From e181f04c642204e79749af93fa921875ff6c21ba Mon Sep 17 00:00:00 2001 From: baoshiwei <baoshiwei@shlanbao.cn> Date: 星期二, 20 五月 2025 10:46:35 +0800 Subject: [PATCH] refactor(qms): 重构趋势图展示逻辑 --- src/plugins/tab.ts | 32 +++++++++++++++++++++----------- 1 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/plugins/tab.ts b/src/plugins/tab.ts index 97442ff..4b44dc6 100644 --- a/src/plugins/tab.ts +++ b/src/plugins/tab.ts @@ -1,19 +1,29 @@ -import { useTagsViewStore } from '@/store/modules/tagsView'; import router from '@/router'; -import { TagView, RouteLocationRaw } from 'vue-router'; +import { RouteLocationMatched, RouteLocationNormalized, RouteLocationRaw } from 'vue-router'; +import useTagsViewStore from '@/store/modules/tagsView'; export default { /** * 鍒锋柊褰撳墠tab椤电 * @param obj 鏍囩瀵硅薄 */ - async refreshPage(obj?: TagView): Promise<void> { + async refreshPage(obj?: RouteLocationNormalized): Promise<void> { const { path, query, matched } = router.currentRoute.value; if (obj === undefined) { - matched.forEach((m) => { + matched.forEach((m: RouteLocationMatched) => { if (m.components && m.components.default && m.components.default.name) { if (!['Layout', 'ParentView'].includes(m.components.default.name)) { - obj = { name: m.components.default.name, path: path, query: query }; + obj = { + name: m.components.default.name, + path: path, + query: query, + matched: undefined, + fullPath: undefined, + hash: undefined, + params: undefined, + redirectedFrom: undefined, + meta: undefined + }; } } }); @@ -38,10 +48,10 @@ } }, // 鍏抽棴鎸囧畾tab椤电 - async closePage(obj?: TagView): Promise<{ visitedViews: TagView[]; cachedViews: string[] } | any> { + async closePage(obj?: RouteLocationNormalized): Promise<{ visitedViews: RouteLocationNormalized[]; cachedViews: string[] } | any> { if (obj === undefined) { // prettier-ignore - const { visitedViews } = await useTagsViewStore().delView(router.currentRoute.value) as any + const { visitedViews } = await useTagsViewStore().delView(router.currentRoute.value) const latestView = visitedViews.slice(-1)[0]; if (latestView) { return router.push(latestView.fullPath); @@ -55,15 +65,15 @@ return useTagsViewStore().delAllViews(); }, // 鍏抽棴宸︿晶tab椤电 - closeLeftPage(obj?: TagView) { + closeLeftPage(obj?: RouteLocationNormalized) { return useTagsViewStore().delLeftTags(obj || router.currentRoute.value); }, // 鍏抽棴鍙充晶tab椤电 - closeRightPage(obj?: TagView) { + closeRightPage(obj?: RouteLocationNormalized) { return useTagsViewStore().delRightTags(obj || router.currentRoute.value); }, // 鍏抽棴鍏朵粬tab椤电 - closeOtherPage(obj?: TagView) { + closeOtherPage(obj?: RouteLocationNormalized) { return useTagsViewStore().delOthersViews(obj || router.currentRoute.value); }, /** @@ -80,7 +90,7 @@ * 淇敼tab椤电 * @param obj 鏍囩瀵硅薄 */ - updatePage(obj: TagView) { + updatePage(obj: RouteLocationNormalized) { return useTagsViewStore().updateVisitedView(obj); } }; -- Gitblit v1.9.3