From 699f9012e0e33237c71d9abdc3072c5b467196db Mon Sep 17 00:00:00 2001 From: wangdl Date: Mon, 15 Jun 2026 22:06:11 +0800 Subject: [PATCH] refactor: organize admin menu into categories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before: 17 flat first-level items, 14 under single "系统运维" After: 5 groups — 总览/用户管理/知识库/学习数据/系统 - AdminMenuItem.path → optional for group headers - Breadcrumb map updated to match new structure - Removed unused entries (hermes/servers/billing/git/etc.) Co-Authored-By: Claude Opus 4.7 --- src/config/menu.tsx | 82 +++++++++++++++++++------------------ src/layouts/AdminLayout.tsx | 25 ++++++----- 2 files changed, 54 insertions(+), 53 deletions(-) diff --git a/src/config/menu.tsx b/src/config/menu.tsx index 9ee0595..d941aa7 100644 --- a/src/config/menu.tsx +++ b/src/config/menu.tsx @@ -1,10 +1,10 @@ import type React from 'react' -import { DashboardOutlined, RobotOutlined, UserOutlined, DollarOutlined, BookOutlined, ImportOutlined, FileOutlined, SafetyOutlined, CodeOutlined, CloudServerOutlined, SettingOutlined, RocketOutlined } from '@ant-design/icons' +import { DashboardOutlined, UserOutlined, BookOutlined, ReadOutlined, SettingOutlined } from '@ant-design/icons' import type { AdminRole } from '@/types/admin' import { hasRole } from '@/constants/roles' export interface AdminMenuItem { - path: string + path?: string name: string icon?: React.ReactNode requiredRole?: AdminRole @@ -13,44 +13,46 @@ export interface AdminMenuItem { export const adminMenuItems: AdminMenuItem[] = [ { path: '/', name: '总览', icon: }, - { path: '/hermes', name: 'Hermes 设置', icon: , requiredRole: 'SUPER_ADMIN' }, - { path: '/users', name: '用户管理', icon: , children: [ - { path: '/users/admins', name: '管理员', requiredRole: 'SUPER_ADMIN' }, - { path: '/users/members', name: '普通用户' }, - ]}, - { path: '/membership', name: '会员与额度', icon: , requiredRole: 'ADMIN' }, - { path: '/knowledge', name: '知识库管理', icon: , children: [ - { path: '/knowledge/bases', name: '知识库列表' }, - { path: '/knowledge/sources', name: '知识源列表' }, - { path: '/knowledge/ops', name: '知识运维' }, - ]}, - { path: '/release', name: '发布决策', icon: , requiredRole: 'ADMIN' }, - { path: '/imports', name: '文档导入', icon: }, - { path: '/files', name: '文件与 COS', icon: }, - { path: '/reporting', name: '报表导出', icon: , requiredRole: 'ADMIN' }, - { path: '/compliance', name: '合规安全', icon: , requiredRole: 'ADMIN' }, - { path: '/audit', name: '审计日志', icon: , requiredRole: 'ADMIN' }, - { path: '/billing', name: 'API 用量', icon: , requiredRole: 'SUPER_ADMIN' }, - { path: '/git', name: '项目中心', icon: }, - { path: '/ops', name: '系统运维', icon: , requiredRole: 'SUPER_ADMIN', children: [ - { path: '/throttle', name: '限流管理' }, - { path: '/security-events', name: '安全事件' }, - { path: '/secrets', name: '密钥管理' }, - { path: '/metrics', name: '接口监控' }, - { path: '/ai-gateway', name: 'AI Gateway' }, - { path: '/servers', name: '服务器' }, - { path: '/chat-logs', name: '对话日志' }, - { path: '/events', name: '事件队列' }, - { path: '/vector', name: '向量检索' }, - { path: '/config', name: '配置管理' }, - { path: '/backup', name: '备份清理' }, - { path: '/cache', name: '缓存管理' }, - { path: '/notification-admin', name: '通知管理' }, - { path: '/safety', name: '内容安全' }, - ]}, - { path: '/reviews', name: '复习数据', icon: , requiredRole: 'ADMIN' }, - { path: '/learning-data', name: '学习数据', icon: , requiredRole: 'ADMIN' }, - { path: '/settings', name: '系统配置', icon: , requiredRole: 'ADMIN' }, + + { + name: '用户管理', icon: , children: [ + { path: '/users/admins', name: '管理员', requiredRole: 'SUPER_ADMIN' }, + { path: '/users/members', name: '普通用户' }, + { path: '/membership', name: '会员与额度', requiredRole: 'ADMIN' }, + ], + }, + + { + name: '知识库', icon: , children: [ + { path: '/knowledge/bases', name: '知识库列表' }, + { path: '/knowledge/sources', name: '知识源列表' }, + { path: '/imports', name: '文档导入' }, + { path: '/files', name: '文件与 COS' }, + ], + }, + + { + name: '学习数据', icon: , children: [ + { path: '/learning', name: '学习 Dashboard' }, + { path: '/learning/events', name: '阅读事件' }, + { path: '/learning/sessions', name: '学习会话' }, + { path: '/learning/progress', name: '阅读进度' }, + { path: '/learning/daily', name: '每日活动' }, + { path: '/learning/records', name: '学习记录' }, + { path: '/learning/timeline', name: '用户时间线' }, + { path: '/learning/anomalies', name: '异常数据' }, + { path: '/learning/user-diagnose', name: '用户诊断' }, + { path: '/learning/material-diagnose', name: '资料诊断' }, + ], + }, + + { + name: '系统', icon: , children: [ + { path: '/settings', name: '系统配置', requiredRole: 'ADMIN' }, + { path: '/audit', name: '审计日志', requiredRole: 'ADMIN' }, + { path: '/ai-costs', name: 'AI 调用与成本' }, + ], + }, ] export function filterMenuByRole(items: AdminMenuItem[], role?: AdminRole): AdminMenuItem[] { diff --git a/src/layouts/AdminLayout.tsx b/src/layouts/AdminLayout.tsx index c06aaa7..eed6074 100644 --- a/src/layouts/AdminLayout.tsx +++ b/src/layouts/AdminLayout.tsx @@ -9,29 +9,28 @@ import type { AdminRole } from '@/types/admin' const breadcrumbMap: Record = { '/': '总览', - '/hermes': 'Hermes 设置', '/users': '用户管理', '/users/admins': '管理员', '/users/members': '普通用户', '/membership': '会员与额度', - '/knowledge': '知识库管理', + '/knowledge': '知识库', '/knowledge/bases': '知识库列表', '/knowledge/sources': '知识源列表', '/imports': '文档导入', '/files': '文件与 COS', + '/learning': '学习数据', + '/learning/events': '阅读事件', + '/learning/sessions': '学习会话', + '/learning/progress': '阅读进度', + '/learning/daily': '每日活动', + '/learning/records': '学习记录', + '/learning/timeline': '用户时间线', + '/learning/anomalies': '异常数据', + '/learning/user-diagnose': '用户诊断', + '/learning/material-diagnose': '资料诊断', '/settings': '系统配置', - '/billing': 'API 用量', - '/git': '代码仓库', - '/servers': '服务器运维', - '/config': '配置管理', - '/throttle': '限流管理', - '/security-events': '安全事件', - '/secrets': '密钥管理', - '/metrics': '接口监控', - '/ai-gateway': 'AI Gateway', - '/safety': '内容安全', - '/events': '事件队列', '/audit': '审计日志', + '/ai-costs': 'AI 调用与成本', } export default function AdminLayout() {