feat(router): 添加首页路由并调整PC端路由结构

添加新的首页路由组件,实现设备检测自动跳转功能
重构PC端路由路径,移除冗余子路由配置
This commit is contained in:
超级老白兔
2025-09-11 17:51:05 +08:00
parent 4d6b516662
commit f6b0e7b0d9
3 changed files with 41 additions and 6 deletions

View File

@@ -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 (
<Layout>
<div>
<h1></h1>
</div>
</Layout>
);
};
export default IndexPage;

View File

@@ -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: <Index />,
auth: false, // 需要登录
},
{
path: "/init",
element: <Init />,

View File

@@ -4,14 +4,10 @@ import Dashboard from "@/pages/pc/ckbox/dashboard";
const ckboxRoutes = [
{
path: "/ckbox",
path: "/pc",
element: <CkboxPage />,
auth: true,
children: [
{
path: "",
element: <Dashboard />,
},
{
path: "dashboard",
element: <Dashboard />,