xingyu před 2 roky
rodič
revize
4bf8576dbd

+ 4 - 0
yudao-ui-admin-vue3/src/components/UserInfo/src/UserInfo.vue

@@ -6,6 +6,7 @@ import { useRouter } from 'vue-router'
 import { useDesign } from '@/hooks/web/useDesign'
 import avatarImg from '@/assets/imgs/avatar.gif'
 import { useUserStore } from '@/store/modules/user'
+import { useTagsViewStore } from '@/store/modules/tagsView'
 
 const { t } = useI18n()
 
@@ -15,6 +16,8 @@ const { push, replace } = useRouter()
 
 const userStore = useUserStore()
 
+const tagsViewStore = useTagsViewStore()
+
 const { getPrefixCls } = useDesign()
 
 const prefixCls = getPrefixCls('user-info')
@@ -33,6 +36,7 @@ const loginOut = () => {
   })
     .then(async () => {
       userStore.loginOut()
+      tagsViewStore.delAllViews
       replace('/login')
     })
     .catch(() => {})

+ 4 - 5
yudao-ui-admin-vue3/src/router/index.ts

@@ -48,14 +48,14 @@ router.beforeEach(async (to, from, next) => {
     if (to.path === '/login') {
       next({ path: '/' })
     } else {
-      console.info(3)
       // 获取所有字典
-      const res = await listSimpleDictDataApi()
-      dictStore.setDictMap(res)
+      if (!dictStore.getHasDictData) {
+        const res = await listSimpleDictDataApi()
+        dictStore.setDictMap(res)
+      }
       if (userStore.getRoles.length === 0) {
         isRelogin.show = true
         isRelogin.show = false
-        console.info(2)
         // 后端过滤菜单
         await permissionStore.generateRoutes()
         permissionStore.getAddRouters.forEach((route) => {
@@ -66,7 +66,6 @@ router.beforeEach(async (to, from, next) => {
         const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect }
         next(nextData)
       } else {
-        console.info(3)
         next()
       }
     }

+ 1 - 1
yudao-ui-admin-vue3/src/store/modules/dict.ts

@@ -28,7 +28,7 @@ export const useDictStore = defineStore({
     getDictMap(): Recordable {
       return this.dictMap
     },
-    getHasDictData(): Boolean {
+    getHasDictData(): boolean {
       if (this.dictMap.length > 0) {
         return true
       } else {