From f6b0e7b0d9ef05d8ab3788e4022e63f66ce4db0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E8=80=81=E7=99=BD=E5=85=94?= Date: Thu, 11 Sep 2025 17:51:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(router):=20=E6=B7=BB=E5=8A=A0=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E8=B7=AF=E7=94=B1=E5=B9=B6=E8=B0=83=E6=95=B4PC?= =?UTF-8?q?=E7=AB=AF=E8=B7=AF=E7=94=B1=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加新的首页路由组件,实现设备检测自动跳转功能 重构PC端路由路径,移除冗余子路由配置 --- Touchkebao/src/pages/index.tsx | 34 +++++++++++++++++++++++++ Touchkebao/src/router/module/common.tsx | 7 ++++- Touchkebao/src/router/module/pc.tsx | 6 +---- 3 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 Touchkebao/src/pages/index.tsx diff --git a/Touchkebao/src/pages/index.tsx b/Touchkebao/src/pages/index.tsx new file mode 100644 index 00000000..ed9c8153 --- /dev/null +++ b/Touchkebao/src/pages/index.tsx @@ -0,0 +1,34 @@ +import React, { useEffect } from "react"; +import { useNavigate } from "react-router-dom"; +import Layout from "@/components/Layout/Layout"; + +const IndexPage: React.FC = () => { + const navigate = useNavigate(); + + useEffect(() => { + // 检测是否为移动端 + const isMobile = () => { + const userAgent = navigator.userAgent; + const mobileRegex = + /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i; + return mobileRegex.test(userAgent) || window.innerWidth <= 768; + }; + + // 如果是移动端,跳转到/pc/dashboard + if (isMobile()) { + navigate("/mobile/dashboard"); + } else { + navigate("/pc/dashboard"); + } + }, [navigate]); + + return ( + +
+

首页

+
+
+ ); +}; + +export default IndexPage; diff --git a/Touchkebao/src/router/module/common.tsx b/Touchkebao/src/router/module/common.tsx index f3f6e677..d7062d05 100644 --- a/Touchkebao/src/router/module/common.tsx +++ b/Touchkebao/src/router/module/common.tsx @@ -1,8 +1,13 @@ import Login from "@/pages/login/Login"; import Guide from "@/pages/guide"; import Init from "@/pages/iframe/init"; - +import Index from "@/pages/index"; const authRoutes = [ + { + path: "/", + element: , + auth: false, // 需要登录 + }, { path: "/init", element: , diff --git a/Touchkebao/src/router/module/pc.tsx b/Touchkebao/src/router/module/pc.tsx index 1fbb8b61..0464f090 100644 --- a/Touchkebao/src/router/module/pc.tsx +++ b/Touchkebao/src/router/module/pc.tsx @@ -4,14 +4,10 @@ import Dashboard from "@/pages/pc/ckbox/dashboard"; const ckboxRoutes = [ { - path: "/ckbox", + path: "/pc", element: , auth: true, children: [ - { - path: "", - element: , - }, { path: "dashboard", element: ,