'use client' import Link from 'next/link' import { usePathname } from 'next/navigation' import { ShieldCheck, ListTodo, User, LayoutDashboard, Scan, BarChart3, Settings, FileText, Users, Bell, FolderKanban, PlusCircle, ClipboardCheck, Bot, MessageSquare } from 'lucide-react' import { cn } from '@/lib/utils' interface NavItem { icon: React.ElementType label: string href: string badge?: 'dot' | 'warning' | number // 支持红点、警告或数字徽章 } // 达人端导航项 const creatorNavItems: NavItem[] = [ { icon: ListTodo, label: '我的任务', href: '/creator' }, { icon: Bell, label: '消息中心', href: '/creator/messages' }, { icon: User, label: '个人中心', href: '/creator/profile' }, ] // 代理商端导航项 const agencyNavItems: NavItem[] = [ { icon: LayoutDashboard, label: '工作台', href: '/agency' }, { icon: Scan, label: '审核台', href: '/agency/review' }, { icon: MessageSquare, label: '申诉处理', href: '/agency/appeals' }, { icon: FileText, label: 'Brief 配置', href: '/agency/briefs' }, { icon: Users, label: '达人管理', href: '/agency/creators' }, { icon: BarChart3, label: '数据报表', href: '/agency/reports' }, { icon: Bell, label: '消息中心', href: '/agency/messages' }, { icon: User, label: '个人中心', href: '/agency/profile' }, ] // 品牌方端导航项 const brandNavItems: NavItem[] = [ { icon: FolderKanban, label: '项目看板', href: '/brand' }, { icon: PlusCircle, label: '创建项目', href: '/brand/projects/create' }, { icon: ClipboardCheck, label: '终审台', href: '/brand/review' }, { icon: Bell, label: '消息中心', href: '/brand/messages' }, { icon: Users, label: '代理商管理', href: '/brand/agencies' }, { icon: FileText, label: '规则配置', href: '/brand/rules' }, { icon: Bot, label: 'AI 配置', href: '/brand/ai-config' }, { icon: Settings, label: '系统设置', href: '/brand/settings' }, ] interface SidebarProps { role?: 'creator' | 'agency' | 'brand' aiServiceError?: boolean // AI 服务是否异常 } export function Sidebar({ role = 'creator', aiServiceError = false }: SidebarProps) { const pathname = usePathname() || '' // 根据 aiServiceError 动态设置 AI 配置的徽章 const getBrandNavItems = (): NavItem[] => { return brandNavItems.map(item => { if (item.href === '/brand/ai-config' && aiServiceError) { return { ...item, badge: 'warning' as const } } return item }) } const navItems = role === 'creator' ? creatorNavItems : role === 'agency' ? agencyNavItems : getBrandNavItems() const isActive = (href: string) => { if (href === `/${role}`) { return pathname === href || pathname === `/${role}/` } return pathname.startsWith(href) } return ( ) } export default Sidebar