mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-13 19:20:37 +00:00
Compare commits
2 Commits
perf/test-
...
fetch-node
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da7df96a27 | ||
|
|
2591d39da3 |
97
src/extensions/core/apiNode.ts
Normal file
97
src/extensions/core/apiNode.ts
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
import { t } from '@/i18n'
|
||||||
|
import { api } from '@/scripts/api'
|
||||||
|
import { app } from '@/scripts/app'
|
||||||
|
import { useExtensionService } from '@/services/extensionService'
|
||||||
|
import { useToastStore } from '@/stores/toastStore'
|
||||||
|
|
||||||
|
useExtensionService().registerExtension({
|
||||||
|
name: 'Comfy.FetchApi',
|
||||||
|
|
||||||
|
async nodeCreated(node) {
|
||||||
|
if (node.constructor.comfyClass !== 'FetchApi') return
|
||||||
|
|
||||||
|
const onExecuted = node.onExecuted
|
||||||
|
const msg = t('toastMessages.unableToFetchFile')
|
||||||
|
|
||||||
|
const downloadFile = async (
|
||||||
|
typeValue: string,
|
||||||
|
subfolderValue: string,
|
||||||
|
filenameValue: string
|
||||||
|
) => {
|
||||||
|
try {
|
||||||
|
const params = [
|
||||||
|
'filename=' + encodeURIComponent(filenameValue),
|
||||||
|
'type=' + encodeURIComponent(typeValue),
|
||||||
|
'subfolder=' + encodeURIComponent(subfolderValue),
|
||||||
|
app.getRandParam().substring(1)
|
||||||
|
].join('&')
|
||||||
|
|
||||||
|
const fetchURL = `/view?${params}`
|
||||||
|
const response = await api.fetchApi(fetchURL)
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
console.error(response)
|
||||||
|
useToastStore().addAlert(msg)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const blob = await response.blob()
|
||||||
|
const downloadFilename = filenameValue
|
||||||
|
|
||||||
|
const url = window.URL.createObjectURL(blob)
|
||||||
|
const a = document.createElement('a')
|
||||||
|
a.style.display = 'none'
|
||||||
|
a.href = url
|
||||||
|
a.download = downloadFilename
|
||||||
|
|
||||||
|
document.body.appendChild(a)
|
||||||
|
a.click()
|
||||||
|
document.body.removeChild(a)
|
||||||
|
|
||||||
|
window.URL.revokeObjectURL(url)
|
||||||
|
|
||||||
|
return true
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
useToastStore().addAlert(msg)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const type = node.widgets?.find((w) => w.name === 'type')
|
||||||
|
const subfolder = node.widgets?.find((w) => w.name === 'subfolder')
|
||||||
|
const filename = node.widgets?.find((w) => w.name === 'filename')
|
||||||
|
|
||||||
|
node.onExecuted = function (message: any) {
|
||||||
|
onExecuted?.apply(this, arguments as any)
|
||||||
|
|
||||||
|
const typeInput = message.result[0]
|
||||||
|
const subfolderInput = message.result[1]
|
||||||
|
const filenameInput = message.result[2]
|
||||||
|
const autoDownload = node.widgets?.find((w) => w.name === 'auto_download')
|
||||||
|
|
||||||
|
if (type && subfolder && filename) {
|
||||||
|
type.value = typeInput
|
||||||
|
subfolder.value = subfolderInput
|
||||||
|
filename.value = filenameInput
|
||||||
|
|
||||||
|
if (autoDownload && autoDownload.value) {
|
||||||
|
downloadFile(typeInput, subfolderInput, filenameInput)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
node.addWidget('button', 'download', 'download', async () => {
|
||||||
|
if (type && subfolder && filename) {
|
||||||
|
await downloadFile(
|
||||||
|
type.value as string,
|
||||||
|
subfolder.value as string,
|
||||||
|
filename.value as string
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
console.error(msg)
|
||||||
|
useToastStore().addAlert(msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import './apiNode'
|
||||||
import './clipspace'
|
import './clipspace'
|
||||||
import './contextMenuFilter'
|
import './contextMenuFilter'
|
||||||
import './dynamicPrompts'
|
import './dynamicPrompts'
|
||||||
|
|||||||
@@ -1273,7 +1273,8 @@
|
|||||||
"failedToPurchaseCredits": "Failed to purchase credits: {error}",
|
"failedToPurchaseCredits": "Failed to purchase credits: {error}",
|
||||||
"unauthorizedDomain": "Your domain {domain} is not authorized to use this service. Please contact {email} to add your domain to the whitelist.",
|
"unauthorizedDomain": "Your domain {domain} is not authorized to use this service. Please contact {email} to add your domain to the whitelist.",
|
||||||
"useApiKeyTip": "Tip: Can't access normal login? Use the Comfy API Key option.",
|
"useApiKeyTip": "Tip: Can't access normal login? Use the Comfy API Key option.",
|
||||||
"nothingSelected": "Nothing selected"
|
"nothingSelected": "Nothing selected",
|
||||||
|
"unableToFetchFile": "Unable to fetch file"
|
||||||
},
|
},
|
||||||
"auth": {
|
"auth": {
|
||||||
"apiKey": {
|
"apiKey": {
|
||||||
|
|||||||
@@ -1359,6 +1359,7 @@
|
|||||||
"pendingTasksDeleted": "Tareas pendientes eliminadas",
|
"pendingTasksDeleted": "Tareas pendientes eliminadas",
|
||||||
"pleaseSelectNodesToGroup": "Por favor, seleccione los nodos (u otros grupos) para crear un grupo para",
|
"pleaseSelectNodesToGroup": "Por favor, seleccione los nodos (u otros grupos) para crear un grupo para",
|
||||||
"pleaseSelectOutputNodes": "Por favor, selecciona los nodos de salida",
|
"pleaseSelectOutputNodes": "Por favor, selecciona los nodos de salida",
|
||||||
|
"unableToFetchFile": "No se pudo obtener el archivo",
|
||||||
"unableToGetModelFilePath": "No se puede obtener la ruta del archivo del modelo",
|
"unableToGetModelFilePath": "No se puede obtener la ruta del archivo del modelo",
|
||||||
"unauthorizedDomain": "Tu dominio {domain} no está autorizado para usar este servicio. Por favor, contacta a {email} para agregar tu dominio a la lista blanca.",
|
"unauthorizedDomain": "Tu dominio {domain} no está autorizado para usar este servicio. Por favor, contacta a {email} para agregar tu dominio a la lista blanca.",
|
||||||
"updateRequested": "Actualización solicitada",
|
"updateRequested": "Actualización solicitada",
|
||||||
|
|||||||
@@ -1359,6 +1359,7 @@
|
|||||||
"pendingTasksDeleted": "Tâches en attente supprimées",
|
"pendingTasksDeleted": "Tâches en attente supprimées",
|
||||||
"pleaseSelectNodesToGroup": "Veuillez sélectionner les nœuds (ou autres groupes) pour créer un groupe pour",
|
"pleaseSelectNodesToGroup": "Veuillez sélectionner les nœuds (ou autres groupes) pour créer un groupe pour",
|
||||||
"pleaseSelectOutputNodes": "Veuillez sélectionner les nœuds de sortie",
|
"pleaseSelectOutputNodes": "Veuillez sélectionner les nœuds de sortie",
|
||||||
|
"unableToFetchFile": "Impossible de récupérer le fichier",
|
||||||
"unableToGetModelFilePath": "Impossible d'obtenir le chemin du fichier modèle",
|
"unableToGetModelFilePath": "Impossible d'obtenir le chemin du fichier modèle",
|
||||||
"unauthorizedDomain": "Votre domaine {domain} n'est pas autorisé à utiliser ce service. Veuillez contacter {email} pour ajouter votre domaine à la liste blanche.",
|
"unauthorizedDomain": "Votre domaine {domain} n'est pas autorisé à utiliser ce service. Veuillez contacter {email} pour ajouter votre domaine à la liste blanche.",
|
||||||
"updateRequested": "Mise à jour demandée",
|
"updateRequested": "Mise à jour demandée",
|
||||||
|
|||||||
@@ -1359,6 +1359,7 @@
|
|||||||
"pendingTasksDeleted": "保留中のタスクが削除されました",
|
"pendingTasksDeleted": "保留中のタスクが削除されました",
|
||||||
"pleaseSelectNodesToGroup": "グループを作成するためのノード(または他のグループ)を選択してください",
|
"pleaseSelectNodesToGroup": "グループを作成するためのノード(または他のグループ)を選択してください",
|
||||||
"pleaseSelectOutputNodes": "出力ノードを選択してください",
|
"pleaseSelectOutputNodes": "出力ノードを選択してください",
|
||||||
|
"unableToFetchFile": "ファイルを取得できません",
|
||||||
"unableToGetModelFilePath": "モデルファイルのパスを取得できません",
|
"unableToGetModelFilePath": "モデルファイルのパスを取得できません",
|
||||||
"unauthorizedDomain": "あなたのドメイン {domain} はこのサービスを利用する権限がありません。ご利用のドメインをホワイトリストに追加するには、{email} までご連絡ください。",
|
"unauthorizedDomain": "あなたのドメイン {domain} はこのサービスを利用する権限がありません。ご利用のドメインをホワイトリストに追加するには、{email} までご連絡ください。",
|
||||||
"updateRequested": "更新が要求されました",
|
"updateRequested": "更新が要求されました",
|
||||||
|
|||||||
@@ -1359,6 +1359,7 @@
|
|||||||
"pendingTasksDeleted": "보류 중인 작업이 삭제되었습니다",
|
"pendingTasksDeleted": "보류 중인 작업이 삭제되었습니다",
|
||||||
"pleaseSelectNodesToGroup": "그룹을 만들기 위해 노드(또는 다른 그룹)를 선택해 주세요",
|
"pleaseSelectNodesToGroup": "그룹을 만들기 위해 노드(또는 다른 그룹)를 선택해 주세요",
|
||||||
"pleaseSelectOutputNodes": "출력 노드를 선택해 주세요",
|
"pleaseSelectOutputNodes": "출력 노드를 선택해 주세요",
|
||||||
|
"unableToFetchFile": "파일을 가져올 수 없습니다",
|
||||||
"unableToGetModelFilePath": "모델 파일 경로를 가져올 수 없습니다",
|
"unableToGetModelFilePath": "모델 파일 경로를 가져올 수 없습니다",
|
||||||
"unauthorizedDomain": "귀하의 도메인 {domain}은(는) 이 서비스를 사용할 수 있는 권한이 없습니다. 도메인을 허용 목록에 추가하려면 {email}로 문의해 주세요.",
|
"unauthorizedDomain": "귀하의 도메인 {domain}은(는) 이 서비스를 사용할 수 있는 권한이 없습니다. 도메인을 허용 목록에 추가하려면 {email}로 문의해 주세요.",
|
||||||
"updateRequested": "업데이트 요청됨",
|
"updateRequested": "업데이트 요청됨",
|
||||||
|
|||||||
@@ -1359,6 +1359,7 @@
|
|||||||
"pendingTasksDeleted": "Ожидающие задачи удалены",
|
"pendingTasksDeleted": "Ожидающие задачи удалены",
|
||||||
"pleaseSelectNodesToGroup": "Пожалуйста, выберите узлы (или другие группы) для создания группы",
|
"pleaseSelectNodesToGroup": "Пожалуйста, выберите узлы (или другие группы) для создания группы",
|
||||||
"pleaseSelectOutputNodes": "Пожалуйста, выберите выходные узлы",
|
"pleaseSelectOutputNodes": "Пожалуйста, выберите выходные узлы",
|
||||||
|
"unableToFetchFile": "Не удалось получить файл",
|
||||||
"unableToGetModelFilePath": "Не удалось получить путь к файлу модели",
|
"unableToGetModelFilePath": "Не удалось получить путь к файлу модели",
|
||||||
"unauthorizedDomain": "Ваш домен {domain} не авторизован для использования этого сервиса. Пожалуйста, свяжитесь с {email}, чтобы добавить ваш домен в белый список.",
|
"unauthorizedDomain": "Ваш домен {domain} не авторизован для использования этого сервиса. Пожалуйста, свяжитесь с {email}, чтобы добавить ваш домен в белый список.",
|
||||||
"updateRequested": "Запрошено обновление",
|
"updateRequested": "Запрошено обновление",
|
||||||
|
|||||||
@@ -1359,6 +1359,7 @@
|
|||||||
"pendingTasksDeleted": "待处理任务已删除",
|
"pendingTasksDeleted": "待处理任务已删除",
|
||||||
"pleaseSelectNodesToGroup": "请选取节点(或其他组)以创建分组",
|
"pleaseSelectNodesToGroup": "请选取节点(或其他组)以创建分组",
|
||||||
"pleaseSelectOutputNodes": "请选择输出节点",
|
"pleaseSelectOutputNodes": "请选择输出节点",
|
||||||
|
"unableToFetchFile": "无法获取文件",
|
||||||
"unableToGetModelFilePath": "无法获取模型文件路径",
|
"unableToGetModelFilePath": "无法获取模型文件路径",
|
||||||
"unauthorizedDomain": "您的域名 {domain} 未被授权使用此服务。请联系 {email} 将您的域名添加到白名单。",
|
"unauthorizedDomain": "您的域名 {domain} 未被授权使用此服务。请联系 {email} 将您的域名添加到白名单。",
|
||||||
"updateRequested": "已请求更新",
|
"updateRequested": "已请求更新",
|
||||||
|
|||||||
Reference in New Issue
Block a user