新增接单平台第一期闭环
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
SettingOutlined,
|
||||
ShopOutlined,
|
||||
TeamOutlined,
|
||||
TrophyOutlined,
|
||||
UnorderedListOutlined,
|
||||
UserOutlined,
|
||||
} from '@ant-design/icons'
|
||||
@@ -55,6 +56,7 @@ export default function AdminLayout() {
|
||||
{ key: '/admin/dashboard', icon: <DashboardOutlined />, label: '概览' },
|
||||
{ key: '/admin/orders', icon: <OrderedListOutlined />, label: '订单' },
|
||||
{ key: '/admin/tasks', icon: <UnorderedListOutlined />, label: '任务' },
|
||||
{ key: '/admin/worker-platform', icon: <TrophyOutlined />, label: '接单平台' },
|
||||
{ key: '/admin/kuaishou-industry', icon: <SafetyCertificateOutlined />, label: '电子凭证' },
|
||||
{ key: '/admin/cloudtentacles-records', icon: <FileSearchOutlined />, label: '发货记录' },
|
||||
]
|
||||
@@ -204,6 +206,7 @@ export default function AdminLayout() {
|
||||
function resolveSelectedKey(pathname: string) {
|
||||
if (pathname.startsWith('/admin/orders')) return '/admin/orders'
|
||||
if (pathname.startsWith('/admin/tasks')) return '/admin/tasks'
|
||||
if (pathname.startsWith('/admin/worker-platform')) return '/admin/worker-platform'
|
||||
if (pathname.startsWith('/admin/kuaishou-industry')) return '/admin/kuaishou-industry'
|
||||
if (pathname === '/admin/platform-shops') return '/admin/platform-shops'
|
||||
return pathname
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
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: <ShoppingOutlined />, label: '抢单大厅' },
|
||||
{ key: '/worker/orders', icon: <ContainerOutlined />, label: '我的订单' },
|
||||
{ key: '/worker/profile', icon: <UserOutlined />, 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 (
|
||||
<Layout className="admin-shell worker-shell">
|
||||
<Layout.Sider width={220} className="admin-sider" trigger={null}>
|
||||
<div className="admin-sider-inner">
|
||||
<div className="admin-brand">
|
||||
<div className="admin-brand-copy">
|
||||
<strong>趣游通</strong>
|
||||
<span>接单平台</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="admin-sidebar-profile">
|
||||
<Typography.Text strong>{username}</Typography.Text>
|
||||
<Typography.Text type="secondary">{formatWorkerStatus(status)}</Typography.Text>
|
||||
</div>
|
||||
<Menu
|
||||
mode="inline"
|
||||
inlineIndent={16}
|
||||
selectedKeys={[resolveSelectedKey(location.pathname)]}
|
||||
items={menuItems}
|
||||
className="admin-menu"
|
||||
onClick={({ key }) => navigate(String(key))}
|
||||
/>
|
||||
<div className="admin-sider-footer">
|
||||
<Button block icon={<LogoutOutlined />} onClick={submitLogout}>
|
||||
退出登录
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Layout.Sider>
|
||||
<Layout className="admin-main-shell">
|
||||
<Layout.Header className="admin-topbar">
|
||||
<Space className="admin-user" size={12}>
|
||||
<Typography.Text type="secondary">{formatWorkerStatus(status)}</Typography.Text>
|
||||
</Space>
|
||||
</Layout.Header>
|
||||
<Layout.Content className="admin-content">
|
||||
<Outlet />
|
||||
</Layout.Content>
|
||||
</Layout>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
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 '未登录'
|
||||
}
|
||||
Reference in New Issue
Block a user