'use client'; import {useEffect} from 'react'; import Link from 'next/link'; import {usePathname} from 'next/navigation'; import {dashboardNavigation} from '@/lib/constants/navigation'; import {cn} from '@/lib/utils/cn'; import {isNavigationItemActive} from '@/lib/utils/navigation'; import {useAppShellStore} from '@/store/app-shell'; import type {NavigationIconKey, NavigationItem} from '@/types/navigation'; function SidebarIcon({icon}: { icon: NavigationIconKey }) { const commonProps = { className: 'h-[18px] w-[18px]', fill: 'none', stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round' as const, strokeLinejoin: 'round' as const, viewBox: '0 0 24 24', }; switch (icon) { case 'home': return ( ); case 'node': return ( ); case 'website': return ( ); case 'domain': return ( ); case 'certificate': return ( ); case 'proxy': return ( ); case 'release': return ( ); case 'user': return ( ); case 'setting': return ( ); } } function SidebarNavItem({ item, currentPath, isSidebarCollapsed, forceExpanded, onNavigate, depth = 0, }: { item: NavigationItem; currentPath: string; isSidebarCollapsed: boolean; forceExpanded?: boolean; onNavigate?: () => void; depth?: number; }) { const active = isNavigationItemActive(currentPath, item); const hasChildren = Boolean(item.children?.length); const showLabel = forceExpanded || !isSidebarCollapsed; return (
0 && 'ml-3 rounded-xl', active ? 'border-[var(--border-strong)] bg-[var(--accent-soft)] text-[var(--foreground-primary)]' : 'border-transparent text-[var(--foreground-secondary)] hover:border-[var(--border-default)] hover:bg-[var(--surface-muted)] hover:text-[var(--foreground-primary)]', )} > {showLabel ? {item.label} : null} {showLabel && hasChildren ? (
{item.children?.map((child) => ( ))}
) : null}
); } function SidebarContent({ currentPath, isSidebarCollapsed, forceExpanded = false, onNavigate, }: { currentPath: string; isSidebarCollapsed: boolean; forceExpanded?: boolean; onNavigate?: () => void; }) { const showLabel = forceExpanded || !isSidebarCollapsed; return (
AF
{showLabel ? (

ATSFlare

控制面

) : null}
{showLabel ? (
已连接 ATSFlare Server
) : null}
); } export function DashboardSidebar() { const pathname = usePathname(); const currentPath = pathname ?? '/'; const isSidebarCollapsed = useAppShellStore((state) => state.isSidebarCollapsed); const isMobileSidebarOpen = useAppShellStore((state) => state.isMobileSidebarOpen); const setMobileSidebarOpen = useAppShellStore((state) => state.setMobileSidebarOpen); useEffect(() => { setMobileSidebarOpen(false); }, [currentPath, setMobileSidebarOpen]); return ( <>
setMobileSidebarOpen(false)} aria-hidden='true' /> ); }