fix:修复选项卡删除逻辑

This commit is contained in:
JaguarJack
2024-04-02 11:01:32 +08:00
parent de31bf23cd
commit 6de3edd4fc

View File

@@ -82,9 +82,15 @@ export const useNavTabStore = defineStore('nav_tabs', {
},
removeTab(index: number): void {
const goPath = this.tabs[index - 1].fullPath
const activeIndex = this.getActiveTabIndex()
if (index === activeIndex) {
this.tabs = this.tabs.filter((_, idx) => idx !== index);
router.push(this.tabs[index - 1].fullPath)
} else {
const goPath = activeIndex ? this.tabs[activeIndex].fullPath : this.tabs[index - 1].fullPath
this.tabs = this.tabs.filter((_, idx) => idx !== index);
router.push(goPath)
}
},