import {
Activity,
Database,
HardDrive,
LayoutDashboard,
ListChecks,
LogOut,
MessagesSquare,
Moon,
ScrollText,
Settings,
ShieldCheck,
Sun,
Users,
} from 'lucide-react'
import { useEffect, useState } from 'react'
import { Menu, X } from 'lucide-react'
import { NavLink, Navigate, Outlet, useLocation, useNavigate } from 'react-router-dom'
import { Cpu } from 'lucide-react'
import { useSession } from '@/app/session'
import { useTheme } from '@/app/theme'
import { Badge, Button, Loading } from '@/shared/ui'
const NAV_ITEMS = [
{ to: '/', label: '系统状态', icon: LayoutDashboard, end: true },
{ to: '/users', label: '用户', icon: Users },
{ to: '/spaces', label: 'Space', icon: Database },
{ to: '/chat', label: '聊天记录', icon: MessagesSquare },
{ to: '/storage', label: '存储', icon: HardDrive },
{ to: '/queues', label: '队列', icon: Activity },
{ to: '/runners', label: 'Runner', icon: Cpu },
{ to: '/tasks', label: '任务', icon: ListChecks },
{ to: '/logs', label: '日志', icon: ScrollText },
{ to: '/admins', label: '管理员', icon: ShieldCheck },
{ to: '/system', label: '系统配置', icon: Settings },
]
function roleLabel(role: string): string {
switch (role) {
case 'super_admin':
return '超级管理员'
case 'operator':
return '运维'
default:
return '只读'
}
}
export function AdminShell() {
const { me, loading, logout } = useSession()
const { dark, toggle } = useTheme()
const navigate = useNavigate()
const location = useLocation()
const [menuOpen, setMenuOpen] = useState(false)
// The drawer belongs to the current page only: any navigation closes it.
useEffect(() => { setMenuOpen(false) }, [location.pathname])
if (loading) {
return