Bladeren bron

页签新增关闭左侧

RuoYi 4 jaren geleden
bovenliggende
commit
ea20fa3ce2
2 gewijzigde bestanden met toevoegingen van 40 en 1 verwijderingen
  1. 15 0
      ruoyi-ui/src/layout/components/TagsView/index.vue
  2. 25 1
      ruoyi-ui/src/store/modules/tagsView.js

+ 15 - 0
ruoyi-ui/src/layout/components/TagsView/index.vue

@@ -21,6 +21,7 @@
21 21
       <li @click="refreshSelectedTag(selectedTag)"><i class="el-icon-refresh-right"></i> 刷新页面</li>
22 22
       <li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)"><i class="el-icon-close"></i> 关闭当前</li>
23 23
       <li @click="closeOthersTags"><i class="el-icon-circle-close"></i> 关闭其他</li>
24
+      <li v-if="!isFirstView()" @click="closeLeftTags"><i class="el-icon-back"></i> 关闭左侧</li>
24 25
       <li v-if="!isLastView()" @click="closeRightTags"><i class="el-icon-right"></i> 关闭右侧</li>
25 26
       <li @click="closeAllTags(selectedTag)"><i class="el-icon-circle-close"></i> 全部关闭</li>
26 27
     </ul>
@@ -84,6 +85,13 @@ export default {
84 85
     isAffix(tag) {
85 86
       return tag.meta && tag.meta.affix
86 87
     },
88
+    isFirstView() {
89
+      try {
90
+        return this.selectedTag.fullPath === this.visitedViews[1].fullPath || this.selectedTag.fullPath === '/index'
91
+      } catch (err) {
92
+        return false
93
+      }
94
+    },
87 95
     isLastView() {
88 96
       try {
89 97
         return this.selectedTag.fullPath === this.visitedViews[this.visitedViews.length - 1].fullPath
@@ -167,6 +175,13 @@ export default {
167 175
         }
168 176
       })
169 177
     },
178
+    closeLeftTags() {
179
+      this.$store.dispatch('tagsView/delLeftTags', this.selectedTag).then(visitedViews => {
180
+        if (!visitedViews.find(i => i.fullPath === this.$route.fullPath)) {
181
+          this.toLastView(visitedViews)
182
+        }
183
+      })
184
+    },
170 185
     closeOthersTags() {
171 186
       this.$router.push(this.selectedTag).catch(()=>{});
172 187
       this.$store.dispatch('tagsView/delOthersViews', this.selectedTag).then(() => {

+ 25 - 1
ruoyi-ui/src/store/modules/tagsView.js

@@ -79,6 +79,23 @@ const mutations = {
79 79
       }
80 80
       return false
81 81
     })
82
+  },
83
+
84
+  DEL_LEFT_VIEWS: (state, view) => {
85
+    const index = state.visitedViews.findIndex(v => v.path === view.path)
86
+    if (index === -1) {
87
+      return
88
+    }
89
+    state.visitedViews = state.visitedViews.filter((item, idx) => {
90
+      if (idx >= index || (item.meta && item.meta.affix)) {
91
+        return true
92
+      }
93
+      const i = state.cachedViews.indexOf(item.name)
94
+      if (i > -1) {
95
+        state.cachedViews.splice(i, 1)
96
+      }
97
+      return false
98
+    })
82 99
   }
83 100
 }
84 101
 
@@ -172,7 +189,14 @@ const actions = {
172 189
       commit('DEL_RIGHT_VIEWS', view)
173 190
       resolve([...state.visitedViews])
174 191
     })
175
-  }
192
+  },
193
+
194
+  delLeftTags({ commit }, view) {
195
+    return new Promise(resolve => {
196
+      commit('DEL_LEFT_VIEWS', view)
197
+      resolve([...state.visitedViews])
198
+    })
199
+  },
176 200
 }
177 201
 
178 202
 export default {