Browse Source

更改用户名显示字段

master
parent
commit
4569fc8525
  1. 4
      src/layout/components/UserInfo/src/UserInfo.vue
  2. 10
      src/store/modules/user.ts

4
src/layout/components/UserInfo/src/UserInfo.vue

@ -25,7 +25,7 @@ const prefixCls = getPrefixCls('user-info')
const avatar = computed(() => userStore.user.avatar || avatarImg) const avatar = computed(() => userStore.user.avatar || avatarImg)
const userName = computed(() => userStore.user.nickname ?? 'Admin') const userName = computed(() => userStore.user.nickname ?? 'Admin')
const realName=computed(()=>userStore.user.realName ?? '管理员')
// //
const lockStore = useLockStore() const lockStore = useLockStore()
const getIsLock = computed(() => lockStore.getLockInfo?.isLock ?? false) const getIsLock = computed(() => lockStore.getLockInfo?.isLock ?? false)
@ -59,7 +59,7 @@ const toDocument = () => {
<div class="flex items-center"> <div class="flex items-center">
<ElAvatar :src="avatar" alt="" class="w-[calc(var(--logo-height)-25px)] rounded-[50%]" /> <ElAvatar :src="avatar" alt="" class="w-[calc(var(--logo-height)-25px)] rounded-[50%]" />
<span class="pl-[5px] text-14px text-[var(--top-header-text-color)] <lg:hidden"> <span class="pl-[5px] text-14px text-[var(--top-header-text-color)] <lg:hidden">
{{ userName }} {{ realName }}
</span> </span>
</div> </div>
<template #dropdown> <template #dropdown>

10
src/store/modules/user.ts

@ -10,7 +10,8 @@ interface UserVO {
id: number id: number
avatar: string avatar: string
nickname: string nickname: string
deptId: number deptId: number,
realName:string
} }
interface UserInfoVO { interface UserInfoVO {
@ -30,7 +31,8 @@ export const useUserStore = defineStore('admin-user', {
id: 0, id: 0,
avatar: '', avatar: '',
nickname: '', nickname: '',
deptId: 0 deptId: 0,
realName: '',
} }
}), }),
getters: { getters: {
@ -56,6 +58,7 @@ export const useUserStore = defineStore('admin-user', {
let userInfo = wsCache.get(CACHE_KEY.USER) let userInfo = wsCache.get(CACHE_KEY.USER)
if (!userInfo) { if (!userInfo) {
userInfo = await getInfo() userInfo = await getInfo()
console.log(userInfo)
} }
this.permissions = userInfo.permissions this.permissions = userInfo.permissions
this.roles = userInfo.roles this.roles = userInfo.roles
@ -92,7 +95,8 @@ export const useUserStore = defineStore('admin-user', {
id: 0, id: 0,
avatar: '', avatar: '',
nickname: '', nickname: '',
deptId: 0 deptId: 0,
realName:''
} }
} }
} }

Loading…
Cancel
Save