mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 10:42:44 +00:00
Sidebar tab API for extensions (#215)
* Add extensionManager to manage tabs * Fix null bug * nit
This commit is contained in:
32
src/stores/workspaceStateStore.ts
Normal file
32
src/stores/workspaceStateStore.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
interface WorkspaceState {
|
||||
activeSidebarTab: string | null;
|
||||
sidebarTabsOrder: string[]; // Array of tab IDs in order
|
||||
}
|
||||
|
||||
export const useWorkspaceStore = defineStore("workspace", {
|
||||
state: (): WorkspaceState => ({
|
||||
activeSidebarTab: null,
|
||||
sidebarTabsOrder: [],
|
||||
}),
|
||||
actions: {
|
||||
updateActiveSidebarTab(tabId: string) {
|
||||
this.activeSidebarTab = tabId;
|
||||
},
|
||||
updateSidebarOrder(newOrder: string[]) {
|
||||
this.sidebarTabsOrder = newOrder;
|
||||
},
|
||||
serialize() {
|
||||
return JSON.stringify({
|
||||
activeSidebarTab: this.activeSidebarTab,
|
||||
sidebarTabsOrder: this.sidebarTabsOrder,
|
||||
});
|
||||
},
|
||||
deserialize(state: string) {
|
||||
const parsedState = JSON.parse(state);
|
||||
this.sidebarTabsOrder = parsedState.sidebarTabsOrder;
|
||||
this.activeSidebarTab = parsedState.activeSidebarTab;
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user