From 0d3cae0ce57ac7f3265edf05be58ebd1d4c529a2 Mon Sep 17 00:00:00 2001 From: "DESKTOP-31IBRMI\\Administrator" <1509326266@qq.com> Date: Fri, 23 Aug 2024 10:35:38 +0800 Subject: [PATCH] fix(projects): repair tabcannot be modified --- src/store/slice/tab/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/store/slice/tab/index.ts b/src/store/slice/tab/index.ts index b3caecd..8ebc585 100644 --- a/src/store/slice/tab/index.ts +++ b/src/store/slice/tab/index.ts @@ -57,6 +57,7 @@ export const tabSlice = createSlice({ }, changeTabLabel(state, { payload }: PayloadAction<{ label?: string; index: number }>) { const { label, index } = payload; + if (label) { state.tabs[index].i18nKey = label; } else { @@ -303,9 +304,9 @@ export const setTabLabel = const activeTabId = getActiveTabId(getState()); const tabs = getTabs(getState()); const id = tabId || activeTabId; - const tab = tabs.findIndex(item => item.id === id); - if (!tab) return; + + if (tab < 0) return; dispatch(changeTabLabel({ label, index: tab })); }; @@ -323,7 +324,7 @@ export const resetTabLabel = const id = tabId || activeTabId; const tab = tabs.findIndex(item => item.id === id); - if (!tab) return; + if (tab < 0) return; dispatch(changeTabLabel({ index: tab })); };