2026-05-22 00:38:56 +08:00
|
|
|
|
import type React from 'react'
|
2026-05-22 16:39:42 +08:00
|
|
|
|
import { DashboardOutlined, RobotOutlined, UserOutlined, DollarOutlined, BookOutlined, ImportOutlined, FileOutlined, SafetyOutlined, CodeOutlined, CloudServerOutlined, SettingOutlined }
|
2026-05-21 17:19:58 +08:00
|
|
|
|
import type { AdminRole } from '@/types/admin'
|
2026-05-22 16:39:42 +08:00
|
|
|
|
import { SettingOutlined, CloudServerOutlined, CodeOutlined, SafetyOutlined, FileOutlined, ImportOutlined, BookOutlined, DollarOutlined, UserOutlined, RobotOutlined, DashboardOutlined, 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 /> },
|
|
|
|
|
|
{
|
|
|
|
|
|
path: '/users',
|
|
|
|
|
|
name: '用户管理',
|
|
|
|
|
|
icon: <UserOutlined />,
|
|
|
|
|
|
requiredRole: 'ADMIN',
|
|
|
|
|
|
children: [
|
|
|
|
|
|
{ path: '/users/admins', name: '管理员', requiredRole: 'SUPER_ADMIN' },
|
|
|
|
|
|
{ path: '/users/members', name: '普通用户' },
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
{ path: '/membership', name: '会员与额度', icon: <DollarOutlined />, requiredRole: 'ADMIN' },
|
|
|
|
|
|
{
|
|
|
|
|
|
path: '/knowledge',
|
|
|
|
|
|
name: '知识库管理',
|
|
|
|
|
|
icon: <BookOutlined />,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
{ path: '/knowledge/bases', name: '知识库列表' },
|
|
|
|
|
|
{ path: '/knowledge/sources', name: '知识源列表' },
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
{ path: '/imports', name: '文档导入', icon: <ImportOutlined /> },
|
|
|
|
|
|
{ path: '/files', name: '文件与 COS', icon: <FileOutlined /> },
|
|
|
|
|
|
{ path: '/settings', name: '系统配置', icon: <SettingOutlined />, requiredRole: 'ADMIN' },
|
|
|
|
|
|
{ path: '/billing', name: 'API 用量', icon: <DollarOutlined />, requiredRole: 'SUPER_ADMIN' },
|
|
|
|
|
|
{ path: '/git', name: '代码仓库', icon: <CodeOutlined /> },
|
|
|
|
|
|
{ path: '/servers', name: '服务器运维', icon: <CloudServerOutlined />, requiredRole: 'SUPER_ADMIN' },
|
|
|
|
|
|
{ path: '/audit', name: '审计日志', icon: <SafetyOutlined />, requiredRole: 'ADMIN' },
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
export function filterMenuByRole(items: AdminMenuItem[], role?: AdminRole): AdminMenuItem[] {
|
|
|
|
|
|
if (!role) return []
|
|
|
|
|
|
return items
|
|
|
|
|
|
.filter((item) => !item.requiredRole || hasRole(role, item.requiredRole))
|
|
|
|
|
|
.map((item) => ({
|
|
|
|
|
|
...item,
|
|
|
|
|
|
children: item.children ? filterMenuByRole(item.children, role) : undefined,
|
|
|
|
|
|
}))
|
|
|
|
|
|
.filter((item) => {
|
|
|
|
|
|
if (item.children && item.children.length === 0) return false
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
}export const menuItems: AdminMenuItem[] = [
|
|
|
|
|
|
{ path: '/', name: '总览', icon: <DashboardOutlined /> },
|
|
|
|
|
|
{ path: '/assistant', name: '任务助理', icon: <RobotOutlined /> },
|
|
|
|
|
|
{
|
|
|
|
|
|
path: '/users',
|
|
|
|
|
|
name: '用户管理',
|
|
|
|
|
|
icon: <UserOutlined />,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
{ path: '/users/admins', name: '管理员', requiredRole: 'SUPER_ADMIN' },
|
|
|
|
|
|
{ path: '/users/members', name: '普通用户' },
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
{ path: '/membership', name: '会员与额度', icon: <DollarOutlined />, requiredRole: 'ADMIN' },
|
|
|
|
|
|
{
|
|
|
|
|
|
path: '/knowledge',
|
|
|
|
|
|
name: '知识库管理',
|
|
|
|
|
|
icon: <BookOutlined />,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
{ path: '/knowledge/bases', name: '知识库列表' },
|
|
|
|
|
|
{ path: '/knowledge/sources', name: '知识源列表' },
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
{ path: '/imports', name: '文档导入', icon: <ImportOutlined /> },
|
|
|
|
|
|
{ path: '/files', name: '文件与 COS', icon: <FileOutlined /> },
|
|
|
|
|
|
{ path: '/audit', name: '审计日志', icon: <SafetyOutlined />, requiredRole: 'ADMIN' },
|
|
|
|
|
|
{ path: '/billing', name: 'API 用量', icon: <DollarOutlined />, requiredRole: 'SUPER_ADMIN' },
|
|
|
|
|
|
{ path: '/git', name: '代码仓库', icon: <CodeOutlined /> },
|
|
|
|
|
|
{ path: '/servers', name: '服务器运维', icon: <CloudServerOutlined />, requiredRole: 'SUPER_ADMIN' },
|
|
|
|
|
|
{ path: '/settings', name: '系统配置', icon: <SettingOutlined />, requiredRole: 'ADMIN' },
|
|
|
|
|
|
];import type React from 'react'
|
2026-05-22 16:39:42 +08:00
|
|
|
|
import { SettingOutlined, CloudServerOutlined, CodeOutlined, SafetyOutlined, FileOutlined, ImportOutlined, BookOutlined, DollarOutlined, UserOutlined, RobotOutlined, DashboardOutlined, DollarOutlined, CodeOutlined, CloudServerOutlined, RobotOutlined, DashboardOutlined,
|
2026-05-22 16:39:01 +08:00
|
|
|
|
UserOutlined,
|
|
|
|
|
|
BookOutlined,
|
|
|
|
|
|
ImportOutlined,
|
|
|
|
|
|
SettingOutlined,
|
|
|
|
|
|
FileOutlined,
|
|
|
|
|
|
SafetyOutlined,
|
2026-05-22 16:39:42 +08:00
|
|
|
|
} , DashboardOutlined } , RobotOutlined } , UserOutlined } , DollarOutlined } , BookOutlined } , ImportOutlined } , FileOutlined } , SafetyOutlined } , CodeOutlined } , CloudServerOutlined } , SettingOutlined } from '@ant-design/icons'
|
2026-05-22 16:39:01 +08:00
|
|
|
|
import type { AdminRole } from '@/types/admin'
|
2026-05-22 16:39:42 +08:00
|
|
|
|
import { SettingOutlined, CloudServerOutlined, CodeOutlined, SafetyOutlined, FileOutlined, ImportOutlined, BookOutlined, DollarOutlined, UserOutlined, RobotOutlined, DashboardOutlined, hasRole } from '@/constants/roles'
|
2026-05-21 17:19:58 +08:00
|
|
|
|
|
|
|
|
|
|
export interface AdminMenuItem {
|
|
|
|
|
|
path: string
|
|
|
|
|
|
name: string
|
|
|
|
|
|
icon?: React.ReactNode
|
|
|
|
|
|
requiredRole?: AdminRole
|
|
|
|
|
|
children?: AdminMenuItem[]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const adminMenuItems: AdminMenuItem[] = [
|
|
|
|
|
|
{ path: '/', name: '总览', icon: <DashboardOutlined /> },
|
2026-05-22 00:38:56 +08:00
|
|
|
|
{ path: '/assistant', name: '任务助理', icon: <RobotOutlined /> },
|
2026-05-21 17:19:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
path: '/users',
|
|
|
|
|
|
name: '用户管理',
|
|
|
|
|
|
icon: <UserOutlined />,
|
|
|
|
|
|
requiredRole: 'ADMIN',
|
|
|
|
|
|
children: [
|
|
|
|
|
|
{ path: '/users/admins', name: '管理员', requiredRole: 'SUPER_ADMIN' },
|
|
|
|
|
|
{ path: '/users/members', name: '普通用户' },
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
{ path: '/membership', name: '会员与额度', icon: <DollarOutlined />, requiredRole: 'ADMIN' },
|
|
|
|
|
|
{
|
|
|
|
|
|
path: '/knowledge',
|
|
|
|
|
|
name: '知识库管理',
|
|
|
|
|
|
icon: <BookOutlined />,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
{ path: '/knowledge/bases', name: '知识库列表' },
|
|
|
|
|
|
{ path: '/knowledge/sources', name: '知识源列表' },
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
{ path: '/imports', name: '文档导入', icon: <ImportOutlined /> },
|
|
|
|
|
|
{ path: '/files', name: '文件与 COS', icon: <FileOutlined /> },
|
|
|
|
|
|
{ path: '/settings', name: '系统配置', icon: <SettingOutlined />, requiredRole: 'ADMIN' },
|
2026-05-22 15:31:00 +08:00
|
|
|
|
{ path: '/billing', name: 'API 用量', icon: <DollarOutlined />, requiredRole: 'SUPER_ADMIN' },
|
2026-05-22 14:35:26 +08:00
|
|
|
|
{ path: '/git', name: '代码仓库', icon: <CodeOutlined /> },
|
2026-05-22 13:30:37 +08:00
|
|
|
|
{ path: '/servers', name: '服务器运维', icon: <CloudServerOutlined />, requiredRole: 'SUPER_ADMIN' },
|
2026-05-21 17:19:58 +08:00
|
|
|
|
{ path: '/audit', name: '审计日志', icon: <SafetyOutlined />, requiredRole: 'ADMIN' },
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
export function filterMenuByRole(items: AdminMenuItem[], role?: AdminRole): AdminMenuItem[] {
|
|
|
|
|
|
if (!role) return []
|
|
|
|
|
|
return items
|
|
|
|
|
|
.filter((item) => !item.requiredRole || hasRole(role, item.requiredRole))
|
|
|
|
|
|
.map((item) => ({
|
|
|
|
|
|
...item,
|
|
|
|
|
|
children: item.children ? filterMenuByRole(item.children, role) : undefined,
|
|
|
|
|
|
}))
|
|
|
|
|
|
.filter((item) => {
|
|
|
|
|
|
if (item.children && item.children.length === 0) return false
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|