'use client'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { Folder, FileText } from 'lucide-react'; import { cn } from '@/lib/utils'; import type { ManualTreeNode } from '@/lib/types'; interface TreeNavProps { nodes: ManualTreeNode[]; } /** 递归渲染节点(含子孙) */ function TreeItem({ node, depth = 0 }: { node: ManualTreeNode; depth?: number }) { const pathname = usePathname(); const href = `/manual/${node.id}`; const active = pathname === href; // ===== 顶层目录 → 分区标题(带分隔线 + 缩进引导线) ===== if (depth === 0 && node.type === 0) { return (
{node.title}
{node.children.length > 0 && (
{node.children.map((c) => ( ))}
)}
); } // ===== 嵌套目录 → 子标题(带缩进引导线) ===== if (node.type === 0) { return (
{node.title}
{node.children.length > 0 && (
{node.children.map((c) => ( ))}
)}
); } // ===== 文档 → 可点击链接 ===== return ( {node.title} ); } /** 使用手册左侧树形导航(始终展开) */ export function ManualTreeNav({ nodes }: TreeNavProps) { if (nodes.length === 0) { return (
暂无文档
); } return ( ); }