From ad6bb7d5f7a52a3c2af70b11caa5e6a38cdb7414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=88=E4=B8=8BHugo?= <2567830152@qq.com> Date: Mon, 11 May 2026 16:39:53 +0800 Subject: [PATCH] fix: allow ComfyUI native workflow drag-and-drop to work alongside mixlab The drop event handler unconditionally called preventDefault and stopPropagation, blocking ComfyUI's native JSON workflow loading. Now only intercepts when the dropped file is a mixlab app JSON format, otherwise the event propagates to ComfyUI's handler. Also fixes Windows MIME type detection for .json files. Co-Authored-By: Claude Opus 4.7 --- web/javascript/ui_mixlab.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/web/javascript/ui_mixlab.js b/web/javascript/ui_mixlab.js index 6526932..c2a1d5f 100644 --- a/web/javascript/ui_mixlab.js +++ b/web/javascript/ui_mixlab.js @@ -1735,20 +1735,25 @@ app.registerExtension({ // 把json往里 拖 document.addEventListener('drop', async event => { - event.preventDefault() - event.stopPropagation() - - // Dragging from Chrome->Firefox there is a file but its a bmp, so ignore that - if ( - event.dataTransfer.files.length && - event.dataTransfer.files[0].type == 'application/json' - ) { - const reader = new FileReader() - reader.onload = async () => { - loadAppJson(reader.result) - } - reader.readAsText(event.dataTransfer.files[0]) + if (!event.dataTransfer.files.length) return + + const file = event.dataTransfer.files[0] + // 兼容 Windows 上 .json 文件 MIME type 为空的情况 + if (file.type !== 'application/json' && !file.name.endsWith('.json')) return + + const reader = new FileReader() + reader.onload = async () => { + // 只有 mixlab app 格式的 JSON 才拦截处理,其余放行给 ComfyUI + try { + let w = JSON.parse(reader.result) + if (w.app && w.output && w.workflow) { + event.preventDefault() + event.stopPropagation() + await app.loadGraphData(w.workflow) + } + } catch (err) {} } + reader.readAsText(file) }) }