Commit 4bf8576dbd91a80abe9f14e2cf852722e18b1d9f
1 parent
b64261a2
perf: store
Showing
3 changed files
with
9 additions
and
6 deletions
yudao-ui-admin-vue3/src/components/UserInfo/src/UserInfo.vue
| @@ -6,6 +6,7 @@ import { useRouter } from 'vue-router' | @@ -6,6 +6,7 @@ import { useRouter } from 'vue-router' | ||
| 6 | import { useDesign } from '@/hooks/web/useDesign' | 6 | import { useDesign } from '@/hooks/web/useDesign' |
| 7 | import avatarImg from '@/assets/imgs/avatar.gif' | 7 | import avatarImg from '@/assets/imgs/avatar.gif' |
| 8 | import { useUserStore } from '@/store/modules/user' | 8 | import { useUserStore } from '@/store/modules/user' |
| 9 | +import { useTagsViewStore } from '@/store/modules/tagsView' | ||
| 9 | 10 | ||
| 10 | const { t } = useI18n() | 11 | const { t } = useI18n() |
| 11 | 12 | ||
| @@ -15,6 +16,8 @@ const { push, replace } = useRouter() | @@ -15,6 +16,8 @@ const { push, replace } = useRouter() | ||
| 15 | 16 | ||
| 16 | const userStore = useUserStore() | 17 | const userStore = useUserStore() |
| 17 | 18 | ||
| 19 | +const tagsViewStore = useTagsViewStore() | ||
| 20 | + | ||
| 18 | const { getPrefixCls } = useDesign() | 21 | const { getPrefixCls } = useDesign() |
| 19 | 22 | ||
| 20 | const prefixCls = getPrefixCls('user-info') | 23 | const prefixCls = getPrefixCls('user-info') |
| @@ -33,6 +36,7 @@ const loginOut = () => { | @@ -33,6 +36,7 @@ const loginOut = () => { | ||
| 33 | }) | 36 | }) |
| 34 | .then(async () => { | 37 | .then(async () => { |
| 35 | userStore.loginOut() | 38 | userStore.loginOut() |
| 39 | + tagsViewStore.delAllViews | ||
| 36 | replace('/login') | 40 | replace('/login') |
| 37 | }) | 41 | }) |
| 38 | .catch(() => {}) | 42 | .catch(() => {}) |
yudao-ui-admin-vue3/src/router/index.ts
| @@ -48,14 +48,14 @@ router.beforeEach(async (to, from, next) => { | @@ -48,14 +48,14 @@ router.beforeEach(async (to, from, next) => { | ||
| 48 | if (to.path === '/login') { | 48 | if (to.path === '/login') { |
| 49 | next({ path: '/' }) | 49 | next({ path: '/' }) |
| 50 | } else { | 50 | } else { |
| 51 | - console.info(3) | ||
| 52 | // 获取所有字典 | 51 | // 获取所有字典 |
| 53 | - const res = await listSimpleDictDataApi() | ||
| 54 | - dictStore.setDictMap(res) | 52 | + if (!dictStore.getHasDictData) { |
| 53 | + const res = await listSimpleDictDataApi() | ||
| 54 | + dictStore.setDictMap(res) | ||
| 55 | + } | ||
| 55 | if (userStore.getRoles.length === 0) { | 56 | if (userStore.getRoles.length === 0) { |
| 56 | isRelogin.show = true | 57 | isRelogin.show = true |
| 57 | isRelogin.show = false | 58 | isRelogin.show = false |
| 58 | - console.info(2) | ||
| 59 | // 后端过滤菜单 | 59 | // 后端过滤菜单 |
| 60 | await permissionStore.generateRoutes() | 60 | await permissionStore.generateRoutes() |
| 61 | permissionStore.getAddRouters.forEach((route) => { | 61 | permissionStore.getAddRouters.forEach((route) => { |
| @@ -66,7 +66,6 @@ router.beforeEach(async (to, from, next) => { | @@ -66,7 +66,6 @@ router.beforeEach(async (to, from, next) => { | ||
| 66 | const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect } | 66 | const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect } |
| 67 | next(nextData) | 67 | next(nextData) |
| 68 | } else { | 68 | } else { |
| 69 | - console.info(3) | ||
| 70 | next() | 69 | next() |
| 71 | } | 70 | } |
| 72 | } | 71 | } |
yudao-ui-admin-vue3/src/store/modules/dict.ts
| @@ -28,7 +28,7 @@ export const useDictStore = defineStore({ | @@ -28,7 +28,7 @@ export const useDictStore = defineStore({ | ||
| 28 | getDictMap(): Recordable { | 28 | getDictMap(): Recordable { |
| 29 | return this.dictMap | 29 | return this.dictMap |
| 30 | }, | 30 | }, |
| 31 | - getHasDictData(): Boolean { | 31 | + getHasDictData(): boolean { |
| 32 | if (this.dictMap.length > 0) { | 32 | if (this.dictMap.length > 0) { |
| 33 | return true | 33 | return true |
| 34 | } else { | 34 | } else { |