feat: add unique super administrator and role management

This commit is contained in:
wlx committed 2026-09-17 19:03:51 +08:00
1 parent 9e731e47b9
commit 386d15cde2
16 files changed
+455 -24

No files matched your search

+4 -4
View File
@@ -54,7 +54,7 @@ function navigate(view: string) {
}
function switchPortal() {
if (authUser.value?.role !== 'admin') {
if (!['admin', 'super_admin'].includes(authUser.value?.role || '')) {
notify('当前账号没有管理端权限')
return
}
@@ -154,10 +154,10 @@ function openAccountSettings() {
</div>
<div class="topbar-actions">
<button class="global-search desktop-only" @click="notify('全局搜索将在接入真实数据后开放')"><Search :size="16" /><span>搜索模型、用户或任务</span><kbd>⌘ K</kbd></button>
<button v-if="authUser?.role === 'admin'" class="portal-switch" @click="switchPortal"><ArrowLeftRight :size="16" /><span>{{ portal === 'admin' ? '返回用户端' : '进入管理端' }}</span></button>
<button v-if="['admin', 'super_admin'].includes(authUser?.role || '')" class="portal-switch" @click="switchPortal"><ArrowLeftRight :size="16" /><span>{{ portal === 'admin' ? '返回用户端' : '进入管理端' }}</span></button>
<button class="icon-button desktop-only" aria-label="通知" @click="notify('当前没有新的通知')"><Bell :size="18" /></button>
<div class="account-menu-wrap">
<button class="user-menu" :class="{ active: accountMenuOpen }" @click="accountMenuOpen = !accountMenuOpen"><span>{{ userName.slice(0, 1) }}</span><div><strong>{{ userName }}</strong><small>{{ authUser?.role === 'admin' ? '平台管理员' : '普通用户' }}</small></div></button>
<button class="user-menu" :class="{ active: accountMenuOpen }" @click="accountMenuOpen = !accountMenuOpen"><span>{{ userName.slice(0, 1) }}</span><div><strong>{{ userName }}</strong><small>{{ authUser?.role === 'super_admin' ? '超级管理员' : authUser?.role === 'admin' ? '平台管理员' : '普通用户' }}</small></div></button>
<Transition name="menu-pop"><div v-if="accountMenuOpen" class="account-popover"><header><span>{{ userName.slice(0, 1) }}</span><div><strong>{{ userName }}</strong><small>{{ authUser?.account }}</small></div></header><button @click="openAccountSettings"><Settings :size="16" />账号设置</button><button class="logout-button" @click="logout"><LogOut :size="16" />退出登录</button></div></Transition>
</div>
</div>
@@ -165,7 +165,7 @@ function openAccountSettings() {
<main class="content">
<UserConsole v-if="portal === 'user'" :view="activeView" :display-name="userName" @navigate="navigate" @notify="notify" />
<AdminConsole v-else :view="activeView" @navigate="navigate" @notify="notify" />
<AdminConsole v-else :view="activeView" :current-user="authUser" @navigate="navigate" @notify="notify" />
</main>
</div>