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

43 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-03-06 10:54:33 +08:00
import { Suspense } from "react";
2023-03-17 17:58:37 +08:00
import { Route, Routes } from "react-router-dom";
2023-02-27 11:23:36 +08:00
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";
2023-03-18 22:03:17 +08:00
import { Toaster } from "react-hot-toast";
import Loading from "./components/Loading";
2023-02-27 11:23:36 +08:00
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={
2023-03-18 22:03:17 +08:00
<Suspense fallback={<Loading />}>
2023-03-06 10:54:33 +08:00
<Guard>{<router.element />}</Guard>
</Suspense>
}
/>
))}
2023-02-27 11:23:36 +08:00
<Route path="*" element={<span>404</span>} />
</Routes>
</main>
2023-03-18 22:03:17 +08:00
<Toaster />
2023-02-27 11:23:36 +08:00
</>
);
}
export default App;