UP 调整标签的创建和移除顺序
This commit is contained in:
parent
b6a882d664
commit
cd152eb6fd
|
@ -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('/')
|
||||
}
|
||||
|
|
|
@ -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){
|
||||
|
|
Loading…
Reference in New Issue