App.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // 关于路由
  2. import React from 'react'
  3. import { Router, Route, Switch } from 'react-router-dom'
  4. import history from './utils/history'
  5. import AuthRoute from './components/AuthRoute'
  6. import SpinLoding from './components/SpinLoding'
  7. import AsyncSpinLoding from './components/AsyncSpinLoding'
  8. import { Image } from 'antd'
  9. import { useSelector } from 'react-redux'
  10. import store, { RootState } from './store'
  11. import UpAsyncLoding from './components/UpAsyncLoding'
  12. import MessageCom from './components/Message'
  13. import LookDom from './components/LookDom'
  14. const Layout = React.lazy(() => import('./pages/Layout'))
  15. const Login = React.lazy(() => import('./pages/Login'))
  16. export default function App() {
  17. // 从仓库中获取查看图片的信息
  18. const lookBigImg = useSelector((state: RootState) => state.A0Layout.lookBigImg)
  19. return (
  20. <>
  21. {/* 关于路由 */}
  22. <Router history={history}>
  23. <React.Suspense fallback={<SpinLoding />}>
  24. <Switch>
  25. {/* 测试页面 */}
  26. <Route path='/login' component={Login} />
  27. <AuthRoute path='/' component={Layout} />
  28. </Switch>
  29. </React.Suspense>
  30. </Router>
  31. {/* 发送请求的加载组件 */}
  32. <AsyncSpinLoding />
  33. {/* 所有图片点击预览查看大图 */}
  34. {lookBigImg.show ? (
  35. <Image
  36. preview={{
  37. visible: lookBigImg.show,
  38. src: lookBigImg.url,
  39. onVisibleChange: value => {
  40. // 清除仓库信息
  41. store.dispatch({
  42. type: 'layout/lookBigImg',
  43. payload: { url: '', show: false }
  44. })
  45. }
  46. }}
  47. />
  48. ) : null}
  49. {/* 上传附件的进度条元素 */}
  50. <UpAsyncLoding />
  51. {/* 查看视频音频 */}
  52. <LookDom />
  53. {/* antd 轻提示 ---兼容360浏览器 */}
  54. <MessageCom />
  55. </>
  56. )
  57. }