AdminShell.tsx
4.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { useState } from 'react';
import { Outlet, useLocation, useNavigate } from 'react-router-dom';
import { Avatar, Button, Modal, Navigation } from '../../packages/ui/src';
import { logout } from '../auth/localAuth';
export function AdminShell() {
const location = useLocation();
const navigate = useNavigate();
const [logoutConfirmOpen, setLogoutConfirmOpen] = useState(false);
const activeNavigationKey = location.pathname.startsWith('/skills')
? 'skill-list'
: location.pathname.startsWith('/agent-tags')
? 'agent-tag-list'
: location.pathname.startsWith('/official-site/methodology')
? 'official-site-methodology'
: location.pathname.startsWith('/official-site/job-tabs')
? 'official-site-job-tabs'
: location.pathname.startsWith('/agents')
? 'agent-list'
: location.pathname.startsWith('/channel-codes')
? 'channel-code-list'
: undefined;
const breadcrumb = location.pathname.startsWith('/skills')
? 'Agent管理 / Skill目录'
: location.pathname.startsWith('/agent-tags')
? 'Agent管理 / 岗位标签管理'
: location.pathname.startsWith('/official-site/methodology')
? '官网配置 / 方法论展示配置'
: location.pathname.startsWith('/official-site/job-tabs')
? '官网配置 / 岗位展示配置'
: location.pathname.startsWith('/channel-codes')
? 'Agent群管理 / 渠道活码'
: 'Agent管理 / Agent列表';
const navigationItems = [
{
key: 'agent-management',
label: 'Agent管理',
children: [
{ key: 'agent-list', label: 'Agent列表' },
{ key: 'agent-tag-list', label: '岗位标签管理' },
{ key: 'skill-list', label: 'Skill目录' },
],
},
{
key: 'agent-group-management',
label: 'Agent群管理',
children: [{ key: 'channel-code-list', label: '渠道活码' }],
},
{
key: 'official-site-management',
label: '官网配置',
children: [
{ key: 'official-site-job-tabs', label: '岗位展示配置' },
{ key: 'official-site-methodology', label: '方法论展示配置' },
],
},
];
return (
<div className="grid min-h-screen grid-cols-[180px_1fr] bg-[var(--gl-color-bg-page)] text-[var(--gl-color-text-primary)] max-[760px]:grid-cols-1">
<aside className="flex flex-col gap-4 border-r border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] p-4">
<div className="grid gap-1">
<p className="m-0 text-xs leading-[var(--gl-line-height-sm)] text-[var(--gl-color-text-secondary)]">Admin Console</p>
<h1 className="m-0 whitespace-nowrap text-base font-semibold leading-[var(--gl-line-height-lg)]">岗位Agent管理后台</h1>
</div>
<Navigation
activeKey={activeNavigationKey}
ariaLabel="管理后台导航"
items={navigationItems}
onChange={(key) => {
if (key === 'agent-list') navigate('/agents');
if (key === 'agent-tag-list') navigate('/agent-tags');
if (key === 'skill-list') navigate('/skills');
if (key === 'channel-code-list') navigate('/channel-codes');
if (key === 'official-site-methodology') navigate('/official-site/methodology');
if (key === 'official-site-job-tabs') navigate('/official-site/job-tabs');
}}
/>
</aside>
<div className="grid min-w-0 grid-rows-[auto_1fr]">
<header className="flex min-h-14 items-center justify-between border-b border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] px-8 text-sm text-[var(--gl-color-text-secondary)] max-[760px]:px-4">
<span>{breadcrumb}</span>
<div className="flex items-center gap-3">
<Avatar name="管理员" />
<Button
variant="outline"
onClick={() => setLogoutConfirmOpen(true)}
>
退出登录
</Button>
</div>
</header>
<main className="p-8 max-[760px]:p-4">
<Outlet />
</main>
</div>
<Modal
open={logoutConfirmOpen}
title="确认退出登录?"
onCancel={() => setLogoutConfirmOpen(false)}
onOk={() => {
setLogoutConfirmOpen(false);
logout();
navigate('/login', { replace: true, state: { from: location } });
}}
>
<p className="m-0 text-sm leading-[var(--gl-line-height-md)] text-[var(--gl-color-text-secondary)]">
退出后将返回登录页,当前后台操作上下文不会保留。
</p>
</Modal>
</div>
);
}