UP 调整标签的创建和移除顺序

This commit is contained in:
sc 2022-07-22 15:27:19 +08:00
parent b6a882d664
commit cd152eb6fd
2 changed files with 12 additions and 4 deletions

View File

@ -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('/')
}

View File

@ -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){