mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-14 17:37:46 +00:00
Fix extension register tab with API (#229)
* Get rid of extension manager impl * nit * Test register tab
This commit is contained in:
@@ -1,32 +1,37 @@
|
||||
import { SidebarTabExtension } from '@/types/extensionTypes'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
interface WorkspaceState {
|
||||
activeSidebarTab: string | null
|
||||
sidebarTabsOrder: string[] // Array of tab IDs in order
|
||||
sidebarTabs: SidebarTabExtension[]
|
||||
}
|
||||
|
||||
export const useWorkspaceStore = defineStore('workspace', {
|
||||
state: (): WorkspaceState => ({
|
||||
activeSidebarTab: null,
|
||||
sidebarTabsOrder: []
|
||||
sidebarTabs: []
|
||||
}),
|
||||
actions: {
|
||||
updateActiveSidebarTab(tabId: string) {
|
||||
this.activeSidebarTab = tabId
|
||||
},
|
||||
updateSidebarOrder(newOrder: string[]) {
|
||||
this.sidebarTabsOrder = newOrder
|
||||
registerSidebarTab(tab: SidebarTabExtension) {
|
||||
this.sidebarTabs = [...this.sidebarTabs, tab]
|
||||
},
|
||||
serialize() {
|
||||
return JSON.stringify({
|
||||
activeSidebarTab: this.activeSidebarTab,
|
||||
sidebarTabsOrder: this.sidebarTabsOrder
|
||||
})
|
||||
unregisterSidebarTab(id: string) {
|
||||
const index = this.sidebarTabs.findIndex((tab) => tab.id === id)
|
||||
if (index !== -1) {
|
||||
const tab = this.sidebarTabs[index]
|
||||
if (tab.type === 'custom' && tab.destroy) {
|
||||
tab.destroy()
|
||||
}
|
||||
const newSidebarTabs = [...this.sidebarTabs]
|
||||
newSidebarTabs.splice(index, 1)
|
||||
this.sidebarTabs = newSidebarTabs
|
||||
}
|
||||
},
|
||||
deserialize(state: string) {
|
||||
const parsedState = JSON.parse(state)
|
||||
this.sidebarTabsOrder = parsedState.sidebarTabsOrder
|
||||
this.activeSidebarTab = parsedState.activeSidebarTab
|
||||
getSidebarTabs() {
|
||||
return [...this.sidebarTabs]
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user