Skip to content

Commit

Permalink
fix(projects): repair tabcannot be modified
Browse files Browse the repository at this point in the history
  • Loading branch information
mufeng889 committed Aug 23, 2024
1 parent 7ced849 commit 0d3cae0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/store/slice/tab/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 }));
};
Expand All @@ -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 }));
};

0 comments on commit 0d3cae0

Please sign in to comment.