手机浏览跳转h5

This commit is contained in:
禺狨 2023-07-03 14:22:47 +08:00
parent d47f1a9250
commit 2949eaafda
3 changed files with 25 additions and 1 deletions

View File

@ -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]);

View File

@ -30,7 +30,19 @@ if (getToken()) {
});
});
} else {
RootPage = <InitPage />;
RootPage = lazy(async () => {
return new Promise<any>(async (resolve) => {
try {
let configRes: any = await system.config();
resolve({
default: <InitPage configData={configRes.data} />,
});
} catch (e) {
console.error("系统初始化失败", e);
}
});
});
}
// 懒加载

View File

@ -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;
}