33 lines
944 B
TypeScript
33 lines
944 B
TypeScript
import { NavLink, Navigate, Outlet } from 'react-router-dom';
|
|
import { isLoggedIn } from '../lib/api';
|
|
|
|
const TABS = [
|
|
{ to: '/', end: true, icon: 'dashboard', label: '首页' },
|
|
{ to: '/stores', icon: 'store', label: '门店管理' },
|
|
{ to: '/center', icon: 'account_circle', label: '合伙人中心' },
|
|
] as const;
|
|
|
|
export default function TabLayout() {
|
|
if (!isLoggedIn()) {
|
|
return <Navigate to="/login" replace />;
|
|
}
|
|
return (
|
|
<>
|
|
<Outlet />
|
|
<nav className="app-tabbar">
|
|
{TABS.map((tab) => (
|
|
<NavLink
|
|
key={tab.to}
|
|
to={tab.to}
|
|
end={tab.end}
|
|
className={({ isActive }) => `app-tabbar-item${isActive ? ' active' : ''}`}
|
|
>
|
|
<span className="material-symbols-outlined app-tabbar-icon">{tab.icon}</span>
|
|
<span className="app-tabbar-label">{tab.label}</span>
|
|
</NavLink>
|
|
))}
|
|
</nav>
|
|
</>
|
|
);
|
|
}
|