From 319dd2c8399d508264fae612ce421df6dba28851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=81=B5=E5=BA=94?= Date: Sat, 4 Jul 2026 17:35:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BE=A7=E8=BE=B9?= =?UTF-8?q?=E6=A0=8F=E5=AF=BC=E8=88=AA=20P0=20=E2=80=94=20=E6=89=80?= =?UTF-8?q?=E6=9C=89=E5=AF=BC=E8=88=AA=E8=B7=AF=E5=BE=84=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20/app=20=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因:导航配置中所有 path 缺少 /app 前缀,与路由配置不匹配。 侧边栏 navigate('/dashboard') 但路由实际为 /app/dashboard, 导致所有侧边栏按钮点击后 URL 停在 /app/dashboard。 修复内容: - navigation.ts/tsx: NAV_ITEMS 和 NAV_GROUPS 所有 path 加 /app 前缀 - Sidebar.tsx: isMenuItemActive 中 dashboard 特殊判断更新为 /app/dashboard - Header.tsx: isActive 函数 + logo 点击 + 用户菜单导航路径修复 - 页面内硬编码路径修复: - Dashboard.tsx: /history → /app/history - MyTemplates.tsx: /editing-planner → /app/editing-planner - DuplicationResults.tsx: /duplication → /app/duplication - DuplicationDetail.tsx: /duplication/results → /app/duplication/results - UpgradeSubscription.tsx: /subscription → /app/subscription - AdminComingSoon.tsx: / → /app/dashboard - Login.tsx: 登录成功后 / → /app/dashboard TypeScript 零错误。 --- apps/web/src/components/layout/Header.tsx | 11 ++-- apps/web/src/components/layout/Sidebar.tsx | 5 +- apps/web/src/config/navigation.ts | 53 ++++++++++--------- apps/web/src/config/navigation.tsx | 46 ++++++++-------- apps/web/src/pages/admin/AdminComingSoon.tsx | 2 +- apps/web/src/pages/auth/Login.tsx | 2 +- apps/web/src/pages/dashboard/Dashboard.tsx | 4 +- .../pages/duplication/DuplicationDetail.tsx | 2 +- .../pages/duplication/DuplicationResults.tsx | 2 +- .../src/pages/my-templates/MyTemplates.tsx | 4 +- .../subscription/UpgradeSubscription.tsx | 2 +- 11 files changed, 69 insertions(+), 64 deletions(-) diff --git a/apps/web/src/components/layout/Header.tsx b/apps/web/src/components/layout/Header.tsx index cb1223282..3bb2e9aff 100644 --- a/apps/web/src/components/layout/Header.tsx +++ b/apps/web/src/components/layout/Header.tsx @@ -30,13 +30,13 @@ const Header: React.FC = () => { key: "profile", icon: , label: "个人设置", - onClick: () => navigate("/profile"), + onClick: () => navigate("/app/profile"), }, { key: "subscription", icon: , label: "订阅管理", - onClick: () => navigate("/subscription"), + onClick: () => navigate("/app/subscription"), }, { type: "divider" }, { @@ -49,8 +49,9 @@ const Header: React.FC = () => { /** 判断导航项是否激活 */ const isActive = (path: string) => { - if (path === "/dashboard") { - return location.pathname === "/" || location.pathname === "/dashboard"; + // 首页特殊处理:/ 和 /app/dashboard 都算激活 + if (path === "/app/dashboard") { + return location.pathname === "/" || location.pathname === "/app" || location.pathname === "/app/dashboard"; } return location.pathname.startsWith(path); }; @@ -61,7 +62,7 @@ const Header: React.FC = () => { +
{recentTasks.map((task) => ( @@ -331,7 +331,7 @@ const Dashboard: React.FC = () => { diff --git a/apps/web/src/pages/duplication/DuplicationDetail.tsx b/apps/web/src/pages/duplication/DuplicationDetail.tsx index d603f6db0..39ad49949 100644 --- a/apps/web/src/pages/duplication/DuplicationDetail.tsx +++ b/apps/web/src/pages/duplication/DuplicationDetail.tsx @@ -170,7 +170,7 @@ const DuplicationDetail: React.FC = () => { diff --git a/apps/web/src/pages/my-templates/MyTemplates.tsx b/apps/web/src/pages/my-templates/MyTemplates.tsx index f6199c4ea..b2d961e44 100644 --- a/apps/web/src/pages/my-templates/MyTemplates.tsx +++ b/apps/web/src/pages/my-templates/MyTemplates.tsx @@ -141,7 +141,7 @@ const MyTemplates: React.FC = () => { @@ -178,7 +178,7 @@ const MyTemplates: React.FC = () => { description="还没有模板,点击右上角「新建模板」开始创建" style={{ padding: 80 }} > - diff --git a/apps/web/src/pages/subscription/UpgradeSubscription.tsx b/apps/web/src/pages/subscription/UpgradeSubscription.tsx index 87390d4aa..b24f06d40 100644 --- a/apps/web/src/pages/subscription/UpgradeSubscription.tsx +++ b/apps/web/src/pages/subscription/UpgradeSubscription.tsx @@ -160,7 +160,7 @@ const UpgradeSubscription: React.FC = () => { try { const res = await cancelSubscription(); message.success(res.message); - navigate("/subscription"); + navigate("/app/subscription"); } catch (err: unknown) { if (!(err as { __msgShown?: boolean })?.__msgShown) message.error("取消失败");