Skip to content

Commit c46c54c

Browse files
author
Kerwin
committed
fix: show real user role
1 parent 1de68dd commit c46c54c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/components/common/UserAvatar/index.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { computed, onMounted, ref } from 'vue'
33
import { NAvatar, NButton, NTag } from 'naive-ui'
44
import { useRoute } from 'vue-router'
5+
import { UserRole } from '../Setting/model'
56
import { useAuthStore, useUserStore } from '@/store'
67
import defaultAvatar from '@/assets/avatar.jpg'
78
import { isString } from '@/utils/is'
@@ -43,8 +44,8 @@ onMounted(async () => {
4344
<div class="flex-1 min-w-0 ml-2">
4445
<h2 v-if="userInfo.name" class="">
4546
{{ userInfo.name }}
46-
<NTag size="small" :bordered="false" type="success">
47-
Admin
47+
<NTag v-if="userInfo.roles.length > 0" size="small" :bordered="false" type="success">
48+
{{ UserRole[userInfo.roles[0]] }}
4849
</NTag>
4950
</h2>
5051
<p v-if="userInfo.name" class="overflow-hidden text-xs text-gray-500 text-ellipsis whitespace-nowrap">

src/store/modules/user/helper.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { UserRole } from '@/components/common/Setting/model'
12
import { UserConfig } from '@/components/common/Setting/model'
23
import { ss } from '@/utils/storage'
34

@@ -9,6 +10,7 @@ export interface UserInfo {
910
description: string
1011
root: boolean
1112
config: UserConfig
13+
roles: UserRole[]
1214
}
1315

1416
export interface UserState {
@@ -23,6 +25,7 @@ export function defaultSetting(): UserState {
2325
description: '',
2426
root: false,
2527
config: { chatModel: 'gpt-3.5-turbo' },
28+
roles: [],
2629
},
2730
}
2831
}

0 commit comments

Comments
 (0)