RouterOrder.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import history, { isMobileFu } from "@/utils/history";
  2. import React from "react";
  3. import { Route, Router, Switch } from "react-router-dom";
  4. import SpinLoding from "./SpinLoding";
  5. import NotFound from "@/components/NotFound";
  6. const A1Home = React.lazy(() => import("@/pages/A1Home"));
  7. const A1HomeM = React.lazy(() => import("@/pages/A1HomeM"));
  8. const B1Village = React.lazy(() => import("@/pages/B1Village"));
  9. const B1VillageM = React.lazy(() => import("@/pages/B1VillageM"));
  10. const C1Architec = React.lazy(() => import("@/pages/C1Architec"));
  11. const C1ArchitecM = React.lazy(() => import("@/pages/C1ArchitecM"));
  12. const C2ArchitecInfo = React.lazy(() => import("@/pages/C2ArchitecInfo"));
  13. const D1Build = React.lazy(() => import("@/pages/D1Build"));
  14. const D1BuildM = React.lazy(() => import("@/pages/D1BuildM"));
  15. const D2BuildInfo = React.lazy(() => import("@/pages/D2BuildInfo"));
  16. const Z2Scene = React.lazy(() => import("@/pages/Z2Scene"));
  17. const Z1Search = React.lazy(() => import("@/pages/Z1Search"));
  18. const routerArr = [
  19. {
  20. id: 1,
  21. name: "总览",
  22. path: "/",
  23. exact: true,
  24. Com: isMobileFu() ? A1HomeM : A1Home,
  25. },
  26. {
  27. id: 2,
  28. name: "村落",
  29. path: "/village",
  30. exact: false,
  31. Com: isMobileFu() ? B1VillageM : B1Village,
  32. },
  33. {
  34. id: 3,
  35. name: "建筑",
  36. path: "/architec",
  37. exact: false,
  38. Com: isMobileFu() ? C1ArchitecM : C1Architec,
  39. },
  40. {
  41. id: 4,
  42. name: "建筑详情",
  43. path: "/architecInfo",
  44. exact: false,
  45. Com: C2ArchitecInfo,
  46. },
  47. {
  48. id: 5,
  49. name: "构件",
  50. path: "/build",
  51. exact: false,
  52. Com: isMobileFu() ? D1BuildM : D1Build,
  53. },
  54. {
  55. id: 6,
  56. name: "构件详情",
  57. path: "/buildInfo",
  58. exact: false,
  59. Com: D2BuildInfo,
  60. },
  61. {
  62. id: 7,
  63. name: "场景",
  64. path: "/scene",
  65. exact: false,
  66. Com: Z2Scene,
  67. },
  68. {
  69. id: 8,
  70. name: "搜索",
  71. path: "/search",
  72. exact: false,
  73. Com: Z1Search,
  74. },
  75. {
  76. id: 9,
  77. name: "找不到页面",
  78. path: "*",
  79. exact: false,
  80. Com: NotFound,
  81. },
  82. ];
  83. function RouterOrder() {
  84. return (
  85. <Router history={history}>
  86. <React.Suspense fallback={<SpinLoding />}>
  87. <Switch>
  88. {routerArr.map((v) => (
  89. <Route key={v.id} path={v.path} exact={v.exact} component={v.Com} />
  90. ))}
  91. </Switch>
  92. </React.Suspense>
  93. </Router>
  94. );
  95. }
  96. const MemoRouterOrder = React.memo(RouterOrder);
  97. export default MemoRouterOrder;