mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-22 23:39:45 +00:00
Add command to switch opened workflow tabs (#1109)
This commit is contained in:
@@ -40,6 +40,28 @@ export const useWorkflowStore = defineStore('workflow', () => {
|
||||
buildTree(openWorkflows.value, (workflow: ComfyWorkflow) => [workflow.key])
|
||||
)
|
||||
|
||||
const loadOpenedWorkflowIndexShift = async (shift: number) => {
|
||||
const index = openWorkflows.value.indexOf(
|
||||
activeWorkflow.value as ComfyWorkflow
|
||||
)
|
||||
if (index !== -1) {
|
||||
const length = openWorkflows.value.length
|
||||
const nextIndex = (index + shift + length) % length
|
||||
const nextWorkflow = openWorkflows.value[nextIndex]
|
||||
if (nextWorkflow) {
|
||||
await nextWorkflow.load()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const loadNextOpenedWorkflow = async () => {
|
||||
await loadOpenedWorkflowIndexShift(1)
|
||||
}
|
||||
|
||||
const loadPreviousOpenedWorkflow = async () => {
|
||||
await loadOpenedWorkflowIndexShift(-1)
|
||||
}
|
||||
|
||||
return {
|
||||
activeWorkflow,
|
||||
workflows,
|
||||
@@ -50,7 +72,9 @@ export const useWorkflowStore = defineStore('workflow', () => {
|
||||
workflowsTree,
|
||||
bookmarkedWorkflowsTree,
|
||||
openWorkflowsTree,
|
||||
buildWorkflowTree
|
||||
buildWorkflowTree,
|
||||
loadNextOpenedWorkflow,
|
||||
loadPreviousOpenedWorkflow
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user