显示当前登录账号和权限

This commit is contained in:
xuans 2026-10-06 00:17:01 +08:00
parent 53047e9066
commit 46f684ac38
3 changed files with 39 additions and 0 deletions

View File

@ -461,6 +461,7 @@ const { activeSection, activeLabel, sections, selectSection } = useDashboardNavi
<DashboardNavigation
:active-section="activeSection"
:sections="sections"
:current-user="currentUser"
@select="selectSection"
@settings="openSettings"
/>

View File

@ -110,6 +110,30 @@
padding-top: 22px;
}
.navigation-account {
display: grid;
gap: 5px;
margin: 0 8px 10px;
padding: 11px 12px;
border: 1px solid #e2e8f2;
border-radius: 12px;
background: #f8faff;
color: #263752;
overflow-wrap: anywhere;
}
.navigation-account-label,
.navigation-account-role {
color: #7a879d;
font-size: 11px;
line-height: 1.4;
}
.navigation-account strong {
font-size: 13px;
line-height: 1.4;
}
.navigation-error {
margin: 0 8px 8px;
color: #b42318;

View File

@ -3,9 +3,16 @@ import { useAccessDenied } from "../AccessDenied/AccessDenied.js";
const { loggingOut, error, logout } = useAccessDenied();
const roleLabels = {
super_admin: "超级管理员",
admin: "管理员",
user: "普通用户",
};
defineProps({
activeSection: { type: String, required: true },
sections: { type: Array, required: true },
currentUser: { type: Object, default: null },
});
defineEmits(["select", "settings"]);
@ -73,6 +80,13 @@ defineEmits(["select", "settings"]);
<span>系统设置</span>
</button>
<div class="navigation-session">
<div v-if="currentUser" class="navigation-account" aria-label="当前登录账号">
<span class="navigation-account-label">当前登录账号</span>
<strong>{{ currentUser.account || "未命名账号" }}</strong>
<span class="navigation-account-role">
权限:{{ roleLabels[currentUser.role] || "未知权限" }}
</span>
</div>
<p v-if="error" class="navigation-error" role="alert">{{ error }}</p>
<button
class="navigation-item navigation-logout"