diff --git a/src/layout/components/TagsView/index.vue b/src/layout/components/TagsView/index.vue
index 7a3d3067..b3e6f100 100644
--- a/src/layout/components/TagsView/index.vue
+++ b/src/layout/components/TagsView/index.vue
@@ -22,6 +22,7 @@
Refresh
Close
Close Others
+ Close to the Right
Close All
@@ -76,6 +77,9 @@ export default {
isAffix(tag) {
return tag.meta && tag.meta.affix
},
+ isLastView() {
+ return this.selectedTag.fullPath === this.visitedViews[this.visitedViews.length - 1].fullPath
+ },
filterAffixTags(routes, basePath = '/') {
let tags = []
routes.forEach(route => {
@@ -159,6 +163,13 @@ export default {
this.moveToCurrentTag()
})
},
+ closeRightTags() {
+ this.$store.dispatch('tagsView/delRightTags', this.selectedTag).then(visitedViews => {
+ if (!visitedViews.find(i => i.fullPath === this.$route.fullPath)) {
+ this.toLastView(visitedViews)
+ }
+ })
+ },
closeAllTags(view) {
this.$store.dispatch('tagsView/delAllViews').then(({ visitedViews }) => {
if (this.affixTags.some(tag => tag.path === view.path)) {
@@ -167,7 +178,7 @@ export default {
this.toLastView(visitedViews, view)
})
},
- toLastView(visitedViews, view) {
+ toLastView(visitedViews, view = {}) {
const latestView = visitedViews.slice(-1)[0]
if (latestView) {
this.$router.push(latestView.fullPath)
diff --git a/src/store/modules/tagsView.js b/src/store/modules/tagsView.js
index ab2ec298..b8bb520f 100644
--- a/src/store/modules/tagsView.js
+++ b/src/store/modules/tagsView.js
@@ -66,6 +66,19 @@ const mutations = {
},
MOVE_VIEW: (state, { oldIndex, newIndex }) => {
state.visitedViews.splice(newIndex, 0, state.visitedViews.splice(oldIndex, 1)[0])
+ },
+ DEL_RIGHT_VIEWS: (state, view) => {
+ const index = state.visitedViews.findIndex(v => v.path === view.path)
+ if (index === -1) {
+ return
+ }
+ const arr = state.visitedViews.splice(index + 1)
+ arr.forEach(item => {
+ const index = state.cachedViews.indexOf(item.name)
+ if (index > -1) {
+ state.cachedViews.splice(index, 1)
+ }
+ })
}
}
@@ -155,6 +168,12 @@ const actions = {
},
moveView({ commit }, arg) {
commit('MOVE_VIEW', arg)
+ },
+ delRightTags({ commit }, view) {
+ return new Promise(resolve => {
+ commit('DEL_RIGHT_VIEWS', view)
+ resolve([...state.visitedViews])
+ })
}
}