diff --git a/src/layout/components/Header/index.vue b/src/layout/components/Header/index.vue index 0ba76d2..ddf8e54 100644 --- a/src/layout/components/Header/index.vue +++ b/src/layout/components/Header/index.vue @@ -179,7 +179,7 @@ import { useTabsViewStore } from '@/store/modules/tabsView'; import { computed, ref, unref, watch, inject } from 'vue'; import { useRoute, useRouter } from 'vue-router'; - import { TABS_ROUTES } from '@/store/mutation-types'; + import { TABS_ROUTES,FIRST_ROUTE } from '@/store/mutation-types'; import { useUserStore } from '@/store/modules/user'; import { useLockscreenStore } from '@/store/modules/lockscreen'; import { useProjectSetting } from '@/hooks/setting/useProjectSetting'; @@ -343,6 +343,7 @@ // 移除标签页 tabsViewStore.closeAllTabs(); localStorage.removeItem(TABS_ROUTES); + localStorage.removeItem(FIRST_ROUTE); asyncRouteStore.setDynamicAddedRoute(false); window.location.reload(); router.replace({ diff --git a/src/layout/components/TagsView/index.vue b/src/layout/components/TagsView/index.vue index bf014d2..0b28b53 100644 --- a/src/layout/components/TagsView/index.vue +++ b/src/layout/components/TagsView/index.vue @@ -122,7 +122,7 @@ import { computed, ref, unref, provide, watch, onMounted, nextTick, toRaw, inject } from 'vue'; import { useRoute, useRouter } from 'vue-router'; import { storage } from '@/utils/Storage'; - import { TABS_ROUTES } from '@/store/mutation-types'; + import { TABS_ROUTES,FIRST_ROUTE } from '@/store/mutation-types'; import { useTabsViewStore } from '@/store/modules/tabsView'; import { useAsyncRouteStore } from '@/store/modules/asyncRoute'; import { RouteItem } from '@/store/modules/tabsView'; @@ -385,7 +385,7 @@ // 关闭全部 const closeAll = () => { tabsViewStore.closeAllTabs(); - router.replace(storage.get('FIRST-PATH')); + router.replace(storage.get(FIRST_ROUTE)); // router.replace(PageEnum.BASE_HOME_REDIRECT); updateNavScroll(); }; diff --git a/src/router/router-guards.ts b/src/router/router-guards.ts index d91e878..12543c9 100644 --- a/src/router/router-guards.ts +++ b/src/router/router-guards.ts @@ -2,7 +2,7 @@ import type { RouteRecordRaw } from 'vue-router'; import { isNavigationFailure, Router } from 'vue-router'; import { useUserStoreWidthOut } from '@/store/modules/user'; import { useAsyncRouteStoreWidthOut } from '@/store/modules/asyncRoute'; -import { ACCESS_TOKEN } from '@/store/mutation-types'; +import { ACCESS_TOKEN,FIRST_ROUTE } from '@/store/mutation-types'; import { storage } from '@/utils/Storage'; import { PageEnum } from '@/enums/pageEnum'; import { ErrorPageRoute,AboutPageRoute } from '@/router/base'; @@ -69,7 +69,7 @@ export function createRouterGuards(router: Router) { } router.addRoute(AboutPageRoute as unknown as RouteRecordRaw); const firstRoutePath = findFirstRoutePath(routes) - storage.set('FIRST-PATH',firstRoutePath) + storage.set(FIRST_ROUTE,firstRoutePath) if (from.path === LOGIN_PATH && (to.name === 'errorPage' || !to.name)) { next(firstRoutePath); return; diff --git a/src/store/mutation-types.ts b/src/store/mutation-types.ts index e7b4e57..07e349b 100644 --- a/src/store/mutation-types.ts +++ b/src/store/mutation-types.ts @@ -2,3 +2,4 @@ export const ACCESS_TOKEN = 'ACCESS-TOKEN'; // 用户token export const CURRENT_USER = 'CURRENT-USER'; // 当前用户信息 export const IS_LOCKSCREEN = 'IS-LOCKSCREEN'; // 是否锁屏 export const TABS_ROUTES = 'TABS-ROUTES'; // 标签页 +export const FIRST_ROUTE = 'FIRST-ROUTE'; // 菜单第一个路由