127 lines
4.0 KiB
TypeScript
127 lines
4.0 KiB
TypeScript
import type { LucideIcon } from 'lucide-react'
|
|
import { can } from '@/auth/store'
|
|
import {
|
|
BookOpenText,
|
|
Bot,
|
|
ClipboardList,
|
|
FileText,
|
|
FileJson,
|
|
Flag,
|
|
FolderTree,
|
|
Hash,
|
|
Inbox,
|
|
KeyRound,
|
|
Languages,
|
|
LayoutList,
|
|
ListChecks,
|
|
MessageSquareWarning,
|
|
Newspaper,
|
|
Palette,
|
|
Receipt,
|
|
ScrollText,
|
|
Send,
|
|
Shield,
|
|
Smartphone,
|
|
Sparkles,
|
|
UserCheck,
|
|
Users,
|
|
} from 'lucide-react'
|
|
|
|
export interface NavItem {
|
|
label: string
|
|
to: string
|
|
icon: LucideIcon
|
|
/** hide when the user lacks this permission (super-admin always passes) */
|
|
permission?: string
|
|
}
|
|
|
|
export interface NavGroup {
|
|
label: string
|
|
items: NavItem[]
|
|
}
|
|
|
|
export const NAV_GROUPS: NavGroup[] = [
|
|
{
|
|
label: '开发工具',
|
|
items: [
|
|
{
|
|
label: 'API 文档',
|
|
to: '/api-docs',
|
|
icon: FileJson,
|
|
permission: 'auth:api-docs:read',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: '分类管理',
|
|
items: [
|
|
{ label: '分类树', to: '/categories', icon: FolderTree, permission: 'admin:category:read' },
|
|
{ label: '待审核分类', to: '/categories/pending', icon: ListChecks, permission: 'admin:category:approve' },
|
|
],
|
|
},
|
|
{
|
|
label: '内容工作室',
|
|
items: [
|
|
{ label: '机器人作者', to: '/studio/robot-authors', icon: Bot, permission: 'admin:studio:read' },
|
|
{ label: '文章系列', to: '/studio/series', icon: LayoutList, permission: 'admin:studio:read' },
|
|
{ label: '文章', to: '/studio/articles', icon: Newspaper, permission: 'admin:studio:read' },
|
|
{ label: '子话题', to: '/studio/subtopics', icon: Sparkles, permission: 'admin:studio:read' },
|
|
{ label: '分类简报', to: '/studio/category-briefs', icon: ScrollText, permission: 'admin:studio:read' },
|
|
{ label: '风格预设', to: '/studio/style-presets', icon: Palette, permission: 'admin:studio:read' },
|
|
{
|
|
label: 'Agent 接入',
|
|
to: '/studio/agent-tokens',
|
|
icon: KeyRound,
|
|
permission: 'admin:studio:agent-token:issue',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: '专长交易',
|
|
items: [
|
|
{ label: '需求监控', to: '/exc/demands', icon: ClipboardList, permission: 'admin:exc:read' },
|
|
{ label: '派单监控', to: '/exc/dispatches', icon: Send, permission: 'admin:exc:read' },
|
|
{ label: '订单监控', to: '/exc/orders', icon: Receipt, permission: 'admin:exc:read' },
|
|
{ label: '服务商监控', to: '/exc/providers', icon: UserCheck, permission: 'admin:exc:read' },
|
|
],
|
|
},
|
|
{
|
|
label: 'Dimzou 内容',
|
|
items: [
|
|
{ label: '文档监控', to: '/dimzou/documents', icon: FileText, permission: 'admin:dimzou:read' },
|
|
{ label: '发布监控', to: '/dimzou/publications', icon: BookOpenText, permission: 'admin:dimzou:read' },
|
|
{ label: 'Dimzou 翻译', to: '/dimzou-translations', icon: Languages, permission: 'admin:dimzou:read' },
|
|
],
|
|
},
|
|
{
|
|
label: '内容审核',
|
|
items: [
|
|
{ label: '被举报评论', to: '/comment-reports', icon: MessageSquareWarning, permission: 'admin:comment:read' },
|
|
{ label: '被举报事件', to: '/event-reports', icon: Flag, permission: 'admin:filex:read' },
|
|
],
|
|
},
|
|
{
|
|
label: '用户与系统',
|
|
items: [
|
|
{ label: '用户列表', to: '/users', icon: Users, permission: 'auth:role:assign' },
|
|
{ label: '角色管理', to: '/roles', icon: Shield, permission: 'auth:role:read' },
|
|
{ label: '用户角色', to: '/admin-users', icon: Users, permission: 'auth:role:assign' },
|
|
{ label: 'SID 管理', to: '/sid', icon: Hash, permission: 'admin:sid:manage' },
|
|
{ label: '语言设置', to: '/locales', icon: Languages, permission: 'admin:locale:read' },
|
|
{ label: '推送设备', to: '/devices', icon: Smartphone, permission: 'admin:notification:read' },
|
|
{ label: '机器人会话', to: '/robots', icon: Inbox, permission: 'auth:robot-token:issue' },
|
|
],
|
|
},
|
|
]
|
|
|
|
export function getFirstAccessibleRoute(): string | null {
|
|
for (const group of NAV_GROUPS) {
|
|
for (const item of group.items) {
|
|
if (!item.permission || can(item.permission)) {
|
|
return item.to
|
|
}
|
|
}
|
|
}
|
|
return null
|
|
}
|