feat: add tab close menu actions (#24)

Co-authored-by: SuLe <sule@SuLedeMacBook-Air.local>
This commit is contained in:
SuLea-IT
2026-04-30 16:35:01 +08:00
committed by GitHub
co-authored by SuLe
parent 9ee31aa188
commit aea6bf3239
6 changed files with 133 additions and 22 deletions
+26
View File
@@ -0,0 +1,26 @@
export interface TabLike {
id: string;
}
export interface TabCloseState<T extends TabLike> {
tabs: T[];
activeTabId: string | null;
}
export function closeOtherTabsState<T extends TabLike>(
tabs: readonly T[],
activeTabId: string | null,
targetTabId: string,
): TabCloseState<T> {
const target = tabs.find((tab) => tab.id === targetTabId);
if (!target) return { tabs: [...tabs], activeTabId };
return { tabs: [target], activeTabId: target.id };
}
export function closeAllTabsState<T extends TabLike>(
_tabs: readonly T[],
_activeTabId: string | null,
): TabCloseState<T> {
return { tabs: [], activeTabId: null };
}