From 274894a41f857dac30877a5dee1c711a2a8049b6 Mon Sep 17 00:00:00 2001 From: chenrui <1187576398@qq.com> Date: 星期四, 29 五月 2025 10:38:57 +0800 Subject: [PATCH] 自动填充功能修改 --- src/plugins/tab.js | 42 ++++++++++++++++++++++++------------------ 1 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/plugins/tab.js b/src/plugins/tab.js index d9fd580..16755f0 100644 --- a/src/plugins/tab.js +++ b/src/plugins/tab.js @@ -1,20 +1,20 @@ -import store from '@/store' +import useTagsViewStore from '@/store/modules/tagsView' import router from '@/router' export default { // 鍒锋柊褰撳墠tab椤电 refreshPage(obj) { - const { path, query, matched } = router.currentRoute.value; + const { path, query, matched } = router.currentRoute.value if (obj === undefined) { matched.forEach((m) => { 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 } } } - }); + }) } - return store.dispatch('tagsView/delCachedView', obj).then(() => { + return useTagsViewStore().delCachedView(obj).then(() => { const { path, query } = obj router.replace({ path: '/redirect' + path, @@ -24,42 +24,48 @@ }, // 鍏抽棴褰撳墠tab椤电锛屾墦寮�鏂伴〉绛� closeOpenPage(obj) { - store.dispatch("tagsView/delView", router.currentRoute.value); + useTagsViewStore().delView(router.currentRoute.value) if (obj !== undefined) { - return router.push(obj); + return router.push(obj) } }, // 鍏抽棴鎸囧畾tab椤电 closePage(obj) { if (obj === undefined) { - return store.dispatch('tagsView/delView', router.currentRoute.value).then(({ lastPath }) => { - return router.push(lastPath || '/index'); - }); + return useTagsViewStore().delView(router.currentRoute.value).then(({ visitedViews }) => { + const latestView = visitedViews.slice(-1)[0] + if (latestView) { + return router.push(latestView.fullPath) + } + return router.push('/') + }) } - return store.dispatch('tagsView/delView', obj); + return useTagsViewStore().delView(obj) }, // 鍏抽棴鎵�鏈塼ab椤电 closeAllPage() { - return store.dispatch('tagsView/delAllViews'); + return useTagsViewStore().delAllViews() }, // 鍏抽棴宸︿晶tab椤电 closeLeftPage(obj) { - return store.dispatch('tagsView/delLeftTags', obj || router.currentRoute.value); + return useTagsViewStore().delLeftTags(obj || router.currentRoute.value) }, // 鍏抽棴鍙充晶tab椤电 closeRightPage(obj) { - return store.dispatch('tagsView/delRightTags', obj || router.currentRoute.value); + return useTagsViewStore().delRightTags(obj || router.currentRoute.value) }, // 鍏抽棴鍏朵粬tab椤电 closeOtherPage(obj) { - return store.dispatch('tagsView/delOthersViews', obj || router.currentRoute.value); + return useTagsViewStore().delOthersViews(obj || router.currentRoute.value) }, // 鎵撳紑tab椤电 - openPage(url) { - return router.push(url); + openPage(title, url, params) { + const obj = { path: url, meta: { title: title } } + useTagsViewStore().addView(obj) + return router.push({ path: url, query: params }) }, // 淇敼tab椤电 updatePage(obj) { - return store.dispatch('tagsView/updateVisitedView', obj); + return useTagsViewStore().updateVisitedView(obj) } } -- Gitblit v1.9.3