From 64bd119c299bdf648a505bf86df3445cc66ef1df Mon Sep 17 00:00:00 2001 From: AN <1983933789@qq.com> Date: Sun, 8 Jun 2025 22:49:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(utils):=20=E4=BF=AE=E5=A4=8D=20=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=BD=93=E5=89=8Dtab=E4=B8=BA=E6=9C=80=E5=90=8E?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E6=97=B6=EF=BC=8Ctab=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E9=94=99=E8=AF=AFbug.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/tab/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/store/modules/tab/index.ts b/src/store/modules/tab/index.ts index 78aaac69..61bf3afa 100644 --- a/src/store/modules/tab/index.ts +++ b/src/store/modules/tab/index.ts @@ -100,7 +100,12 @@ export const useTabStore = defineStore(SetupStoreId.Tab, () => { const removedTabRouteKey = tabs.value[removeTabIndex].routeKey; const isRemoveActiveTab = activeTabId.value === tabId; - const nextTab = tabs.value[removeTabIndex + 1] || homeTab.value; + + // if remove the last tab, then switch to the second last tab + const isLastTab = removeTabIndex === tabs.value.length - 1; + const nextTab = isLastTab + ? tabs.value[removeTabIndex - 1] || homeTab.value + : tabs.value[removeTabIndex + 1] || homeTab.value; // remove tab tabs.value.splice(removeTabIndex, 1);