From 3098d99de4d9c1c8c1f9dd4c7c51a82f05bc1740 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com>
Date: Mon, 3 Jul 2023 12:07:48 +0800
Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=B7=B3=E8=BD=ACpc?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/pages/init/index.tsx | 9 +++++++++
src/routes/index.tsx | 13 ++++++++++++-
src/utils/index.ts | 7 +++++++
3 files changed, 28 insertions(+), 1 deletion(-)
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;
+}