import { useState, useEffect } from 'react'; import { useRouter } from 'next/router'; import Link from 'next/link'; import Head from 'next/head'; import { HomeIcon, UsersIcon, PhoneIcon, CalendarIcon, DocumentTextIcon, CurrencyDollarIcon, ChartBarIcon, CogIcon, BellIcon, UserGroupIcon, ClipboardDocumentListIcon, Bars3Icon, XMarkIcon, BuildingOfficeIcon, FolderIcon, DocumentIcon, ReceiptPercentIcon, ChevronDownIcon, ChevronRightIcon, LanguageIcon, ArrowRightOnRectangleIcon } from '@heroicons/react/24/outline'; interface DashboardLayoutProps { children: React.ReactNode; title?: string; } const navigation = [ { name: '仪表盘', href: '/dashboard', icon: HomeIcon }, { name: '用户管理', href: '/dashboard/users', icon: UsersIcon }, { name: '翻译员管理', href: '/dashboard/interpreters', icon: LanguageIcon }, { name: '订单管理', icon: DocumentTextIcon, children: [ { name: '订单列表', href: '/dashboard/orders' }, { name: '发票管理', href: '/dashboard/invoices' } ] }, { name: '通话记录', href: '/dashboard/calls', icon: PhoneIcon }, { name: '企业服务', href: '/dashboard/enterprise', icon: BuildingOfficeIcon }, { name: '文档管理', href: '/dashboard/documents', icon: FolderIcon }, { name: '系统设置', href: '/dashboard/settings', icon: CogIcon }, ]; export default function DashboardLayout({ children, title = '管理后台' }: DashboardLayoutProps) { const [sidebarOpen, setSidebarOpen] = useState(false); const [isDemoMode, setIsDemoMode] = useState(true); // 始终启用演示模式 const [expandedItems, setExpandedItems] = useState([]); const router = useRouter(); useEffect(() => { // 演示模式始终启用 setIsDemoMode(true); }, []); const handleLogout = () => { // 清除本地存储并跳转到登录页 localStorage.removeItem('access_token'); localStorage.removeItem('user'); router.push('/auth/login'); }; const toggleExpanded = (itemName: string) => { setExpandedItems(prev => prev.includes(itemName) ? prev.filter(name => name !== itemName) : [...prev, itemName] ); }; const isItemActive = (item: any) => { if (item.href) { return router.pathname === item.href; } if (item.children) { return item.children.some((child: any) => router.pathname === child.href); } return false; }; const renderNavItem = (item: any) => { const hasChildren = item.children && item.children.length > 0; const isActive = isItemActive(item); const isExpanded = expandedItems.includes(item.name); if (hasChildren) { return (
{isExpanded && (
{item.children.map((child: any) => ( {child.name} ))}
)}
); } return ( {item.name} ); }; return ( <> {title} - 口译服务管理平台
{/* 移动端侧边栏 */}
setSidebarOpen(false)} />

口译管理系统

{isDemoMode && ( 演示模式 )}

管理员

admin@demo.com

{/* 桌面端侧边栏 */}

口译管理系统

{isDemoMode && ( 演示模式 )}

管理员

admin@demo.com

{/* 主内容区域 */}

{title}

{isDemoMode && ( 演示模式 )}
{children}
); }