AppM.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import '@/assets/styles/base.css'
  2. // 关于路由
  3. import { useCallback, useEffect, useRef } from 'react'
  4. import MessageCom from './components/Message'
  5. import RouterOrder from './components/RouterOrder'
  6. import screenImg from '@/assets/img/landtip.png'
  7. import AsyncSpinLoding from './components/AsyncSpinLoding'
  8. export default function AppM() {
  9. const setFullFu = useCallback(() => {
  10. clearTimeout(time.current)
  11. time.current = window.setTimeout(() => {
  12. const dom: HTMLDivElement | null = document.querySelector('#root')
  13. if (dom) {
  14. dom.style.height = document.documentElement.clientHeight + 'px'
  15. }
  16. }, 100)
  17. }, [])
  18. const time = useRef(-1)
  19. useEffect(() => {
  20. const dom: HTMLDivElement | null = document.querySelector('#root')
  21. if (dom) {
  22. dom.style.width = '100vw'
  23. dom.style.minHeight = 'auto'
  24. dom.style.height = document.documentElement.clientHeight + 'px'
  25. dom.style.minWidth = 'auto'
  26. }
  27. window.addEventListener('resize', setFullFu, true)
  28. return () => {
  29. window.removeEventListener('resize', setFullFu)
  30. }
  31. }, [setFullFu])
  32. return (
  33. <div id='AppM'>
  34. {/* 关于路由 */}
  35. <RouterOrder />
  36. {/* 发送请求的加载组件 */}
  37. <AsyncSpinLoding />
  38. {/* antd 轻提示 ---兼容360浏览器 */}
  39. <MessageCom />
  40. {/* 横屏提示 */}
  41. <div id='ScreenChange'>
  42. <img src={screenImg} alt='' />
  43. <p>请在竖屏模式浏览</p>
  44. </div>
  45. </div>
  46. )
  47. }