App.tsx 1.9 KB

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