diff --git a/src/pages/init/index.tsx b/src/pages/init/index.tsx index 9a368e8..1041025 100644 --- a/src/pages/init/index.tsx +++ b/src/pages/init/index.tsx @@ -7,6 +7,7 @@ import { } from "../../store/system/systemConfigSlice"; import { loginAction } from "../../store/user/loginUserSlice"; import { useParams, useLocation } from "react-router-dom"; +import { isMobile } from "../../utils"; interface Props { loginData?: any; @@ -52,6 +53,14 @@ export const InitPage = (props: Props) => { dispatch(saveConfigAction(config)); } setInit(true); + if ( + !isMobile() && + props.configData && + props.configData["system-pc-url"] !== "" + ) { + let url = props.configData["system-pc-url"]; + window.location.href = url; + } }, [props]); return ( diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 4be6298..656bcda 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -32,7 +32,18 @@ if (getToken()) { }); }); } else { - RootPage = ; + RootPage = lazy(async () => { + return new Promise(async (resolve) => { + try { + let configRes: any = await system.config(); + resolve({ + default: , + }); + } catch (e) { + console.error("系统初始化失败", e); + } + }); + }); } const routes: RouteObject[] = [ diff --git a/src/utils/index.ts b/src/utils/index.ts index b22dd46..b48568d 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -104,3 +104,10 @@ export function setCategoryName(token: string) { export function clearCategoryName() { window.localStorage.removeItem("playedu-h5-categoryName"); } + +export function isMobile() { + let flag = window.navigator.userAgent.match( + /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i + ); + return flag; +}