Browse Source

Merge branch '01/19NavMenu' of http://git.dayaedu.com/molingzhide/dy-admin-manager into 01/19NavMenu

mo 4 years ago
parent
commit
f50d599200
2 changed files with 9 additions and 4 deletions
  1. 3 2
      src/layout/components/TagsView.vue
  2. 6 2
      src/store/modules/tagsView.js

+ 3 - 2
src/layout/components/TagsView.vue

@@ -60,7 +60,7 @@ export default {
     $route() {
     $route() {
       this.addViewTags();
       this.addViewTags();
       this.moveToCurrentTag();
       this.moveToCurrentTag();
-      if (!activeKey) {
+      if (!activeKey && !this.$store.state.tagsView.isBack) {
         const s = new Searchs()
         const s = new Searchs()
         const keys = [this.$route.path]
         const keys = [this.$route.path]
         for (const key in s.searchs) {
         for (const key in s.searchs) {
@@ -75,6 +75,7 @@ export default {
           s.removeByKey(item)
           s.removeByKey(item)
         }
         }
       }
       }
+      this.$store.commit('SET_IS_BACK', false)
       activeKey = ''
       activeKey = ''
     },
     },
     visible(value) {
     visible(value) {
@@ -146,7 +147,7 @@ export default {
     closeSelectedTag(view) {
     closeSelectedTag(view) {
       const searchs = new Searchs();
       const searchs = new Searchs();
       searchs.remove(this.$route.path);
       searchs.remove(this.$route.path);
-      this.$store.dispatch("delVisitedViews", view).then((views) => {
+      this.$store.dispatch("delVisitedViews", {...view, dontNeedSave: true}).then((views) => {
         if (this.isActive(view)) {
         if (this.isActive(view)) {
           const latestView = views.slice(-1)[0];
           const latestView = views.slice(-1)[0];
           if (latestView) {
           if (latestView) {

+ 6 - 2
src/store/modules/tagsView.js

@@ -1,11 +1,11 @@
 const tagsView = {
 const tagsView = {
   state: {
   state: {
-    visitedViews: []
+    visitedViews: [],
+    isBack: false,
     // cachedViews: []
     // cachedViews: []
   },
   },
   mutations: {
   mutations: {
     ADD_VISITED_VIEWS: (state, view) => {
     ADD_VISITED_VIEWS: (state, view) => {
-      console.log(view)
       if (state.visitedViews.some(v => v.path === view.path)) {
       if (state.visitedViews.some(v => v.path === view.path)) {
         state.visitedViews.forEach(v => {
         state.visitedViews.forEach(v => {
           if (v.path === view.path) {
           if (v.path === view.path) {
@@ -67,6 +67,9 @@ const tagsView = {
     DEL_ALL_VIEWS: (state) => {
     DEL_ALL_VIEWS: (state) => {
       state.visitedViews = []
       state.visitedViews = []
       // state.cachedViews = []
       // state.cachedViews = []
+    },
+    SET_IS_BACK: (state, isBack) => {
+      state.isBack = isBack
     }
     }
   },
   },
   actions: {
   actions: {
@@ -75,6 +78,7 @@ const tagsView = {
     },
     },
     delVisitedViews ({ commit, state }, view) {
     delVisitedViews ({ commit, state }, view) {
       return new Promise((resolve) => {
       return new Promise((resolve) => {
+        commit('SET_IS_BACK', !view.dontNeedSave)
         commit('DEL_VISITED_VIEWS', view)
         commit('DEL_VISITED_VIEWS', view)
         resolve([...state.visitedViews])
         resolve([...state.visitedViews])
       })
       })