Browse Source

fix: 使正确显示右上方登录账号名

Signed-off-by: 吴医生 <draculakkk@hotmail.com>
吴医生 3 years ago
parent
commit
babab39710
1 changed files with 15 additions and 3 deletions
  1. 15 3
      src/components/GoUserInfo/index.vue

+ 15 - 3
src/components/GoUserInfo/index.vue

@@ -27,7 +27,9 @@
 <script lang="ts" setup>
 import { h, ref } from 'vue'
 import { NAvatar, NText } from 'naive-ui'
-import { renderIcon } from '@/utils'
+import { renderIcon, getLocalStorage } from '@/utils'
+import { SystemStoreEnum, SystemStoreUserInfoEnum } from '@/store/modules/systemStore/systemStore.d'
+import { StorageEnum } from '@/enums/storageEnum'
 import { logout, renderLang } from '@/utils'
 import { GoSystemSet } from '@/components/GoSystemSet/index'
 import { GoSystemInfo } from '@/components/GoSystemInfo/index'
@@ -64,7 +66,17 @@ const renderUserInfo = () => {
       }),
       h('div', null, [
         h('div', null, [
-          h(NText, { depth: 2 }, { default: () => '奔跑的面条' })
+            h(NText, { depth: 2 }, {
+                default: () => {
+                    const info = getLocalStorage(StorageEnum.GO_SYSTEM_STORE)
+                    if (info) {
+                        return info[SystemStoreEnum.USER_INFO][SystemStoreUserInfoEnum.USER_NAME];
+                    }
+                    else {
+                        return 'admin';
+                    }
+                }
+            })
         ])
       ])
     ]
@@ -137,4 +149,4 @@ const handleSelect = (key: string) => {
   cursor: pointer;
   transform: scale(0.7);
 }
-</style>
+</style>