App.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 { useDispatch, useSelector } from "react-redux";
  11. import { RootState } from "./store";
  12. import UpAsyncLoding from "./components/UpAsyncLoding";
  13. import MessageCom from "./components/Message";
  14. const Layout = React.lazy(() => import("./pages/Layout"));
  15. const Login = React.lazy(() => import("./pages/Login"));
  16. export default function App() {
  17. const dispatch = useDispatch();
  18. // 从仓库中获取查看图片的信息
  19. const lookBigImg = useSelector(
  20. (state: RootState) => state.loginStore.lookBigImg
  21. );
  22. return (
  23. <>
  24. {/* 关于路由 */}
  25. <Router history={history}>
  26. <React.Suspense fallback={<SpinLoding />}>
  27. <Switch>
  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: lookBigImg.url,
  40. onVisibleChange: (value) => {
  41. // 清除仓库信息
  42. dispatch({
  43. type: "login/lookBigImg",
  44. payload: { url: "", show: false },
  45. });
  46. },
  47. }}
  48. />
  49. {/* 上传附件的进度条元素 */}
  50. <UpAsyncLoding />
  51. {/* antd 轻提示 ---兼容360浏览器 */}
  52. <MessageCom />
  53. </>
  54. );
  55. }