import { useMemo } from 'react'; import { useRouter } from 'next/router'; import { Icon } from './icons'; const tabs = [ { href: '/', label: '首页', icon: 'home' }, { href: '/stats', label: '统计', icon: 'chart' }, { href: '/recurring', label: '周期', icon: 'repeat' }, { href: '/categories', label: '分类', icon: 'tags' }, ]; export default function AppShell({ title, subtitle, actions, headerContent, children, contentClassName = '', hideNav = false, compactHeader = false }) { const router = useRouter(); const activeTab = useMemo(() => { const matched = tabs.find((tab) => tab.href === router.pathname); return matched?.href || null; }, [router.pathname]); const headerNode = headerContent || (title ? (

{title}

{subtitle ?

{subtitle}

: null}
) : null); const headerClassName = [ 'app-header', compactHeader ? 'app-header--compact' : '', headerNode ? 'app-header--with-content' : 'app-header--actions-only', actions ? 'app-header--with-actions' : '', ].filter(Boolean).join(' '); return (
{headerNode ?
{headerNode}
:
{children}
{!hideNav ? ( ) : null}
); }