import { useLocation, useNavigate } from 'react-router-dom' import { Layout, Menu, Dropdown, Avatar } from 'antd' import { AppstoreOutlined, MessageOutlined, HistoryOutlined, TeamOutlined, FileTextOutlined, BarChartOutlined, SettingOutlined, LogoutOutlined, UserOutlined, } from '@ant-design/icons' import { useAuth } from '@/stores/auth' const { Sider } = Layout const menuItems = [ { key: '/agent/dashboard', icon: , label: '工作台' }, { key: '/agent/chat-history', icon: , label: '对话记录' }, { key: '/agent/customers', icon: , label: '客户管理' }, { key: '/agent/knowledge', icon: , label: '知识库' }, { key: '/agent/statistics', icon: , label: '数据统计' }, { key: '/agent/settings', icon: , label: '系统设置' }, ] const AgentSidebar = () => { const location = useLocation() const navigate = useNavigate() const { user, logout } = useAuth() const visibleMenuItems = menuItems.filter(item => { if (item.key === '/agent/statistics') return user?.role === 'admin' || user?.role === 'supervisor' if (item.key === '/agent/settings') return user?.role === 'admin' return true }) const selectedKey = visibleMenuItems.find(item => location.pathname.startsWith(item.key))?.key || '/agent/dashboard' const handleLogout = () => { logout() navigate('/login', { replace: true }) } return ( 客服云 navigate(key)} className="border-e-0 mt-2 flex-1" /> , label: '退出登录', onClick: handleLogout }] }} trigger={['click']} > } className="!bg-blue-100 !text-blue-500" /> {user?.nickname || '客服'} 在线 ) } export default AgentSidebar