+
,
+ children:
,
+ },
+ {
+ key: 'categories',
+ label: '分类管理',
+ icon:
,
+ children:
,
+ },
+ {
+ key: 'search',
+ label: '搜索',
+ icon:
,
+ children:
,
+ },
+ {
+ key: 'analytics',
+ label: '分析看板',
+ icon:
,
+ children:
,
+ },
+ ]}
+ />
+
+ )
+}
+
+// === 辅助函数 ===
+
+function flattenCategories(cats: CategoryResponse[]): { id: string; name: string }[] {
+ const result: { id: string; name: string }[] = []
+ for (const c of cats) {
+ result.push({ id: c.id, name: c.name })
+ if (c.children?.length) {
+ result.push(...flattenCategories(c.children))
+ }
+ }
+ return result
+}
+
+interface TreeNode {
+ key: string
+ title: React.ReactNode
+ icon?: React.ReactNode
+ children?: TreeNode[]
+}
+
+function buildTreeData(cats: CategoryResponse[], onDelete: (id: string) => void): TreeNode[] {
+ return cats.map((c) => ({
+ key: c.id,
+ title: (
+