From f712d4682ea91234be664481390fbc803564b507 Mon Sep 17 00:00:00 2001
From: Pan <panfree23@gmail.com>
Date: Fri, 1 Sep 2017 10:46:20 +0800
Subject: [PATCH] add:when active tabs closed will go to last path

---
 src/store/modules/app.js      | 11 +++++++----
 src/views/layout/TabsView.vue |  6 +++++-
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/store/modules/app.js b/src/store/modules/app.js
index 07e40d42..95cdf5f1 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 d56778fe..94e1f872 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() {
-- 
GitLab