web-backset.cn/apps/web/src/App.tsx

41 lines
1.0 KiB
TypeScript
Raw Normal View History

2023-03-06 10:54:33 +08:00
import { Spin } from "@arco-design/web-react";
import { Suspense } from "react";
2023-02-27 11:23:36 +08:00
import { Route, Routes, useNavigate } from "react-router-dom";
import "./assets/base.less";
import Nav from "./components/Nav";
2023-03-06 10:54:33 +08:00
import { commonRouters, lazyRouters } from "./router";
2023-02-27 11:23:36 +08:00
import { Guard } from "./router/Guard";
function App() {
return (
<>
<Nav />
<main>
<Routes>
2023-03-06 10:54:33 +08:00
{commonRouters.map((router) => (
2023-02-27 11:23:36 +08:00
<Route
key={router.path}
path={router.path}
element={<Guard>{router.element}</Guard>}
/>
))}
2023-03-06 10:54:33 +08:00
{lazyRouters.map((router) => (
<Route
key={router.path}
path={router.path}
element={
<Suspense fallback={<Spin />}>
<Guard>{<router.element />}</Guard>
</Suspense>
}
/>
))}
2023-02-27 11:23:36 +08:00
<Route path="*" element={<span>404</span>} />
</Routes>
</main>
</>
);
}
export default App;