新增账号,超管体系
This commit is contained in:
@@ -92,16 +92,41 @@
|
||||
<el-breadcrumb-item v-if="breadcrumbSection">{{ breadcrumbSection }}</el-breadcrumb-item>
|
||||
<el-breadcrumb-item v-if="breadcrumbTitle">{{ breadcrumbTitle }}</el-breadcrumb-item>
|
||||
</el-breadcrumb>
|
||||
<el-button
|
||||
circle
|
||||
type="primary"
|
||||
class="lux-header-power-btn"
|
||||
title="退出登录"
|
||||
aria-label="退出登录"
|
||||
@click="handleLogout"
|
||||
<el-dropdown
|
||||
trigger="click"
|
||||
placement="bottom-end"
|
||||
popper-class="lux-user-dropdown"
|
||||
@command="handleUserMenuCommand"
|
||||
>
|
||||
<el-icon :size="18"><SwitchButton /></el-icon>
|
||||
</el-button>
|
||||
<el-button
|
||||
circle
|
||||
type="primary"
|
||||
class="lux-header-user-btn"
|
||||
title="用户菜单"
|
||||
aria-label="用户菜单"
|
||||
>
|
||||
<el-icon :size="18"><User /></el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item v-if="currentUsername" disabled class="lux-user-dropdown-name">
|
||||
{{ currentUsername }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item v-if="isSuperAdminUser" command="users" :divided="!!currentUsername">
|
||||
账号管理
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
command="password"
|
||||
:divided="!!currentUsername && !isSuperAdminUser"
|
||||
>
|
||||
修改密码
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item command="logout">
|
||||
退出登录
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</el-header>
|
||||
<el-main class="lux-main">
|
||||
<TabsView />
|
||||
@@ -111,6 +136,8 @@
|
||||
</el-footer>
|
||||
</el-container>
|
||||
</el-container>
|
||||
|
||||
<ChangePasswordDialog v-model="changePasswordVisible" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -118,10 +145,11 @@
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Headset, Collection, List, Upload, Document, SwitchButton, Share } from '@element-plus/icons-vue'
|
||||
import { clearToken } from '@/utils/auth'
|
||||
import { Headset, Collection, List, Upload, Document, Share, User } from '@element-plus/icons-vue'
|
||||
import { clearAuth, getUser, isSuperAdmin } from '@/utils/auth'
|
||||
import TabsView from '@/components/TabsView.vue'
|
||||
import SidebarLogo from '@/components/SidebarLogo.vue'
|
||||
import ChangePasswordDialog from '@/components/ChangePasswordDialog.vue'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -131,6 +159,10 @@ const isSidebarCollapsed = ref(true)
|
||||
|
||||
const openedMenus = ref([])
|
||||
|
||||
const isSuperAdminUser = computed(() => isSuperAdmin())
|
||||
const currentUsername = computed(() => getUser()?.username || '')
|
||||
const changePasswordVisible = ref(false)
|
||||
|
||||
function resolveOpenedMenus(path) {
|
||||
if (path.startsWith('/brand') || path.startsWith('/model')) return ['1']
|
||||
if (path.startsWith('/ota')) return ['upgrade']
|
||||
@@ -154,6 +186,7 @@ const railNavItems = [
|
||||
]
|
||||
|
||||
const breadcrumbTitle = computed(() => {
|
||||
if (route.path === '/home') return ''
|
||||
const t = route.meta?.title
|
||||
return typeof t === 'string' ? t : ''
|
||||
})
|
||||
@@ -163,14 +196,29 @@ const breadcrumbSection = computed(() => {
|
||||
if (path.startsWith('/brand') || path.startsWith('/model')) return '耳机管理'
|
||||
if (path.startsWith('/ota')) return '升级管理'
|
||||
if (path.startsWith('/share-code')) return '分享码'
|
||||
if (path.startsWith('/system')) return '系统管理'
|
||||
return ''
|
||||
})
|
||||
|
||||
const handleLogout = () => {
|
||||
clearToken()
|
||||
clearAuth()
|
||||
ElMessage.success('已退出登录')
|
||||
router.push('/login')
|
||||
}
|
||||
|
||||
function handleUserMenuCommand(command) {
|
||||
if (command === 'logout') {
|
||||
handleLogout()
|
||||
return
|
||||
}
|
||||
if (command === 'users') {
|
||||
router.push('/system/users')
|
||||
return
|
||||
}
|
||||
if (command === 'password') {
|
||||
changePasswordVisible.value = true
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user