浏览代码

Merge branch '01/19NavMenu' into 02_07search

mo 4 年之前
父节点
当前提交
1d8968642a
共有 2 个文件被更改,包括 9 次插入3 次删除
  1. 3 2
      src/layout/components/TagsView.vue
  2. 6 1
      src/store/modules/tagsView.js

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

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

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

@@ -1,6 +1,7 @@
 const tagsView = {
   state: {
-    visitedViews: []
+    visitedViews: [],
+    isBack: false,
     // cachedViews: []
   },
   mutations: {
@@ -66,6 +67,9 @@ const tagsView = {
     DEL_ALL_VIEWS: (state) => {
       state.visitedViews = []
       // state.cachedViews = []
+    },
+    SET_IS_BACK: (state, isBack) => {
+      state.isBack = isBack
     }
   },
   actions: {
@@ -74,6 +78,7 @@ const tagsView = {
     },
     delVisitedViews ({ commit, state }, view) {
       return new Promise((resolve) => {
+        commit('SET_IS_BACK', !view.dontNeedSave)
         commit('DEL_VISITED_VIEWS', view)
         resolve([...state.visitedViews])
       })