App.tsx 1.6 KB

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