This commit is contained in:
邱贞招 2024-06-13 17:47:43 +08:00
parent 3206bc349f
commit 0802a32395
3 changed files with 15 additions and 0 deletions

View File

@ -6,6 +6,7 @@
<top-nav id="topmenu-container" class="topmenu-container" v-if="topNav"/> <top-nav id="topmenu-container" class="topmenu-container" v-if="topNav"/>
<div class="right-menu"> <div class="right-menu">
<span class="dept-name">{{deptName}}</span>
<template v-if="device!=='mobile'"> <template v-if="device!=='mobile'">
<search id="header-search" class="right-menu-item" /> <search id="header-search" class="right-menu-item" />
@ -64,6 +65,7 @@ export default {
...mapGetters([ ...mapGetters([
'sidebar', 'sidebar',
'avatar', 'avatar',
'deptName',
'device' 'device'
]), ]),
setting: { setting: {
@ -138,10 +140,17 @@ export default {
} }
.right-menu { .right-menu {
display: flex;
align-items: center; /* 垂直居中对齐 */
float: right; float: right;
height: 100%; height: 100%;
line-height: 50px; line-height: 50px;
.dept-name {
font-size: 14px;
margin-right: 10px;
}
&:focus { &:focus {
outline: none; outline: none;
} }

View File

@ -7,6 +7,7 @@ const getters = {
cachedViews: state => state.tagsView.cachedViews, cachedViews: state => state.tagsView.cachedViews,
token: state => state.user.token, token: state => state.user.token,
avatar: state => state.user.avatar, avatar: state => state.user.avatar,
deptName: state => state.user.deptName,
name: state => state.user.name, name: state => state.user.name,
introduction: state => state.user.introduction, introduction: state => state.user.introduction,
roles: state => state.user.roles, roles: state => state.user.roles,

View File

@ -7,6 +7,7 @@ const user = {
id: '', id: '',
name: '', name: '',
avatar: '', avatar: '',
deptName: '',
roles: [], roles: [],
permissions: [] permissions: []
}, },
@ -24,6 +25,9 @@ const user = {
SET_AVATAR: (state, avatar) => { SET_AVATAR: (state, avatar) => {
state.avatar = avatar state.avatar = avatar
}, },
SET_DEPTNAME: (state, deptName) => {
state.deptName = deptName
},
SET_ROLES: (state, roles) => { SET_ROLES: (state, roles) => {
state.roles = roles state.roles = roles
}, },
@ -65,6 +69,7 @@ const user = {
commit('SET_ID', user.userId) commit('SET_ID', user.userId)
commit('SET_NAME', user.userName) commit('SET_NAME', user.userName)
commit('SET_AVATAR', avatar) commit('SET_AVATAR', avatar)
commit('SET_DEPTNAME', user.dept.deptName)
resolve(res) resolve(res)
}).catch(error => { }).catch(error => {
reject(error) reject(error)