added: 系统初始化

This commit is contained in:
none
2023-03-23 11:32:38 +08:00
parent 0fabdf7da7
commit c97a2529a8
5 changed files with 73 additions and 4 deletions

View File

@@ -1,7 +1,33 @@
import { lazy } from "react";
import { RouteObject } from "react-router-dom";
import { system } from "../api";
import { InitPage } from "../pages/init";
import { SystemConfigStoreInterface } from "../store/system/systemConfigSlice";
let config: SystemConfigStoreInterface = {
systemApiUrl: "",
systemPcUrl: "",
systemH5Url: "",
systemLogo: "",
systemName: "",
};
const Init = lazy(async () => {
return new Promise<any>((resolve) => {
system.config().then((res: any) => {
config.systemApiUrl = res.data["system-api-url"];
config.systemH5Url = res.data["system-h5-url"];
config.systemLogo = res.data["system-logo"];
config.systemName = res.data["system-name"];
config.systemPcUrl = res.data["system-pc-url"];
resolve({
default: InitPage,
});
});
});
});
// 懒加载
const LoginPage = lazy(() => import("../pages/login"));
@@ -10,7 +36,7 @@ const IndexPage = lazy(() => import("../pages/index"));
const routes: RouteObject[] = [
{
path: "/",
element: <InitPage />,
element: <Init config={config} />,
children: [
{
path: "/",