From 61a8245582f396974ed19bb0c70e3864a8aa0738 Mon Sep 17 00:00:00 2001 From: Chen Gu Date: Sat, 9 May 2026 14:49:21 +0800 Subject: [PATCH] fix: replicate original nav - SubNavBar on sub-pages + external links on home --- src/components/layout/SubNavBar.tsx | 54 +++++++++++++++++++++++++++++ src/pages/Home.tsx | 22 ++++-------- src/router.tsx | 4 ++- 3 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 src/components/layout/SubNavBar.tsx diff --git a/src/components/layout/SubNavBar.tsx b/src/components/layout/SubNavBar.tsx new file mode 100644 index 0000000..c761b90 --- /dev/null +++ b/src/components/layout/SubNavBar.tsx @@ -0,0 +1,54 @@ +import React from 'react'; +import { useNavigate, useLocation } from 'react-router-dom'; + +interface DockItem { + id: string; + label: string; +} + +const NAV_ITEMS: DockItem[] = [ + { id: 'optimization', label: '快速优化' }, + { id: 'exposure', label: '画面滤镜' }, + { id: 'filter-community', label: '滤镜社区' }, + { id: 'weapon', label: '改枪方案' }, + { id: 'settings', label: '设置' }, +]; + +const PAGE_ID_MAP: Record = { + '/optimization': 'optimization', + '/exposure': 'exposure', + '/filter-community': 'filter-community', + '/weapon': 'weapon', + '/scheme-detail': 'weapon', + '/settings': 'settings', +}; + +export default function SubNavBar() { + const navigate = useNavigate(); + const location = useLocation(); + const currentPage = PAGE_ID_MAP[location.pathname] || ''; + + if (!currentPage || currentPage === 'home') return null; + + return ( +
+
+ {NAV_ITEMS.map(item => { + const isActive = currentPage === item.id; + return ( + + ); + })} +
+
+ ); +} diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index c95288a..9784f5c 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -60,22 +60,12 @@ export default function Home() { /> - {/* 社区动态 */} - -
-

最新动态

- 实时 -
-
- {[1, 2, 3].map(i => ( -
- - [{String(i).padStart(4, '0')}] - 社区动态 #{i} -
- ))} -
-
+ {/* 外部链接(对齐原版) */} +
+ 社区教程 + 微信 + 官网 +
{/* 底部启动按钮 */}
diff --git a/src/router.tsx b/src/router.tsx index 3d9bc64..31879b7 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -2,6 +2,7 @@ import React, { Suspense, lazy } from 'react'; import { Routes, Route, useNavigate } from 'react-router-dom'; import PageContainer from './components/layout/PageContainer'; import TopHud from './components/layout/TopHud'; +import SubNavBar from './components/layout/SubNavBar'; const Home = lazy(() => import('./pages/Home')); const Optimization = lazy(() => import('./pages/Optimization')); @@ -44,11 +45,12 @@ function PageShell({ children, currentPage }: { children: React.ReactNode; curre ]} onBack={isHome ? undefined : () => navigate(-1)} /> - + }> {children} +
); }