From 8a1c08baaf0ee002b471996b195e7da180b90209 Mon Sep 17 00:00:00 2001 From: feige <791364011@qq.com> Date: 星期一, 21 七月 2025 09:38:47 +0800 Subject: [PATCH] 增加了前端代码库 --- src/plugins/tab.js | 71 +++++++++++++++++++++++++++++++++++ 1 files changed, 71 insertions(+), 0 deletions(-) diff --git a/src/plugins/tab.js b/src/plugins/tab.js new file mode 100644 index 0000000..f21467d --- /dev/null +++ b/src/plugins/tab.js @@ -0,0 +1,71 @@ +import store from '@/store' +import router from '@/router' + +export default { + // 鍒锋柊褰撳墠tab椤电 + refreshPage(obj) { + const { path, query, matched } = router.currentRoute + 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 } + } + } + }) + } + return store.dispatch('tagsView/delCachedView', obj).then(() => { + const { path, query } = obj + router.replace({ + path: '/redirect' + path, + query: query + }) + }) + }, + // 鍏抽棴褰撳墠tab椤电锛屾墦寮�鏂伴〉绛� + closeOpenPage(obj) { + store.dispatch("tagsView/delView", router.currentRoute) + if (obj !== undefined) { + return router.push(obj) + } + }, + // 鍏抽棴鎸囧畾tab椤电 + closePage(obj) { + if (obj === undefined) { + return store.dispatch('tagsView/delView', router.currentRoute).then(({ visitedViews }) => { + const latestView = visitedViews.slice(-1)[0] + if (latestView) { + return router.push(latestView.fullPath) + } + return router.push('/') + }) + } + return store.dispatch('tagsView/delView', obj) + }, + // 鍏抽棴鎵�鏈塼ab椤电 + closeAllPage() { + return store.dispatch('tagsView/delAllViews') + }, + // 鍏抽棴宸︿晶tab椤电 + closeLeftPage(obj) { + return store.dispatch('tagsView/delLeftTags', obj || router.currentRoute) + }, + // 鍏抽棴鍙充晶tab椤电 + closeRightPage(obj) { + return store.dispatch('tagsView/delRightTags', obj || router.currentRoute) + }, + // 鍏抽棴鍏朵粬tab椤电 + closeOtherPage(obj) { + return store.dispatch('tagsView/delOthersViews', obj || router.currentRoute) + }, + // 娣诲姞tab椤电 + openPage(title, url, params) { + const obj = { path: url, meta: { title: title } } + store.dispatch('tagsView/addView', obj) + return router.push({ path: url, query: params }) + }, + // 淇敼tab椤电 + updatePage(obj) { + return store.dispatch('tagsView/updateVisitedView', obj) + } +} -- Gitblit v1.9.1