mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 10:59:53 +00:00
* [refactor] move workflow domain to its own folder * [refactor] Fix workflow platform architecture organization - Move workflow rendering functionality to renderer/thumbnail domain - Rename ui folder to management for better semantic clarity - Update all import paths to reflect proper domain boundaries - Fix test imports to use new structure Architecture improvements: - rendering → renderer/thumbnail (belongs with other rendering logic) - ui → management (better name for state management and UI integration) This ensures proper separation of concerns and domain boundaries. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * [fix] Resolve circular dependency between nodeDefStore and subgraphStore * [fix] Update browser test imports to use new workflow platform paths --------- Co-authored-by: Claude <noreply@anthropic.com>
126 lines
3.8 KiB
TypeScript
126 lines
3.8 KiB
TypeScript
import { defineStore } from 'pinia'
|
|
import { computed, ref } from 'vue'
|
|
|
|
import { useModelLibrarySidebarTab } from '@/composables/sidebarTabs/useModelLibrarySidebarTab'
|
|
import { useNodeLibrarySidebarTab } from '@/composables/sidebarTabs/useNodeLibrarySidebarTab'
|
|
import { useQueueSidebarTab } from '@/composables/sidebarTabs/useQueueSidebarTab'
|
|
import { t, te } from '@/i18n'
|
|
import { useWorkflowsSidebarTab } from '@/platform/workflow/management/composables/useWorkflowsSidebarTab'
|
|
import { useCommandStore } from '@/stores/commandStore'
|
|
import { useMenuItemStore } from '@/stores/menuItemStore'
|
|
import { SidebarTabExtension } from '@/types/extensionTypes'
|
|
|
|
export const useSidebarTabStore = defineStore('sidebarTab', () => {
|
|
const sidebarTabs = ref<SidebarTabExtension[]>([])
|
|
const activeSidebarTabId = ref<string | null>(null)
|
|
|
|
const activeSidebarTab = computed<SidebarTabExtension | null>(() => {
|
|
return (
|
|
sidebarTabs.value.find((tab) => tab.id === activeSidebarTabId.value) ??
|
|
null
|
|
)
|
|
})
|
|
|
|
const toggleSidebarTab = (tabId: string) => {
|
|
activeSidebarTabId.value = activeSidebarTabId.value === tabId ? null : tabId
|
|
}
|
|
|
|
const registerSidebarTab = (tab: SidebarTabExtension) => {
|
|
sidebarTabs.value = [...sidebarTabs.value, tab]
|
|
|
|
// Generate label in format "Toggle X Sidebar"
|
|
const labelFunction = () => {
|
|
const tabTitle = te(tab.title) ? t(tab.title) : tab.title
|
|
return `Toggle ${tabTitle} Sidebar`
|
|
}
|
|
const tooltipFunction = tab.tooltip
|
|
? te(String(tab.tooltip))
|
|
? () => t(String(tab.tooltip))
|
|
: String(tab.tooltip)
|
|
: undefined
|
|
|
|
const menubarLabelFunction = () => {
|
|
const menubarLabelKeys: Record<string, string> = {
|
|
queue: 'menu.queue',
|
|
'node-library': 'sideToolbar.nodeLibrary',
|
|
'model-library': 'sideToolbar.modelLibrary',
|
|
workflows: 'sideToolbar.workflows'
|
|
}
|
|
|
|
const key = menubarLabelKeys[tab.id]
|
|
if (key && te(key)) {
|
|
return t(key)
|
|
}
|
|
|
|
return tab.title
|
|
}
|
|
|
|
useCommandStore().registerCommand({
|
|
id: `Workspace.ToggleSidebarTab.${tab.id}`,
|
|
icon: typeof tab.icon === 'string' ? tab.icon : undefined,
|
|
label: labelFunction,
|
|
menubarLabel: menubarLabelFunction,
|
|
tooltip: tooltipFunction,
|
|
versionAdded: '1.3.9',
|
|
category: 'view-controls' as const,
|
|
function: () => {
|
|
toggleSidebarTab(tab.id)
|
|
},
|
|
active: () => activeSidebarTab.value?.id === tab.id,
|
|
source: 'System'
|
|
})
|
|
}
|
|
|
|
const unregisterSidebarTab = (id: string) => {
|
|
const index = sidebarTabs.value.findIndex((tab) => tab.id === id)
|
|
if (index !== -1) {
|
|
const tab = sidebarTabs.value[index]
|
|
if (tab.type === 'custom' && tab.destroy) {
|
|
tab.destroy()
|
|
}
|
|
const newSidebarTabs = [...sidebarTabs.value]
|
|
newSidebarTabs.splice(index, 1)
|
|
sidebarTabs.value = newSidebarTabs
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Register the core sidebar tabs.
|
|
*/
|
|
const registerCoreSidebarTabs = () => {
|
|
registerSidebarTab(useQueueSidebarTab())
|
|
registerSidebarTab(useNodeLibrarySidebarTab())
|
|
registerSidebarTab(useModelLibrarySidebarTab())
|
|
registerSidebarTab(useWorkflowsSidebarTab())
|
|
|
|
const menuStore = useMenuItemStore()
|
|
|
|
menuStore.registerCommands(
|
|
['View'],
|
|
[
|
|
'Workspace.ToggleBottomPanel',
|
|
'Comfy.BrowseTemplates',
|
|
'Workspace.ToggleFocusMode',
|
|
'Comfy.ToggleCanvasInfo',
|
|
'Comfy.Canvas.ToggleMinimap',
|
|
'Comfy.Canvas.ToggleLinkVisibility'
|
|
]
|
|
)
|
|
|
|
menuStore.registerCommands(
|
|
['View'],
|
|
['Comfy.Canvas.ZoomIn', 'Comfy.Canvas.ZoomOut', 'Comfy.Canvas.FitView']
|
|
)
|
|
}
|
|
|
|
return {
|
|
sidebarTabs,
|
|
activeSidebarTabId,
|
|
activeSidebarTab,
|
|
toggleSidebarTab,
|
|
registerSidebarTab,
|
|
unregisterSidebarTab,
|
|
registerCoreSidebarTabs
|
|
}
|
|
})
|