mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-24 00:34:09 +00:00
* Refactor command store * Rename coreMenuStore to menuStore * Extension API to register command * Update README * Add playwright test
56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import type { SidebarTabExtension, ToastManager } from '@/types/extensionTypes'
|
|
import { defineStore } from 'pinia'
|
|
import { useToastStore } from './toastStore'
|
|
import { useQueueSettingsStore } from './queueStore'
|
|
import { useMenuItemStore } from './menuItemStore'
|
|
|
|
interface WorkspaceState {
|
|
spinner: boolean
|
|
activeSidebarTab: string | null
|
|
sidebarTabs: SidebarTabExtension[]
|
|
}
|
|
|
|
export const useWorkspaceStore = defineStore('workspace', {
|
|
state: (): WorkspaceState => ({
|
|
spinner: false,
|
|
activeSidebarTab: null,
|
|
sidebarTabs: []
|
|
}),
|
|
getters: {
|
|
toast(): ToastManager {
|
|
return useToastStore()
|
|
},
|
|
queueSettings() {
|
|
return useQueueSettingsStore()
|
|
},
|
|
menu() {
|
|
return {
|
|
registerTopbarCommands: useMenuItemStore().registerCommands
|
|
}
|
|
}
|
|
},
|
|
actions: {
|
|
updateActiveSidebarTab(tabId: string) {
|
|
this.activeSidebarTab = tabId
|
|
},
|
|
registerSidebarTab(tab: SidebarTabExtension) {
|
|
this.sidebarTabs = [...this.sidebarTabs, tab]
|
|
},
|
|
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
|
|
}
|
|
},
|
|
getSidebarTabs() {
|
|
return [...this.sidebarTabs]
|
|
}
|
|
}
|
|
})
|