diff --git a/src/store/modules/app.js b/src/store/modules/app.js index 07e40d42cfe2e502855dde756536a814c4c6ffe9..95cdf5f148eb45f930eeb1658b2ae24b3c25d9f5 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -32,14 +32,17 @@ const app = { } }, actions: { - ToggleSideBar: ({ commit }) => { + ToggleSideBar({ commit }) { commit('TOGGLE_SIDEBAR') }, - addVisitedViews: ({ commit }, view) => { + addVisitedViews({ commit }, view) { commit('ADD_VISITED_VIEWS', view) }, - delVisitedViews: ({ commit }, view) => { - commit('DEL_VISITED_VIEWS', view) + delVisitedViews({ commit, state }, view) { + return new Promise((resolve) => { + commit('DEL_VISITED_VIEWS', view) + resolve([...state.visitedViews]) + }) } } } diff --git a/src/views/layout/TabsView.vue b/src/views/layout/TabsView.vue index d56778fef12e01e17ce02f7486bb95777e5f3229..94e1f87214eae19a33f64b66b76323293eedb5aa 100644 --- a/src/views/layout/TabsView.vue +++ b/src/views/layout/TabsView.vue @@ -17,7 +17,11 @@ export default { }, methods: { closeViewTabs(view, $event) { - this.$store.dispatch('delVisitedViews', view) + this.$store.dispatch('delVisitedViews', view).then((views) => { + if (this.isActive(view.path)) { + this.$router.push(views.pop().path) + } + }) $event.preventDefault() }, generateRoute() {