mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-10-31 10:37:41 +08:00 
			
		
		
		
	perf: store
This commit is contained in:
		| @ -6,6 +6,7 @@ import { useRouter } from 'vue-router' | |||||||
| import { useDesign } from '@/hooks/web/useDesign' | import { useDesign } from '@/hooks/web/useDesign' | ||||||
| import avatarImg from '@/assets/imgs/avatar.gif' | import avatarImg from '@/assets/imgs/avatar.gif' | ||||||
| import { useUserStore } from '@/store/modules/user' | import { useUserStore } from '@/store/modules/user' | ||||||
|  | import { useTagsViewStore } from '@/store/modules/tagsView' | ||||||
|  |  | ||||||
| const { t } = useI18n() | const { t } = useI18n() | ||||||
|  |  | ||||||
| @ -15,6 +16,8 @@ const { push, replace } = useRouter() | |||||||
|  |  | ||||||
| const userStore = useUserStore() | const userStore = useUserStore() | ||||||
|  |  | ||||||
|  | const tagsViewStore = useTagsViewStore() | ||||||
|  |  | ||||||
| const { getPrefixCls } = useDesign() | const { getPrefixCls } = useDesign() | ||||||
|  |  | ||||||
| const prefixCls = getPrefixCls('user-info') | const prefixCls = getPrefixCls('user-info') | ||||||
| @ -33,6 +36,7 @@ const loginOut = () => { | |||||||
|   }) |   }) | ||||||
|     .then(async () => { |     .then(async () => { | ||||||
|       userStore.loginOut() |       userStore.loginOut() | ||||||
|  |       tagsViewStore.delAllViews | ||||||
|       replace('/login') |       replace('/login') | ||||||
|     }) |     }) | ||||||
|     .catch(() => {}) |     .catch(() => {}) | ||||||
|  | |||||||
| @ -48,14 +48,14 @@ router.beforeEach(async (to, from, next) => { | |||||||
|     if (to.path === '/login') { |     if (to.path === '/login') { | ||||||
|       next({ path: '/' }) |       next({ path: '/' }) | ||||||
|     } else { |     } else { | ||||||
|       console.info(3) |  | ||||||
|       // 获取所有字典 |       // 获取所有字典 | ||||||
|       const res = await listSimpleDictDataApi() |       if (!dictStore.getHasDictData) { | ||||||
|       dictStore.setDictMap(res) |         const res = await listSimpleDictDataApi() | ||||||
|  |         dictStore.setDictMap(res) | ||||||
|  |       } | ||||||
|       if (userStore.getRoles.length === 0) { |       if (userStore.getRoles.length === 0) { | ||||||
|         isRelogin.show = true |         isRelogin.show = true | ||||||
|         isRelogin.show = false |         isRelogin.show = false | ||||||
|         console.info(2) |  | ||||||
|         // 后端过滤菜单 |         // 后端过滤菜单 | ||||||
|         await permissionStore.generateRoutes() |         await permissionStore.generateRoutes() | ||||||
|         permissionStore.getAddRouters.forEach((route) => { |         permissionStore.getAddRouters.forEach((route) => { | ||||||
| @ -66,7 +66,6 @@ router.beforeEach(async (to, from, next) => { | |||||||
|         const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect } |         const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect } | ||||||
|         next(nextData) |         next(nextData) | ||||||
|       } else { |       } else { | ||||||
|         console.info(3) |  | ||||||
|         next() |         next() | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -28,7 +28,7 @@ export const useDictStore = defineStore({ | |||||||
|     getDictMap(): Recordable { |     getDictMap(): Recordable { | ||||||
|       return this.dictMap |       return this.dictMap | ||||||
|     }, |     }, | ||||||
|     getHasDictData(): Boolean { |     getHasDictData(): boolean { | ||||||
|       if (this.dictMap.length > 0) { |       if (this.dictMap.length > 0) { | ||||||
|         return true |         return true | ||||||
|       } else { |       } else { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 xingyu
					xingyu