refactor: move admin entry into account menu
This commit is contained in:
+23
-9
@@ -844,10 +844,14 @@ function AdminDashboard() {
|
||||
|
||||
function AccountMenu({
|
||||
user,
|
||||
adminActive,
|
||||
onOpenAdmin,
|
||||
onUserUpdate,
|
||||
onLogout,
|
||||
}: {
|
||||
user: User;
|
||||
adminActive: boolean;
|
||||
onOpenAdmin: () => void;
|
||||
onUserUpdate: (user: User) => void;
|
||||
onLogout: () => void;
|
||||
}) {
|
||||
@@ -867,9 +871,10 @@ function AccountMenu({
|
||||
return (
|
||||
<div className="account">
|
||||
<button
|
||||
className="logout"
|
||||
className={`logout ${adminActive ? "admin-active" : ""}`}
|
||||
onClick={() => setOpen((value) => !value)}
|
||||
aria-label="账户"
|
||||
aria-expanded={open}
|
||||
>
|
||||
{user.label.slice(0, 1)}
|
||||
</button>
|
||||
@@ -879,6 +884,21 @@ function AccountMenu({
|
||||
<strong>{user.label}</strong>
|
||||
<span>{user.role === "admin" ? "管理员" : "独立空间"}</span>
|
||||
</header>
|
||||
{user.role === "admin" && (
|
||||
<button
|
||||
className={`account-admin ${adminActive ? "active" : ""}`}
|
||||
onClick={() => {
|
||||
onOpenAdmin();
|
||||
setOpen(false);
|
||||
}}
|
||||
>
|
||||
<span>
|
||||
<strong>运行后台</strong>
|
||||
<small>Agent 与系统活动</small>
|
||||
</span>
|
||||
<i aria-hidden="true">{adminActive ? "当前" : "›"}</i>
|
||||
</button>
|
||||
)}
|
||||
{user.role !== "admin" && (
|
||||
<label>
|
||||
<span>
|
||||
@@ -958,17 +978,11 @@ function Notebook({
|
||||
想法
|
||||
{pending > 0 && <i aria-hidden="true" />}
|
||||
</button>
|
||||
{user.role === "admin" && (
|
||||
<button
|
||||
className={view === "admin" ? "active" : ""}
|
||||
onClick={() => switchView("admin")}
|
||||
>
|
||||
后台
|
||||
</button>
|
||||
)}
|
||||
</nav>
|
||||
<AccountMenu
|
||||
user={user}
|
||||
adminActive={view === "admin"}
|
||||
onOpenAdmin={() => switchView("admin")}
|
||||
onUserUpdate={onUserUpdate}
|
||||
onLogout={onLogout}
|
||||
/>
|
||||
|
||||
@@ -252,6 +252,11 @@ summary:focus-visible {
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.logout.admin-active {
|
||||
border-color: rgba(153, 104, 72, 0.34);
|
||||
background: rgba(153, 104, 72, 0.06);
|
||||
}
|
||||
|
||||
.account {
|
||||
position: relative;
|
||||
justify-self: end;
|
||||
@@ -288,6 +293,52 @@ summary:focus-visible {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.account-admin {
|
||||
width: 100%;
|
||||
padding: 15px 18px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 18px;
|
||||
border: 0;
|
||||
border-bottom: 1px solid var(--line);
|
||||
background: transparent;
|
||||
color: var(--ink);
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.account-admin:hover,
|
||||
.account-admin.active {
|
||||
background: rgba(153, 104, 72, 0.055);
|
||||
}
|
||||
|
||||
.account-admin > span {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.account-admin strong {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.account-admin small {
|
||||
color: var(--muted);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.account-admin > i {
|
||||
color: var(--warm);
|
||||
font-size: 15px;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.account-admin.active > i {
|
||||
font-size: 9px;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
|
||||
.account-menu > label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in New Issue
Block a user