refactor: move admin entry into account menu
This commit is contained in:
+23
-9
@@ -844,10 +844,14 @@ function AdminDashboard() {
|
|||||||
|
|
||||||
function AccountMenu({
|
function AccountMenu({
|
||||||
user,
|
user,
|
||||||
|
adminActive,
|
||||||
|
onOpenAdmin,
|
||||||
onUserUpdate,
|
onUserUpdate,
|
||||||
onLogout,
|
onLogout,
|
||||||
}: {
|
}: {
|
||||||
user: User;
|
user: User;
|
||||||
|
adminActive: boolean;
|
||||||
|
onOpenAdmin: () => void;
|
||||||
onUserUpdate: (user: User) => void;
|
onUserUpdate: (user: User) => void;
|
||||||
onLogout: () => void;
|
onLogout: () => void;
|
||||||
}) {
|
}) {
|
||||||
@@ -867,9 +871,10 @@ function AccountMenu({
|
|||||||
return (
|
return (
|
||||||
<div className="account">
|
<div className="account">
|
||||||
<button
|
<button
|
||||||
className="logout"
|
className={`logout ${adminActive ? "admin-active" : ""}`}
|
||||||
onClick={() => setOpen((value) => !value)}
|
onClick={() => setOpen((value) => !value)}
|
||||||
aria-label="账户"
|
aria-label="账户"
|
||||||
|
aria-expanded={open}
|
||||||
>
|
>
|
||||||
{user.label.slice(0, 1)}
|
{user.label.slice(0, 1)}
|
||||||
</button>
|
</button>
|
||||||
@@ -879,6 +884,21 @@ function AccountMenu({
|
|||||||
<strong>{user.label}</strong>
|
<strong>{user.label}</strong>
|
||||||
<span>{user.role === "admin" ? "管理员" : "独立空间"}</span>
|
<span>{user.role === "admin" ? "管理员" : "独立空间"}</span>
|
||||||
</header>
|
</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" && (
|
{user.role !== "admin" && (
|
||||||
<label>
|
<label>
|
||||||
<span>
|
<span>
|
||||||
@@ -958,17 +978,11 @@ function Notebook({
|
|||||||
想法
|
想法
|
||||||
{pending > 0 && <i aria-hidden="true" />}
|
{pending > 0 && <i aria-hidden="true" />}
|
||||||
</button>
|
</button>
|
||||||
{user.role === "admin" && (
|
|
||||||
<button
|
|
||||||
className={view === "admin" ? "active" : ""}
|
|
||||||
onClick={() => switchView("admin")}
|
|
||||||
>
|
|
||||||
后台
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</nav>
|
</nav>
|
||||||
<AccountMenu
|
<AccountMenu
|
||||||
user={user}
|
user={user}
|
||||||
|
adminActive={view === "admin"}
|
||||||
|
onOpenAdmin={() => switchView("admin")}
|
||||||
onUserUpdate={onUserUpdate}
|
onUserUpdate={onUserUpdate}
|
||||||
onLogout={onLogout}
|
onLogout={onLogout}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -252,6 +252,11 @@ summary:focus-visible {
|
|||||||
letter-spacing: 0;
|
letter-spacing: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.logout.admin-active {
|
||||||
|
border-color: rgba(153, 104, 72, 0.34);
|
||||||
|
background: rgba(153, 104, 72, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
.account {
|
.account {
|
||||||
position: relative;
|
position: relative;
|
||||||
justify-self: end;
|
justify-self: end;
|
||||||
@@ -288,6 +293,52 @@ summary:focus-visible {
|
|||||||
font-size: 10px;
|
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 {
|
.account-menu > label {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
Reference in New Issue
Block a user