fix: replicate original nav - SubNavBar on sub-pages + external links on home

This commit is contained in:
Chen Gu
2026-05-09 14:49:21 +08:00
parent 27de14f752
commit 61a8245582
3 changed files with 63 additions and 17 deletions

View File

@@ -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<string, string> = {
'/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 (
<div className="fixed bottom-0 left-0 right-0 z-30 flex justify-center pb-1.5">
<div className="flex border border-[#333] bg-[#1a1a1a] relative">
{NAV_ITEMS.map(item => {
const isActive = currentPage === item.id;
return (
<button
key={item.id}
onClick={() => navigate('/' + item.id)}
className={`relative px-3 py-1.5 text-[8px] font-semibold tracking-[0.1em] uppercase
border-r border-[#333] last:border-r-0 transition-colors duration-75
${isActive ? 'bg-[#ff4500]/10 text-[#ff4500]' : 'text-[#555] hover:text-[#888] hover:bg-[#222]'}`}
>
{isActive && <span className="absolute top-0 left-0 right-0 h-[1px] bg-[#ff4500]" />}
{item.label}
</button>
);
})}
</div>
</div>
);
}