From 4169e52baaaa43765848c29c5ce222d019e81c35 Mon Sep 17 00:00:00 2001 From: kailong321200875 <321200875@qq.com> Date: Mon, 21 Aug 2023 09:40:09 +0800 Subject: [PATCH] fix: #318 --- src/store/modules/tagsView.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/store/modules/tagsView.ts b/src/store/modules/tagsView.ts index 039ee534c..1d608bfa7 100644 --- a/src/store/modules/tagsView.ts +++ b/src/store/modules/tagsView.ts @@ -4,6 +4,12 @@ import { getRawRoute } from '@/utils/routerHelper' import { defineStore } from 'pinia' import { store } from '../index' import { findIndex } from '@/utils' +import { useStorage } from '@/hooks/web/useStorage' +import { useAppStoreWithOut } from './app' + +const appStore = useAppStoreWithOut() + +const { getStorage } = useStorage() export interface TagsViewState { visitedViews: RouteLocationNormalizedLoaded[] @@ -49,7 +55,7 @@ export const useTagsViewStore = defineStore('tagsView', { const cacheMap: Set = new Set() for (const v of this.visitedViews) { const item = getRawRoute(v) - const needCache = !item.meta?.noCache + const needCache = !item?.meta?.noCache if (!needCache) { continue } @@ -90,7 +96,9 @@ export const useTagsViewStore = defineStore('tagsView', { // 删除所有tag delAllVisitedViews() { // const affixTags = this.visitedViews.filter((tag) => tag.meta.affix) - this.visitedViews = this.visitedViews.filter((tag) => tag.meta?.affix) + this.visitedViews = getStorage(appStore.getUserInfo) + ? this.visitedViews.filter((tag) => tag?.meta?.affix) + : [] }, // 删除其它 delOthersViews(view: RouteLocationNormalizedLoaded) {