From 9259c2235e31708f954a3578bde3c6a7ab9753e8 Mon Sep 17 00:00:00 2001 From: houzhongjian <houzhongyi@126.com> Date: 星期一, 30 十二月 2024 15:51:40 +0800 Subject: [PATCH] 1、工作流相关组件更新 2、偶尔出现退出登录时路由报错的bug导致无法回到登录页面 3、全局配置文件修改,移除VITE_UPLOAD_URL配置等 --- src/layout/components/Logo/src/Logo.vue | 37 ++++++++++++++++++++++++++++--------- 1 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/layout/components/Logo/src/Logo.vue b/src/layout/components/Logo/src/Logo.vue index d5790b0..ef80370 100644 --- a/src/layout/components/Logo/src/Logo.vue +++ b/src/layout/components/Logo/src/Logo.vue @@ -1,8 +1,17 @@ <script lang="ts" setup> import { computed, onMounted, ref, unref, watch } from 'vue' import { useAppStore } from '@/store/modules/app' +import { useUserStoreWithOut } from '@/store/modules/user' +import { usePermissionStoreWithOut } from '@/store/modules/permission' import { useDesign } from '@/hooks/web/useDesign' -import * as authUtil from "@/utils/auth"; +import {isRelogin} from "@/config/axios/service"; +import router from "@/router"; +import type {RouteRecordRaw} from "vue-router"; +import {CACHE_KEY, useCache, useSessionCache} from "@/hooks/web/useCache"; +import {getAccessToken} from "@/utils/auth"; +import {getInfo} from "@/api/login"; +const { wsCache } = useCache() +const { wsSessionCache } = useSessionCache() defineOptions({ name: 'Logo' }) @@ -22,14 +31,7 @@ const collapse = computed(() => appStore.getCollapse) -let tenantId = authUtil.getTenantId() -console.log(tenantId) -if (tenantId && tenantId === 1) { - homePath.value = '/index' -} else { - homePath.value = '/home2' -} -console.log(homePath.value) +homePath.value = '/index' onMounted(() => { if (unref(collapse)) show.value = false @@ -66,6 +68,22 @@ } } ) + +/** 刷新所有菜单权限 */ +const gotoHome = async () => { + const permissionStore = usePermissionStoreWithOut() + isRelogin.show = true + let userInfo = await getInfo() + wsCache.set(CACHE_KEY.USER, userInfo) + wsSessionCache.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus) + isRelogin.show = false + // 后端过滤菜单 + await permissionStore.generateRoutes() + permissionStore.getAddRouters.forEach((route) => { + router.addRoute(route as unknown as RouteRecordRaw) // 动态添加可访问路由表 + }) +} + </script> <template> @@ -76,6 +94,7 @@ layout !== 'classic' ? `${prefixCls}__Top` : '', 'flex !h-[var(--logo-height)] items-center cursor-pointer pl-8px relative decoration-none overflow-hidden' ]" + @click="gotoHome" :to="homePath" > <img -- Gitblit v1.9.3