项目初始化

This commit is contained in:
禺狨
2023-06-25 11:25:39 +08:00
commit 87f82475aa
39 changed files with 893 additions and 0 deletions

49
src/routes/index.tsx Normal file
View File

@@ -0,0 +1,49 @@
import { lazy } from "react";
import { RouteObject } from "react-router-dom";
import { system, user } from "../api";
import { getToken } from "../utils";
import { InitPage } from "../pages/init";
import IndexPage from "../pages/index/index";
import LoginPage from "../pages/login";
import PrivateRoute from "../components/private-route";
let RootPage: any = null;
if (getToken()) {
RootPage = lazy(async () => {
return new Promise<any>(async (resolve) => {
try {
let configRes: any = await system.config();
let userRes: any = await user.detail();
resolve({
default: (
<InitPage configData={configRes.data} loginData={userRes.data} />
),
});
} catch (e) {
console.error("系统初始化失败", e);
}
});
});
} else {
RootPage = <InitPage />;
}
const routes: RouteObject[] = [
{
path: "/",
element: RootPage,
children: [
{
path: "/",
element: <IndexPage />,
},
{
path: "/login",
element: <LoginPage />,
},
],
},
];
export default routes;