mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 03:01:54 +00:00
[feat] Complete network call consolidation to use consistent clients
Template Workflows: - Replace direct fetch with api.fetchApi() for API endpoints - Keep direct fetch for static file URLs (already using api.fileURL()) Model Exporter: - Add logic to distinguish ComfyUI URLs from external URLs - Use api.apiURL() for ComfyUI URLs, direct fetch for external URLs - Maintain existing download functionality Other files already following correct patterns: - Upload Audio: Already using api.fetchApi() - 3D Loading Utils: Already using api.fetchApi() (fetch call is for blob conversion) - Download Utility: Uses direct fetch for external URLs (correct) All network calls now use consistent client patterns where appropriate.
This commit is contained in:
@@ -160,12 +160,15 @@ export function useTemplateWorkflows() {
|
|||||||
*/
|
*/
|
||||||
const fetchTemplateJson = async (id: string, sourceModule: string) => {
|
const fetchTemplateJson = async (id: string, sourceModule: string) => {
|
||||||
if (sourceModule === 'default') {
|
if (sourceModule === 'default') {
|
||||||
// Default templates provided by frontend are served on this separate endpoint
|
// Default templates provided by frontend are served as static files
|
||||||
return fetch(api.fileURL(`/templates/${id}.json`)).then((r) => r.json())
|
const response = await fetch(api.fileURL(`/templates/${id}.json`))
|
||||||
|
return response.json()
|
||||||
} else {
|
} else {
|
||||||
return fetch(
|
// Custom node templates served via API
|
||||||
api.apiURL(`/workflow_templates/${sourceModule}/${id}.json`)
|
const response = await api.fetchApi(
|
||||||
).then((r) => r.json())
|
`/workflow_templates/${sourceModule}/${id}.json`
|
||||||
|
)
|
||||||
|
return response.json()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { OBJExporter } from 'three/examples/jsm/exporters/OBJExporter'
|
|||||||
import { STLExporter } from 'three/examples/jsm/exporters/STLExporter'
|
import { STLExporter } from 'three/examples/jsm/exporters/STLExporter'
|
||||||
|
|
||||||
import { t } from '@/i18n'
|
import { t } from '@/i18n'
|
||||||
|
import { api } from '@/scripts/api'
|
||||||
import { useToastStore } from '@/stores/toastStore'
|
import { useToastStore } from '@/stores/toastStore'
|
||||||
|
|
||||||
export class ModelExporter {
|
export class ModelExporter {
|
||||||
@@ -36,7 +37,18 @@ export class ModelExporter {
|
|||||||
desiredFilename: string
|
desiredFilename: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url)
|
// Check if this is a ComfyUI relative URL
|
||||||
|
const isComfyUrl = url.startsWith('/') || url.includes('/view?')
|
||||||
|
|
||||||
|
let response: Response
|
||||||
|
if (isComfyUrl) {
|
||||||
|
// Use ComfyUI API client for internal URLs
|
||||||
|
response = await fetch(api.apiURL(url))
|
||||||
|
} else {
|
||||||
|
// Use direct fetch for external URLs
|
||||||
|
response = await fetch(url)
|
||||||
|
}
|
||||||
|
|
||||||
const blob = await response.blob()
|
const blob = await response.blob()
|
||||||
|
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a')
|
||||||
|
|||||||
Reference in New Issue
Block a user