From a8ed066d8d02a42a0d997801a6b72ad0cd5806ae Mon Sep 17 00:00:00 2001 From: LiuHao <liuhaoai545@gmail.com> Date: 星期二, 20 六月 2023 18:57:27 +0800 Subject: [PATCH] update 修改删除tag方法 增加无参refreshPage --- src/store/modules/tagsView.ts | 7 +++++-- src/plugins/tab.ts | 25 ++++++++++++++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/plugins/tab.ts b/src/plugins/tab.ts index 1c0ab7a..d730aab 100644 --- a/src/plugins/tab.ts +++ b/src/plugins/tab.ts @@ -3,8 +3,11 @@ import { TagView, RouteLocationRaw } from 'vue-router'; export default { - // 鍒锋柊褰撳墠tab椤电 - async refreshPage(obj: TagView): Promise<void> { + /** + * 鍒锋柊褰撳墠tab椤电 + * @param obj 鏍囩瀵硅薄 + */ + async refreshPage(obj?: TagView): Promise<void> { const { path, query, matched } = router.currentRoute.value; if (obj === undefined) { matched.forEach((m) => { @@ -15,11 +18,16 @@ } }); } - // prettier-ignore - await useTagsViewStore().delCachedView(obj) + let query1: undefined | {} = {}; + let path1: undefined | string = ''; + if (obj) { + query1 = obj.query; + path1 = obj.path; + } + await useTagsViewStore().delCachedView(obj); await router.replace({ - path: '/redirect' + obj.path, - query: obj.query + path: '/redirect' + path1, + query: query1 }); }, // 鍏抽棴褰撳墠tab椤电锛屾墦寮�鏂伴〉绛� @@ -68,7 +76,10 @@ const obj = { path: url, query: { ...query, title } }; return router.push(obj); }, - // 淇敼tab椤电 + /** + * 淇敼tab椤电 + * @param obj 鏍囩瀵硅薄 + */ updatePage(obj: TagView) { return useTagsViewStore().updateVisitedView(obj); } diff --git a/src/store/modules/tagsView.ts b/src/store/modules/tagsView.ts index 064e4ee..cd065d1 100644 --- a/src/store/modules/tagsView.ts +++ b/src/store/modules/tagsView.ts @@ -54,8 +54,11 @@ resolve([...visitedViews.value]); }); }; - const delCachedView = (view: TagView): Promise<string[]> => { - const viewName = view.name as string; + const delCachedView = (view?: TagView): Promise<string[]> => { + let viewName = ''; + if (view) { + viewName = view.name as string; + } return new Promise((resolve) => { const index = cachedViews.value.indexOf(viewName); index > -1 && cachedViews.value.splice(index, 1); -- Gitblit v1.9.3