File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111 </Button >
1212 </DropdownMenuTrigger >
1313 <DropdownMenuContent class="w-48" align="end" side="top">
14+ <DropdownMenuItem >
15+ <!-- 显示用户名 -->
16+ <Icon name="ri:user-line " class="h-4 w-4" />
17+ <span v-if =" !isAdmin" >{{ userInfo?.account_name }}</span >
18+ <span v-else >rustfsAdmin</span >
19+ </DropdownMenuItem >
1420 <DropdownMenuItem v-if =" ! isAdmin " @select =" handleChangePassword " >
1521 <Icon name="ri:lock-password-line " class="h-4 w-4" />
1622 <span >{{ t('Change Password') }}</span >
@@ -34,6 +40,7 @@ import AccessKeysChangePassword from '@/components/access-keys/change-password.v
3440
3541const { t } = useI18n ()
3642const { logout, isAdmin, setIsAdmin } = useAuth ()
43+ const { userInfo } = usePermissions ()
3744const router = useRouter ()
3845const { isAdminUser } = useUsers ()
3946
Original file line number Diff line number Diff line change @@ -7,15 +7,15 @@ export const usePermissions = () => {
77
88 // Store user policy in global state
99 const userPolicy = useState < ConsolePolicy | null > ( 'user-policy' , ( ) => null )
10+ const userInfo = useState < any > ( 'user-info' , ( ) => null )
1011 const isLoading = useState < boolean > ( 'user-policy-loading' , ( ) => false )
1112
1213 const fetchUserPolicy = async ( ) => {
13- if ( isAdmin . value ) return
14-
1514 isLoading . value = true
1615 try {
17- const userInfo = await $api . get ( '/accountinfo' )
18- let userInfoPolicy = userInfo . policy as string
16+ const info = await $api . get ( '/accountinfo' )
17+ userInfo . value = info
18+ let userInfoPolicy = info . policy as string
1919 userPolicy . value = JSON . parse ( userInfoPolicy ) as ConsolePolicy
2020 } catch ( e ) {
2121 console . error ( 'Failed to fetch user policy' , e )
@@ -79,6 +79,7 @@ export const usePermissions = () => {
7979
8080 return {
8181 userPolicy,
82+ userInfo,
8283 isLoading,
8384 fetchUserPolicy,
8485 hasPermission,
You can’t perform that action at this time.
0 commit comments