✨ 新增管理员代登录功能
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<settings ref="settingRef" />
|
||||
</div>
|
||||
<!-- 全局消息通知:登录后未读弹屏 + 头像菜单“我的通知”入口 -->
|
||||
<notify-popup />
|
||||
<notify-popup v-if="!userStore.impersonating" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -22,8 +22,10 @@ import { AppMain, Navbar, Settings, TagsView } from './components'
|
||||
import NotifyPopup from '@/components/NotifyPopup/index.vue'
|
||||
import useAppStore from '@/store/modules/app'
|
||||
import useSettingsStore from '@/store/modules/settings'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
|
||||
const settingsStore = useSettingsStore()
|
||||
const userStore = useUserStore()
|
||||
const theme = computed(() => settingsStore.theme)
|
||||
const sidebar = computed(() => useAppStore().sidebar)
|
||||
const device = computed(() => useAppStore().device)
|
||||
@@ -116,4 +118,4 @@ function setLayout() {
|
||||
.mobile .fixed-header {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user