import { ContainerOutlined, LogoutOutlined, ShoppingOutlined, UserOutlined, } from '@ant-design/icons' import { App, Button, Layout, Menu, Space, Typography } from 'antd' import type { MenuProps } from 'antd' import { Outlet, useLocation, useNavigate } from 'react-router' import { logoutWorker } from '@/services/worker' import { clearWorkerSession, getWorkerStatus, getWorkerUsername } from '@/utils/worker-auth' const menuItems: MenuProps['items'] = [ { key: '/worker/hall', icon: , label: '抢单大厅' }, { key: '/worker/orders', icon: , label: '我的订单' }, { key: '/worker/profile', icon: , label: '个人中心' }, ] export default function WorkerLayout() { const navigate = useNavigate() const location = useLocation() const { message } = App.useApp() const username = getWorkerUsername() || '打手' const status = getWorkerStatus() async function submitLogout() { try { await logoutWorker() } catch { // 接单端退出为无状态操作,本地清理优先。 } finally { clearWorkerSession() message.success('已退出登录') navigate('/worker/login', { replace: true }) } } return ( 王大锤 接单平台 {username} {formatWorkerStatus(status)} navigate(String(key))} /> } onClick={submitLogout}> 退出登录 {formatWorkerStatus(status)} ) } function resolveSelectedKey(pathname: string) { if (pathname.startsWith('/worker/orders')) return '/worker/orders' if (pathname.startsWith('/worker/profile')) return '/worker/profile' return '/worker/hall' } function formatWorkerStatus(status: string) { if (status === 'active') return '已审核' if (status === 'pending_review') return '待审核' if (status === 'rejected') return '审核未通过' if (status === 'disabled') return '已停用' return '未登录' }