App.tsx 1.9 KB

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