From cd152eb6fd86b11617b9e1a9fbc04b55c46efc3a Mon Sep 17 00:00:00 2001 From: sc Date: Fri, 22 Jul 2022 15:27:19 +0800 Subject: [PATCH] =?UTF-8?q?UP=20=E8=B0=83=E6=95=B4=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E7=9A=84=E5=88=9B=E5=BB=BA=E5=92=8C=E7=A7=BB=E9=99=A4=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/components/tags.vue | 7 ++++--- src/store/modules/viewTags.js | 9 ++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/layout/components/tags.vue b/src/layout/components/tags.vue index 397a8803..d651e6f5 100644 --- a/src/layout/components/tags.vue +++ b/src/layout/components/tags.vue @@ -126,13 +126,14 @@ }, //关闭tag closeSelectedTag(tag, autoPushLatestView=true) { + const nowTagIndex = this.tagList.findIndex(item => item.fullPath == tag.fullPath) this.$store.commit("removeViewTags", tag) this.$store.commit("removeIframeList", tag) this.$store.commit("removeKeepLive", tag.name) if (autoPushLatestView && this.isActive(tag)) { - const latestView = this.tagList.slice(-1)[0] - if (latestView) { - this.$router.push(latestView) + const leftView = this.tagList[nowTagIndex - 1] + if (leftView) { + this.$router.push(leftView) } else { this.$router.push('/') } diff --git a/src/store/modules/viewTags.js b/src/store/modules/viewTags.js index b34f71e6..5946559a 100644 --- a/src/store/modules/viewTags.js +++ b/src/store/modules/viewTags.js @@ -1,13 +1,20 @@ +import router from '@/router' + export default { state: { viewTags: [] }, mutations: { pushViewTags(state, route){ + let backPathIndex = state.viewTags.findIndex(item => item.fullPath == router.options.history.state.back) let target = state.viewTags.find((item) => item.fullPath === route.fullPath) let isName = route.name if(!target && isName){ - state.viewTags.push(route) + if(backPathIndex == -1){ + state.viewTags.push(route) + }else{ + state.viewTags.splice(backPathIndex+1, 0, route) + } } }, removeViewTags(state, route){