feat(TagsView): 快捷导航栏添加关闭左侧和右侧的标签
This commit is contained in:
@@ -210,7 +210,7 @@ function closeSelectedTag(view: TagView) {
|
||||
}
|
||||
|
||||
function closeLeftTags() {
|
||||
ctx.$tab.closeLeftPage(selectedTag.value).then(visitedViews => {
|
||||
tagsViewStoreHook().delLeftViews(selectedTag.value).then(({visitedViews}) => {
|
||||
if (!visitedViews.find(i => i.fullPath === route.fullPath)) {
|
||||
toLastView(visitedViews)
|
||||
}
|
||||
@@ -218,7 +218,7 @@ function closeLeftTags() {
|
||||
}
|
||||
|
||||
function closeRightTags() {
|
||||
ctx.$tab.closeRightPage(selectedTag.value).then(visitedViews => {
|
||||
tagsViewStoreHook().delRightViews(selectedTag.value).then(({visitedViews}) => {
|
||||
if (!visitedViews.find(i => i.fullPath === route.fullPath)) {
|
||||
toLastView(visitedViews)
|
||||
}
|
||||
|
||||
@@ -101,14 +101,49 @@ const tagsViewStore = defineStore({
|
||||
})
|
||||
},
|
||||
delLeftViews(view: any) {
|
||||
const currIndex = this.visitedViews.findIndex(v => v.path === view.path)
|
||||
if (currIndex === -1) {
|
||||
return
|
||||
}
|
||||
this.visitedViews = this.visitedViews.filter((item, index) => {
|
||||
if(index>=currIndex||(item.meta&&item.meta.affix)){
|
||||
return true
|
||||
return new Promise(resolve => {
|
||||
const currIndex = this.visitedViews.findIndex(v => v.path === view.path)
|
||||
if (currIndex === -1) {
|
||||
return
|
||||
}
|
||||
this.visitedViews = this.visitedViews.filter((item, index) => {
|
||||
// affix:true 固定tag,例如“首页”
|
||||
if (index >= currIndex || (item.meta && item.meta.affix)) {
|
||||
return true
|
||||
}
|
||||
|
||||
const cacheIndex = this.cachedViews.indexOf(item.name)
|
||||
if (cacheIndex > -1) {
|
||||
this.cachedViews.splice(cacheIndex, 1)
|
||||
}
|
||||
return false
|
||||
})
|
||||
resolve({
|
||||
visitedViews: [...this.visitedViews]
|
||||
})
|
||||
})
|
||||
},
|
||||
delRightViews(view: any) {
|
||||
return new Promise(resolve => {
|
||||
const currIndex = this.visitedViews.findIndex(v => v.path === view.path)
|
||||
if (currIndex === -1) {
|
||||
return
|
||||
}
|
||||
this.visitedViews = this.visitedViews.filter((item, index) => {
|
||||
// affix:true 固定tag,例如“首页”
|
||||
if (index <= currIndex || (item.meta && item.meta.affix)) {
|
||||
return true
|
||||
}
|
||||
|
||||
const cacheIndex = this.cachedViews.indexOf(item.name)
|
||||
if (cacheIndex > -1) {
|
||||
this.cachedViews.splice(cacheIndex, 1)
|
||||
}
|
||||
return false
|
||||
})
|
||||
resolve({
|
||||
visitedViews: [...this.visitedViews]
|
||||
})
|
||||
})
|
||||
},
|
||||
delAllViews(view: any) {
|
||||
|
||||
Reference in New Issue
Block a user