import { Suspense, useEffect, useState } from 'react' import { Outlet, useNavigate, useLocation } from 'react-router-dom' import { Layout, Menu, Button, Typography } from 'antd' import { DashboardOutlined, VideoCameraOutlined, PlusOutlined, MonitorOutlined, CloudServerOutlined, SettingOutlined, LogoutOutlined, } from '@ant-design/icons' import { clearToken } from '../api/client' import { useBrand } from '../brand/BrandContext' const { Sider, Content, Header } = Layout const { Text } = Typography const menuItems = [ { key: '/admin', icon: , label: '概览' }, { key: '/admin/board', icon: , label: '直播看板' }, { key: '/admin/streams', icon: , label: '节目列表' }, { key: '/admin/streams/new', icon: , label: '创建节目' }, { key: '/admin/nodes', icon: , label: '边缘节点' }, { key: '/admin/settings', icon: , label: '系统设置' }, ] const adminPageImports = [ () => import('./pages/Dashboard'), () => import('./pages/LiveBoard'), () => import('./pages/StreamList'), () => import('./pages/StreamForm'), () => import('./pages/ReplayEditor'), () => import('./pages/NodeManager'), () => import('./pages/Settings'), ] export default function AdminLayout() { const { brand } = useBrand() const [collapsed, setCollapsed] = useState(false) const navigate = useNavigate() const location = useLocation() const selectedKey = menuItems.find( item => location.pathname === item.key || (location.pathname === '/' && item.key === '/admin') )?.key || '/admin' const handleLogout = () => { clearToken(); navigate('/admin/login') } return ( {collapsed ? brand.brand_name.slice(0, 2) : brand.brand_name} navigate(key)} style={{ border: 'none', marginTop: 8 }} /> {brand.brand_tagline} } onClick={handleLogout}>退出登录 ) }