import store from '@/store'
import router from '@/router';
export default {
// 刷新当å‰tab页ç¾
refreshPage(obj) {
const { path, 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 };
}
}
});
}
return store.dispatch('tagsView/delCachedView', obj).then(() => {
const { path } = obj
router.replace({
path: '/redirect' + path
})
})
},
// å…³é—当å‰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(({ lastPath }) => {
return router.push(lastPath || '/');
});
}
return store.dispatch('tagsView/delView', obj);
},
// 关闿‰€æœ‰tab页ç¾
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) {
var obj = { path: url, meta: { title: title } }
store.dispatch('tagsView/addView', obj);
return router.push(url);
},
// 修改tab页ç¾
updatePage(obj) {
return store.dispatch('tagsView/updateVisitedView', obj);
}
}