提交 | 用户 | 时间
|
e57a89
|
1 |
import store from '@/store' |
懒 |
2 |
import router from '@/router'; |
|
3 |
|
|
4 |
export default { |
|
5 |
// 刷新当前tab页签 |
|
6 |
refreshPage(obj) { |
|
7 |
const { path, query, matched } = router.currentRoute; |
|
8 |
if (obj === undefined) { |
|
9 |
matched.forEach((m) => { |
|
10 |
if (m.components && m.components.default && m.components.default.name) { |
|
11 |
if (!['Layout', 'ParentView'].includes(m.components.default.name)) { |
|
12 |
obj = { name: m.components.default.name, path: path, query: query }; |
|
13 |
} |
|
14 |
} |
|
15 |
}); |
|
16 |
} |
|
17 |
return store.dispatch('tagsView/delCachedView', obj).then(() => { |
|
18 |
const { path, query } = obj |
|
19 |
router.replace({ |
|
20 |
path: '/redirect' + path, |
|
21 |
query: query |
|
22 |
}) |
|
23 |
}) |
|
24 |
}, |
|
25 |
// 关闭当前tab页签,打开新页签 |
|
26 |
closeOpenPage(obj) { |
|
27 |
store.dispatch("tagsView/delView", router.currentRoute); |
|
28 |
if (obj !== undefined) { |
|
29 |
return router.push(obj); |
|
30 |
} |
|
31 |
}, |
|
32 |
// 关闭指定tab页签 |
|
33 |
closePage(obj) { |
|
34 |
if (obj === undefined) { |
|
35 |
return store.dispatch('tagsView/delView', router.currentRoute).then(({ visitedViews }) => { |
|
36 |
const latestView = visitedViews.slice(-1)[0] |
|
37 |
if (latestView) { |
|
38 |
return router.push(latestView.fullPath) |
|
39 |
} |
|
40 |
return router.push('/'); |
|
41 |
}); |
|
42 |
} |
|
43 |
return store.dispatch('tagsView/delView', obj); |
|
44 |
}, |
|
45 |
// 关闭所有tab页签 |
|
46 |
closeAllPage() { |
|
47 |
return store.dispatch('tagsView/delAllViews'); |
|
48 |
}, |
|
49 |
// 关闭左侧tab页签 |
|
50 |
closeLeftPage(obj) { |
|
51 |
return store.dispatch('tagsView/delLeftTags', obj || router.currentRoute); |
|
52 |
}, |
|
53 |
// 关闭右侧tab页签 |
|
54 |
closeRightPage(obj) { |
|
55 |
return store.dispatch('tagsView/delRightTags', obj || router.currentRoute); |
|
56 |
}, |
|
57 |
// 关闭其他tab页签 |
|
58 |
closeOtherPage(obj) { |
|
59 |
return store.dispatch('tagsView/delOthersViews', obj || router.currentRoute); |
|
60 |
}, |
|
61 |
// 添加tab页签 |
|
62 |
openPage(title, url, params) { |
|
63 |
const obj = { path: url, meta: { title: title } } |
|
64 |
store.dispatch('tagsView/addView', obj); |
|
65 |
return router.push({ path: url, query: params }); |
|
66 |
}, |
|
67 |
// 修改tab页签 |
|
68 |
updatePage(obj) { |
|
69 |
return store.dispatch('tagsView/updateVisitedView', obj); |
|
70 |
} |
|
71 |
} |