Add command to switch opened workflow tabs (#1109)

This commit is contained in:
Chenlei Hu
2024-10-04 20:33:16 -04:00
committed by GitHub
parent b30d285025
commit 6deb994235
2 changed files with 42 additions and 1 deletions

View File

@@ -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
}
})