✨ 新增管理员代登录功能

This commit is contained in:
caojia
2026-11-04 15:20:05 +08:00
parent 93da04fe5e
commit 5cccbf510f
17 changed files with 540 additions and 18 deletions
+19 -2
View File
@@ -9,6 +9,10 @@
</template>
<div class="right-menu">
<div v-if="userStore.impersonating" class="impersonation-banner">
<span>当前以 {{ userStore.nickName }} 身份操作</span>
<el-button size="small" type="warning" @click="exitActingUser">返回管理员</el-button>
</div>
<template v-if="appStore.device !== 'mobile'">
<header-search id="header-search" class="right-menu-item" />
@@ -50,7 +54,7 @@
<el-dropdown-item command="setLayout" v-if="settingsStore.showSettings">
<span>布局设置</span>
</el-dropdown-item>
<el-dropdown-item command="lockScreen">
<el-dropdown-item v-if="!userStore.impersonating" command="lockScreen">
<span>锁定屏幕</span>
</el-dropdown-item>
<el-dropdown-item divided command="logout">
@@ -111,7 +115,7 @@ function handleCommand(command) {
}
function logout() {
ElMessageBox.confirm('确定注销并退出系统吗?', '提示', {
ElMessageBox.confirm(userStore.impersonating ? '结束代登录并返回管理员账号吗?' : '确定注销并退出系统吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
@@ -122,6 +126,10 @@ function logout() {
}).catch(() => { })
}
function exitActingUser() {
userStore.logOut().then(() => location.replace('/index'))
}
const emits = defineEmits(['setLayout'])
function setLayout() {
emits('setLayout')
@@ -233,6 +241,15 @@ async function toggleTheme(event) {
align-items: center;
margin-left: auto;
.impersonation-banner {
display: flex;
align-items: center;
gap: 8px;
color: #b46a00;
font-size: 13px;
white-space: nowrap;
}
&:focus {
outline: none;
}