import { AlertOutlined, ApartmentOutlined, AuditOutlined, BankOutlined, BookOutlined, ContactsOutlined, CreditCardOutlined, DashboardOutlined, FileTextOutlined, LogoutOutlined, MenuFoldOutlined, MenuUnfoldOutlined, MessageOutlined, PieChartOutlined, ShopOutlined, UserSwitchOutlined, } from '@ant-design/icons'; import { Avatar, Button, Dropdown, Flex, Layout, Menu, Space, Spin, Typography } from 'antd'; import { useState } from 'react'; import { Navigate, Outlet, useLocation, useNavigate } from 'react-router'; import { useAuth } from '../auth/AuthProvider'; const { Header, Sider, Content } = Layout; const items = [ { key: '/', icon: , label: '经营概览' }, { type: 'group' as const, label: '业务运营', children: [ { key: '/tenants', icon: , label: '租户管理' }, { key: '/subscriptions', icon: , label: '套餐与订阅' }, { key: '/billing', icon: , label: '订单与发票' }, { key: '/usage', icon: , label: '用量计费' }, { key: '/dunning', icon: , label: '收款与催缴' }, ] }, { type: 'group' as const, label: '内容资产', children: [ { key: '/question-banks', icon: , label: '公共题库' }, ] }, { type: 'group' as const, label: '平台服务', children: [ { key: '/crm', icon: , label: 'CRM 服务' }, { key: '/sms', icon: , label: '短信服务' }, { key: '/payments', icon: , label: '支付服务' }, ] }, { type: 'group' as const, label: '安全与系统', children: [ { key: '/staff', icon: , label: '员工与角色' }, { key: '/audit', icon: , label: '审计日志' }, { key: '/alerts', icon: , label: '审计告警' }, ] }, ]; const pageTitles: Record = { '/': '经营概览', '/tenants': '租户管理', '/subscriptions': '套餐与订阅', '/billing': '订单与发票', '/usage': '用量计费', '/dunning': '收款与催缴', '/question-banks': '公共题库', '/crm': 'CRM 服务', '/sms': '短信服务', '/payments': '支付服务', '/staff': '员工与角色', '/audit': '审计日志', '/alerts': '审计告警', }; export function AppLayout() { const auth = useAuth(); const location = useLocation(); const navigate = useNavigate(); const [collapsed, setCollapsed] = useState(false); if (auth.loading) return
; if (!auth.user) return ; const displayName = auth.user.name || auth.user.phone || auth.user.email || '平台管理员'; return (
Logo
{!collapsed &&
恭学题库平台管理中心
}
navigate(key)} />
{pageTitles[location.pathname] || '平台管理'} , label: '退出登录', onClick: () => void auth.logout() }] }} trigger={['click']} > {String(displayName).slice(0, 1)} {displayName} 平台管理
); }