Skip to content

Commit f712d46

Browse files
committed
add:when active tabs closed will go to last path
1 parent cb0e889 commit f712d46

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/store/modules/app.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@ const app = {
3232
}
3333
},
3434
actions: {
35-
ToggleSideBar: ({ commit }) => {
35+
ToggleSideBar({ commit }) {
3636
commit('TOGGLE_SIDEBAR')
3737
},
38-
addVisitedViews: ({ commit }, view) => {
38+
addVisitedViews({ commit }, view) {
3939
commit('ADD_VISITED_VIEWS', view)
4040
},
41-
delVisitedViews: ({ commit }, view) => {
42-
commit('DEL_VISITED_VIEWS', view)
41+
delVisitedViews({ commit, state }, view) {
42+
return new Promise((resolve) => {
43+
commit('DEL_VISITED_VIEWS', view)
44+
resolve([...state.visitedViews])
45+
})
4346
}
4447
}
4548
}

src/views/layout/TabsView.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ export default {
1717
},
1818
methods: {
1919
closeViewTabs(view, $event) {
20-
this.$store.dispatch('delVisitedViews', view)
20+
this.$store.dispatch('delVisitedViews', view).then((views) => {
21+
if (this.isActive(view.path)) {
22+
this.$router.push(views.pop().path)
23+
}
24+
})
2125
$event.preventDefault()
2226
},
2327
generateRoute() {

0 commit comments

Comments
 (0)