2026-05-22 16:41:10 +08:00
|
|
|
import type React from 'react'
|
|
|
|
|
import { DashboardOutlined, RobotOutlined, UserOutlined, DollarOutlined, BookOutlined, ImportOutlined, FileOutlined, SafetyOutlined, CodeOutlined, CloudServerOutlined, SettingOutlined } from '@ant-design/icons'
|
2026-05-21 17:19:58 +08:00
|
|
|
import type { AdminRole } from '@/types/admin'
|
2026-05-22 16:41:10 +08:00
|
|
|
import { hasRole } from '@/constants/roles'
|
2026-05-22 16:39:01 +08:00
|
|
|
|
|
|
|
|
export interface AdminMenuItem {
|
|
|
|
|
path: string
|
|
|
|
|
name: string
|
|
|
|
|
icon?: React.ReactNode
|
|
|
|
|
requiredRole?: AdminRole
|
|
|
|
|
children?: AdminMenuItem[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const adminMenuItems: AdminMenuItem[] = [
|
|
|
|
|
{ path: '/', name: '总览', icon: <DashboardOutlined /> },
|
|
|
|
|
{ path: '/assistant', name: '任务助理', icon: <RobotOutlined /> },
|
2026-05-22 17:13:09 +08:00
|
|
|
{ path: '/hermes', name: 'Hermes 设置', icon: <RobotOutlined />, requiredRole: 'SUPER_ADMIN' },
|
2026-05-22 16:41:10 +08:00
|
|
|
{ path: '/users', name: '用户管理', icon: <UserOutlined />, children: [
|
|
|
|
|
{ path: '/users/admins', name: '管理员', requiredRole: 'SUPER_ADMIN' },
|
|
|
|
|
{ path: '/users/members', name: '普通用户' },
|
|
|
|
|
]},
|
2026-05-22 16:39:01 +08:00
|
|
|
{ path: '/membership', name: '会员与额度', icon: <DollarOutlined />, requiredRole: 'ADMIN' },
|
2026-05-22 16:41:10 +08:00
|
|
|
{ path: '/knowledge', name: '知识库管理', icon: <BookOutlined />, children: [
|
|
|
|
|
{ path: '/knowledge/bases', name: '知识库列表' },
|
|
|
|
|
{ path: '/knowledge/sources', name: '知识源列表' },
|
2026-05-24 13:42:54 +08:00
|
|
|
{ path: '/knowledge/ops', name: '知识运维' },
|
2026-05-22 16:41:10 +08:00
|
|
|
]},
|
2026-05-22 16:39:01 +08:00
|
|
|
{ path: '/imports', name: '文档导入', icon: <ImportOutlined /> },
|
|
|
|
|
{ path: '/files', name: '文件与 COS', icon: <FileOutlined /> },
|
2026-05-24 18:01:38 +08:00
|
|
|
{ path: '/reporting', name: '报表导出', icon: <FileOutlined />, requiredRole: 'ADMIN' },
|
2026-05-22 16:39:01 +08:00
|
|
|
{ path: '/audit', name: '审计日志', icon: <SafetyOutlined />, requiredRole: 'ADMIN' },
|
|
|
|
|
{ path: '/billing', name: 'API 用量', icon: <DollarOutlined />, requiredRole: 'SUPER_ADMIN' },
|
|
|
|
|
{ path: '/git', name: '代码仓库', icon: <CodeOutlined /> },
|
2026-05-22 22:31:46 +08:00
|
|
|
{ path: '/ops', name: '系统运维', icon: <CloudServerOutlined />, requiredRole: 'SUPER_ADMIN', children: [
|
2026-05-23 20:47:34 +08:00
|
|
|
{ path: '/throttle', name: '限流管理' },
|
|
|
|
|
{ path: '/security-events', name: '安全事件' },
|
2026-05-23 20:37:26 +08:00
|
|
|
{ path: '/secrets', name: '密钥管理' },
|
2026-05-22 23:21:15 +08:00
|
|
|
{ path: '/metrics', name: '接口监控' },
|
2026-05-23 09:39:53 +08:00
|
|
|
{ path: '/ai-gateway', name: 'AI Gateway' },
|
2026-05-22 23:21:15 +08:00
|
|
|
{ path: '/servers', name: '服务器' },
|
2026-05-24 13:58:40 +08:00
|
|
|
{ path: '/chat-logs', name: '对话日志' },
|
2026-05-22 23:21:15 +08:00
|
|
|
{ path: '/events', name: '事件队列' },
|
2026-05-24 10:18:22 +08:00
|
|
|
{ path: '/vector', name: '向量检索' },
|
2026-05-22 22:37:28 +08:00
|
|
|
{ path: '/config', name: '配置管理' },
|
2026-05-24 17:57:50 +08:00
|
|
|
{ path: '/backup', name: '备份清理' },
|
feat: M3-04/05/06 — Workspace Experience, Notification, Cache Module
- M3-04: Workspace Module (RecentItem, Favorite, SearchHistory, Tags, Search, Dashboard)
- M3-05: Notification Module (Preferences, PushToken, Templates, Admin endpoints)
- M3-06: Cache Module (CacheService with wrap/penetration protection, Admin cache management)
- E2E: 27 new tests for M3-04/05/06 (35/36 passing overall)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 16:00:29 +08:00
|
|
|
{ path: '/cache', name: '缓存管理' },
|
2026-05-24 16:17:00 +08:00
|
|
|
{ path: '/notification-admin', name: '通知管理' },
|
2026-05-22 23:21:15 +08:00
|
|
|
{ path: '/safety', name: '内容安全' },
|
2026-05-22 22:31:46 +08:00
|
|
|
]},
|
2026-05-24 16:17:00 +08:00
|
|
|
{ path: '/reviews', name: '复习数据', icon: <BookOutlined />, requiredRole: 'ADMIN' },
|
2026-05-24 17:45:53 +08:00
|
|
|
{ path: '/learning-data', name: '学习数据', icon: <BookOutlined />, requiredRole: 'ADMIN' },
|
2026-05-22 16:39:01 +08:00
|
|
|
{ path: '/settings', name: '系统配置', icon: <SettingOutlined />, requiredRole: 'ADMIN' },
|
2026-05-21 17:19:58 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
export function filterMenuByRole(items: AdminMenuItem[], role?: AdminRole): AdminMenuItem[] {
|
2026-05-22 16:41:10 +08:00
|
|
|
return items.filter(item => {
|
|
|
|
|
if (item.requiredRole && role && !hasRole(role, item.requiredRole)) return false
|
|
|
|
|
if (item.children) item.children = filterMenuByRole(item.children, role)
|
|
|
|
|
return true
|
|
|
|
|
})
|
2026-05-21 17:19:58 +08:00
|
|
|
}
|