diff --git a/src/pages/init/index.tsx b/src/pages/init/index.tsx index 45d4c50..ec1e21e 100644 --- a/src/pages/init/index.tsx +++ b/src/pages/init/index.tsx @@ -9,6 +9,7 @@ import { import { loginAction } from "../../store/user/loginUserSlice"; import { Header, NoHeader, Footer } from "../../compenents"; import { useParams, useLocation } from "react-router-dom"; +import { isMobile } from "../../utils/index"; interface Props { loginData?: any; @@ -72,6 +73,10 @@ export const InitPage = (props: Props) => { props.configData["player-bullet-secret-opacity"], }; dispatch(saveConfigAction(config)); + if (isMobile() && props.configData["system-h5-url"] !== "") { + let url = props.configData["system-h5-url"]; + window.location.href = url; + } } setInit(true); }, [props]); diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 9c70365..77a7cc7 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -30,7 +30,19 @@ 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); + } + }); + }); } // 懒加载 diff --git a/src/utils/index.ts b/src/utils/index.ts index 7a18b20..397f374 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -104,3 +104,10 @@ export function changeAppUrl(str: string) { return str + "/"; } } + +export function isMobile() { + let flag = 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; +}