mirror of
https://github.com/PlayEdu/h5.git
synced 2025-06-07 19:44:06 +08:00
自动跳转pc
This commit is contained in:
parent
8dad348c20
commit
3098d99de4
@ -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 (
|
||||
|
@ -32,7 +32,18 @@ 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);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const routes: RouteObject[] = [
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user