UP 调整标签的创建和移除顺序
This commit is contained in:
parent
b6a882d664
commit
cd152eb6fd
|
@ -126,13 +126,14 @@
|
||||||
},
|
},
|
||||||
//关闭tag
|
//关闭tag
|
||||||
closeSelectedTag(tag, autoPushLatestView=true) {
|
closeSelectedTag(tag, autoPushLatestView=true) {
|
||||||
|
const nowTagIndex = this.tagList.findIndex(item => item.fullPath == tag.fullPath)
|
||||||
this.$store.commit("removeViewTags", tag)
|
this.$store.commit("removeViewTags", tag)
|
||||||
this.$store.commit("removeIframeList", tag)
|
this.$store.commit("removeIframeList", tag)
|
||||||
this.$store.commit("removeKeepLive", tag.name)
|
this.$store.commit("removeKeepLive", tag.name)
|
||||||
if (autoPushLatestView && this.isActive(tag)) {
|
if (autoPushLatestView && this.isActive(tag)) {
|
||||||
const latestView = this.tagList.slice(-1)[0]
|
const leftView = this.tagList[nowTagIndex - 1]
|
||||||
if (latestView) {
|
if (leftView) {
|
||||||
this.$router.push(latestView)
|
this.$router.push(leftView)
|
||||||
} else {
|
} else {
|
||||||
this.$router.push('/')
|
this.$router.push('/')
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,20 @@
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
state: {
|
state: {
|
||||||
viewTags: []
|
viewTags: []
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
pushViewTags(state, route){
|
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 target = state.viewTags.find((item) => item.fullPath === route.fullPath)
|
||||||
let isName = route.name
|
let isName = route.name
|
||||||
if(!target && isName){
|
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){
|
removeViewTags(state, route){
|
||||||
|
|
Loading…
Reference in New Issue