From f60796f9614c84da61883cccd4e6a9bbb5464a21 Mon Sep 17 00:00:00 2001 From: pingsanddoss <33388958+pingsanddoss@users.noreply.github.com> Date: Tue, 22 Oct 2024 14:59:46 +0800 Subject: [PATCH] fix(@vben/tabs-ui): modified fixed and unfixed logic, fixed #4640 (#4709) * fix: modified fixed and unfixed logic, fixed #4640 * fix: modified fixed and unfixed logic, fixed #4640 --- packages/stores/src/modules/tabbar.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/stores/src/modules/tabbar.ts b/packages/stores/src/modules/tabbar.ts index f24d7907..e80e8740 100644 --- a/packages/stores/src/modules/tabbar.ts +++ b/packages/stores/src/modules/tabbar.ts @@ -312,6 +312,14 @@ export const useTabbarStore = defineStore('core-tabbar', { // this.addTab(tab); this.tabs.splice(index, 1, tab); } + // 过滤固定tabs,后面更改affixTabOrder的值的话可能会有问题,目前行464排序affixTabs没有设置值 + const affixTabs = this.tabs.filter((tab) => isAffixTab(tab)); + // 获得固定tabs的index + const newIndex = affixTabs.findIndex( + (item) => getTabPath(item) === getTabPath(tab), + ); + // 交换位置重新排序 + await this.sortTabs(index, newIndex); }, /** @@ -419,6 +427,12 @@ export const useTabbarStore = defineStore('core-tabbar', { // this.addTab(tab); this.tabs.splice(index, 1, tab); } + // 过滤固定tabs,后面更改affixTabOrder的值的话可能会有问题,目前行464排序affixTabs没有设置值 + const affixTabs = this.tabs.filter((tab) => isAffixTab(tab)); + // 获得固定tabs的index,使用固定tabs的下一个位置也就是活动tabs的第一个位置 + const newIndex = affixTabs.length; + // 交换位置重新排序 + await this.sortTabs(index, newIndex); }, /**