'use client' import { useState, type ReactNode } from 'react' import Link from 'next/link' import { usePathname, useRouter } from 'next/navigation' import { LayoutDashboard, Users, Server, Cpu, Key, BarChart3, ArrowLeftRight, Settings, FileText, LogOut, ChevronLeft, Menu, Bell, } from 'lucide-react' import { AuthGuard, useAuth } from '@/components/auth-guard' import { logout } from '@/lib/auth' import { cn } from '@/lib/utils' const navItems = [ { href: '/', label: '仪表盘', icon: LayoutDashboard }, { href: '/accounts', label: '账号管理', icon: Users }, { href: '/providers', label: '服务商', icon: Server }, { href: '/models', label: '模型管理', icon: Cpu }, { href: '/api-keys', label: 'API 密钥', icon: Key }, { href: '/usage', label: '用量统计', icon: BarChart3 }, { href: '/relay', label: '中转任务', icon: ArrowLeftRight }, { href: '/config', label: '系统配置', icon: Settings }, { href: '/logs', label: '操作日志', icon: FileText }, ] function Sidebar({ collapsed, onToggle, }: { collapsed: boolean onToggle: () => void }) { const pathname = usePathname() const router = useRouter() const { account } = useAuth() function handleLogout() { logout() router.replace('/login') } return ( ) } function Header() { const pathname = usePathname() const currentNav = navItems.find( (item) => item.href === '/' ? pathname === '/' : pathname.startsWith(item.href), ) return (
{/* 移动端菜单按钮 */} {/* 页面标题 */}

{currentNav?.label || '仪表盘'}

{/* 通知 */}
) } function MobileMenuButton() { // Placeholder for mobile menu toggle return ( ) } export default function DashboardLayout({ children }: { children: ReactNode }) { const [sidebarCollapsed, setSidebarCollapsed] = useState(false) return (
setSidebarCollapsed(!sidebarCollapsed)} />
{children}
) }