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 | import { useDesign } from '@/hooks/web/useDesign' |
| 7 | 7 | import avatarImg from '@/assets/imgs/avatar.gif' |
| 8 | 8 | import { useUserStore } from '@/store/modules/user' |
| 9 | +import { useTagsViewStore } from '@/store/modules/tagsView' | |
| 9 | 10 | |
| 10 | 11 | const { t } = useI18n() |
| 11 | 12 | |
| ... | ... | @@ -15,6 +16,8 @@ const { push, replace } = useRouter() |
| 15 | 16 | |
| 16 | 17 | const userStore = useUserStore() |
| 17 | 18 | |
| 19 | +const tagsViewStore = useTagsViewStore() | |
| 20 | + | |
| 18 | 21 | const { getPrefixCls } = useDesign() |
| 19 | 22 | |
| 20 | 23 | const prefixCls = getPrefixCls('user-info') |
| ... | ... | @@ -33,6 +36,7 @@ const loginOut = () => { |
| 33 | 36 | }) |
| 34 | 37 | .then(async () => { |
| 35 | 38 | userStore.loginOut() |
| 39 | + tagsViewStore.delAllViews | |
| 36 | 40 | replace('/login') |
| 37 | 41 | }) |
| 38 | 42 | .catch(() => {}) | ... | ... |
yudao-ui-admin-vue3/src/router/index.ts
| ... | ... | @@ -48,14 +48,14 @@ router.beforeEach(async (to, from, next) => { |
| 48 | 48 | if (to.path === '/login') { |
| 49 | 49 | next({ path: '/' }) |
| 50 | 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 | 56 | if (userStore.getRoles.length === 0) { |
| 56 | 57 | isRelogin.show = true |
| 57 | 58 | isRelogin.show = false |
| 58 | - console.info(2) | |
| 59 | 59 | // 后端过滤菜单 |
| 60 | 60 | await permissionStore.generateRoutes() |
| 61 | 61 | permissionStore.getAddRouters.forEach((route) => { |
| ... | ... | @@ -66,7 +66,6 @@ router.beforeEach(async (to, from, next) => { |
| 66 | 66 | const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect } |
| 67 | 67 | next(nextData) |
| 68 | 68 | } else { |
| 69 | - console.info(3) | |
| 70 | 69 | next() |
| 71 | 70 | } |
| 72 | 71 | } | ... | ... |
yudao-ui-admin-vue3/src/store/modules/dict.ts