diff --git a/src/store/modules/app.js b/src/store/modules/app.js index 21b4de01..711af23d 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -47,6 +47,25 @@ const app = { break } } + }, + DEL_OTHER_VIEWS: (state, view) => { + for (const [i, v] of state.visitedViews.entries()) { + if (v.path === view.path) { + state.visitedViews = [].concat(state.visitedViews.slice(i, i + 1)) + break + } + } + for (const i of state.cachedViews) { + if (i === view.name) { + const index = state.cachedViews.indexOf(i) + state.cachedViews = [].concat(state.cachedViews.slice(index, i + 1)) + break + } + } + }, + DEL_ALL_VIEWS: (state) => { + state.visitedViews = [] + state.cachedViews = [] } }, actions: { @@ -64,6 +83,18 @@ const app = { commit('DEL_VISITED_VIEWS', view) resolve([...state.visitedViews]) }) + }, + delOtherViews({ commit, state }, view) { + return new Promise((resolve) => { + commit('DEL_OTHER_VIEWS', view) + resolve([...state.visitedViews]) + }) + }, + delAllViews({ commit, state }) { + return new Promise((resolve) => { + commit('DEL_ALL_VIEWS') + resolve([...state.visitedViews]) + }) } } } diff --git a/src/views/layout/components/TagsView.vue b/src/views/layout/components/TagsView.vue index 75f4c72a..ec3acdf0 100644 --- a/src/views/layout/components/TagsView.vue +++ b/src/views/layout/components/TagsView.vue @@ -1,22 +1,37 @@