diff --git a/src/layout/hooks/useNav.ts b/src/layout/hooks/useNav.ts index 5ba141b3c1..5efd8cec56 100644 --- a/src/layout/hooks/useNav.ts +++ b/src/layout/hooks/useNav.ts @@ -1,4 +1,5 @@ import { computed } from "vue"; +import { storeToRefs } from "pinia"; import { getConfig } from "@/config"; import { useRouter } from "vue-router"; import { emitter } from "@/utils/mitt"; @@ -10,12 +11,14 @@ import { useAppStoreHook } from "@/store/modules/app"; import { i18nChangeLanguage } from "@wangeditor/editor"; import { useUserStoreHook } from "@/store/modules/user"; import { useEpThemeStoreHook } from "@/store/modules/epTheme"; +import { usePermissionStoreHook } from "@/store/modules/permission"; const errorInfo = "当前路由配置不正确,请检查配置"; export function useNav() { const pureApp = useAppStoreHook(); const routers = useRouter().options.routes; + const { wholeMenus } = storeToRefs(usePermissionStoreHook()); /** 用户名 */ const username = computed(() => { @@ -99,6 +102,7 @@ export function useNav() { } function menuSelect(indexPath: string, routers): void { + if (wholeMenus.value.length === 0) return; if (isRemaining(indexPath)) return; let parentPath = ""; const parentPathIndex = indexPath.lastIndexOf("/"); diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 7ec9d717e1..c487a42572 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -59,9 +59,9 @@ export const useUserStore = defineStore({ this.username = ""; this.roles = []; removeToken(); - router.push("/login"); useMultiTagsStoreHook().handleTags("equal", [...routerArrays]); resetRouter(); + router.push("/login"); }, /** 刷新`token` */ async handRefreshToken(data) {