mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-08 09:00:05 +00:00
feat: Implement workflow template selector dialog and enhance template filtering options
This commit is contained in:
@@ -597,11 +597,28 @@ export class ComfyApi extends EventTarget {
|
||||
|
||||
/**
|
||||
* Gets the index of core workflow templates.
|
||||
* @param locale Optional locale code (e.g., 'en', 'fr', 'zh') to load localized templates
|
||||
*/
|
||||
async getCoreWorkflowTemplates(): Promise<WorkflowTemplates[]> {
|
||||
const res = await axios.get(this.fileURL('/templates/index.json'))
|
||||
const contentType = res.headers['content-type']
|
||||
return contentType?.includes('application/json') ? res.data : []
|
||||
async getCoreWorkflowTemplates(
|
||||
locale?: string
|
||||
): Promise<WorkflowTemplates[]> {
|
||||
const fileName =
|
||||
locale && locale !== 'en' ? `index.${locale}.json` : 'index.json'
|
||||
try {
|
||||
const res = await axios.get(this.fileURL(`/templates/${fileName}`))
|
||||
const contentType = res.headers['content-type']
|
||||
return contentType?.includes('application/json') ? res.data : []
|
||||
} catch (error) {
|
||||
// Fallback to default English version if localized version doesn't exist
|
||||
if (locale && locale !== 'en') {
|
||||
console.warn(
|
||||
`Localized templates for '${locale}' not found, falling back to English`
|
||||
)
|
||||
return this.getCoreWorkflowTemplates('en')
|
||||
}
|
||||
console.error('Error loading core workflow templates:', error)
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user