Add ComfyUI Examples workflows to in-app templates (#2541)

Co-authored-by: jojodecayz <121620462+jojodecayz@users.noreply.github.com>
Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
bymyself
2025-02-15 14:15:56 -07:00
committed by GitHub
parent 00dceb880a
commit 77d3e0c45e
54 changed files with 21677 additions and 1160 deletions

View File

@@ -1,20 +1,48 @@
import { groupBy } from 'lodash'
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { computed, ref, shallowRef } from 'vue'
import { CORE_TEMPLATES } from '@/constants/coreTemplates'
import { api } from '@/scripts/api'
import type {
TemplateGroup,
WorkflowTemplates
} from '@/types/workflowTemplateTypes'
export const useWorkflowTemplatesStore = defineStore(
'workflowTemplates',
() => {
const items = ref<{
[customNodesName: string]: string[]
}>({})
const customTemplates = shallowRef<{ [moduleName: string]: string[] }>({})
const isLoaded = ref(false)
const defaultTemplate: WorkflowTemplates = CORE_TEMPLATES[0]
const groupedTemplates = computed<TemplateGroup[]>(() => {
const allTemplates = [
...CORE_TEMPLATES,
...Object.entries(customTemplates.value).map(
([moduleName, templates]) => ({
moduleName,
title: moduleName,
templates: templates.map((name) => ({
name,
mediaType: 'image',
mediaSubtype: 'jpg'
}))
})
)
]
return Object.entries(
groupBy(allTemplates, (t) =>
t.moduleName === 'default' ? 'ComfyUI Examples' : 'Custom Nodes'
)
).map(([label, modules]) => ({ label, modules }))
})
async function loadWorkflowTemplates() {
try {
if (!isLoaded.value) {
items.value = await api.getWorkflowTemplates()
customTemplates.value = await api.getWorkflowTemplates()
isLoaded.value = true
}
} catch (error) {
@@ -23,7 +51,8 @@ export const useWorkflowTemplatesStore = defineStore(
}
return {
items,
groupedTemplates,
defaultTemplate,
isLoaded,
loadWorkflowTemplates
}