mirror of
https://github.com/PlayEdu/frontend.git
synced 2025-12-23 18:59:44 +08:00
added: 系统初始化
This commit is contained in:
@@ -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: "/",
|
||||
|
||||
Reference in New Issue
Block a user