"use client" import Link from "next/link" import { usePathname } from "next/navigation" import { LayoutDashboard, Database, Tags, Brain, Package, Monitor, ChevronDown, ChevronRight, FileText, Users, Zap, Target, BarChart3, Shield, Bell, Server, MessageSquare, Sparkles, GitBranch, Calendar, Bot, Search, FileOutput, Webhook, Activity, ScrollText, Globe, } from "lucide-react" import { cn } from "@/lib/utils" import { useState } from "react" // 五大核心模块导航结构(不可删除) const NAV_ITEMS = [ // 第一部分:数据概览 { href: "/", label: "数据概览", icon: LayoutDashboard, description: "AI对话 · 数据仪表板" }, // 第二部分:数据接入 { href: "/data-ingestion", label: "数据接入", icon: Database, children: [ { href: "/data-ingestion/sources", label: "数据源管理", icon: Database }, { href: "/data-ingestion/ai-engine", label: "AI标签引擎", icon: Brain }, { href: "/data-ingestion/cleaning", label: "清洗规则", icon: Zap }, { href: "/data-ingestion/tasks", label: "任务调度", icon: Calendar }, { href: "/data-ingestion/lineage", label: "数据血缘", icon: GitBranch }, ], }, // 第三部分:标签画像 { href: "/tag-portrait", label: "标签画像", icon: Tags, children: [ { href: "/tag-portrait/tags", label: "标签管理", icon: Tags }, { href: "/tag-portrait/portrait", label: "用户画像", icon: Users }, { href: "/tag-portrait/crowd", label: "流量池", icon: Target }, ], }, // 第四部分:AI Agent(对接飞书/企微等外部平台) { href: "/ai-agent", label: "AI Agent", icon: Bot, children: [ { href: "/ai-agent/channels", label: "渠道配置", icon: Webhook }, { href: "/ai-agent/smart-tag", label: "AI打标", icon: Sparkles }, { href: "/ai-agent/data-cleaning", label: "AI清洗", icon: Zap }, { href: "/ai-agent/report", label: "智能报告", icon: FileText }, ], }, // 第五部分:数据市场 { href: "/data-market", label: "数据市场", icon: Package, children: [ { href: "/data-market/packages", label: "流量包", icon: Package }, { href: "/data-market/api", label: "API服务", icon: Server }, { href: "/data-market/open-api", label: "开放接口", icon: Globe }, ], }, ] as const // 底部工具菜单(系统监控等) const BOTTOM_NAV_ITEMS = [ { href: "/monitoring/health", label: "系统监控", icon: Monitor, }, ] as const type NavItem = (typeof NAV_ITEMS)[number] function NavItemComponent({ item, level = 0 }: { item: NavItem; level?: number }) { const pathname = usePathname() const [isOpen, setIsOpen] = useState(false) const hasChildren = "children" in item && item.children && item.children.length > 0 const isExactActive = pathname === item.href const isActive = isExactActive || (item.href !== "/" && pathname.startsWith(item.href)) // Auto expand if child is active const childActive = hasChildren && item.children?.some((child) => pathname === child.href || pathname.startsWith(child.href)) return (