mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-23 15:59:47 +00:00
Use index.json to load workflow templates (#2803)
This commit is contained in:
@@ -2,7 +2,6 @@ import { groupBy } from 'lodash'
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed, ref, shallowRef } from 'vue'
|
||||
|
||||
import { CORE_TEMPLATES } from '@/constants/coreTemplates'
|
||||
import { api } from '@/scripts/api'
|
||||
import type {
|
||||
TemplateGroup,
|
||||
@@ -13,12 +12,12 @@ export const useWorkflowTemplatesStore = defineStore(
|
||||
'workflowTemplates',
|
||||
() => {
|
||||
const customTemplates = shallowRef<{ [moduleName: string]: string[] }>({})
|
||||
const coreTemplates = shallowRef<WorkflowTemplates[]>([])
|
||||
const isLoaded = ref(false)
|
||||
const defaultTemplate: WorkflowTemplates = CORE_TEMPLATES[0]
|
||||
|
||||
const groupedTemplates = computed<TemplateGroup[]>(() => {
|
||||
const allTemplates = [
|
||||
...CORE_TEMPLATES,
|
||||
...coreTemplates.value,
|
||||
...Object.entries(customTemplates.value).map(
|
||||
([moduleName, templates]) => ({
|
||||
moduleName,
|
||||
@@ -44,6 +43,7 @@ export const useWorkflowTemplatesStore = defineStore(
|
||||
try {
|
||||
if (!isLoaded.value) {
|
||||
customTemplates.value = await api.getWorkflowTemplates()
|
||||
coreTemplates.value = await api.getCoreWorkflowTemplates()
|
||||
isLoaded.value = true
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -53,7 +53,6 @@ export const useWorkflowTemplatesStore = defineStore(
|
||||
|
||||
return {
|
||||
groupedTemplates,
|
||||
defaultTemplate,
|
||||
isLoaded,
|
||||
loadWorkflowTemplates
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user