Browse Source

Merge branch 'image-cache' of https://github.com/jn-jairo/ComfyUI

pull/2162/head
comfyanonymous 12 months ago
parent
commit
88e2c9746b
  1. 4
      web/extensions/core/maskeditor.js
  2. 6
      web/scripts/app.js
  3. 2
      web/scripts/widgets.js

4
web/extensions/core/maskeditor.js

@ -42,7 +42,7 @@ async function uploadMask(filepath, formData) {
}); });
ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']] = new Image(); ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']] = new Image();
ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']].src = api.apiURL("/view?" + new URLSearchParams(filepath).toString() + app.getPreviewFormatParam()); ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']].src = api.apiURL("/view?" + new URLSearchParams(filepath).toString() + app.getPreviewFormatParam() + app.getRandParam());
if(ComfyApp.clipspace.images) if(ComfyApp.clipspace.images)
ComfyApp.clipspace.images[ComfyApp.clipspace['selectedIndex']] = filepath; ComfyApp.clipspace.images[ComfyApp.clipspace['selectedIndex']] = filepath;
@ -657,4 +657,4 @@ app.registerExtension({
const context_predicate = () => ComfyApp.clipspace && ComfyApp.clipspace.imgs && ComfyApp.clipspace.imgs.length > 0 const context_predicate = () => ComfyApp.clipspace && ComfyApp.clipspace.imgs && ComfyApp.clipspace.imgs.length > 0
ClipspaceDialog.registerButton("MaskEditor", context_predicate, ComfyApp.open_maskeditor); ClipspaceDialog.registerButton("MaskEditor", context_predicate, ComfyApp.open_maskeditor);
} }
}); });

6
web/scripts/app.js

@ -86,6 +86,10 @@ export class ComfyApp {
return ""; return "";
} }
getRandParam() {
return "&rand=" + Math.random();
}
static isImageNode(node) { static isImageNode(node) {
return node.imgs || (node && node.widgets && node.widgets.findIndex(obj => obj.name === 'image') >= 0); return node.imgs || (node && node.widgets && node.widgets.findIndex(obj => obj.name === 'image') >= 0);
} }
@ -437,7 +441,7 @@ export class ComfyApp {
return api.apiURL( return api.apiURL(
"/view?" + "/view?" +
new URLSearchParams(params).toString() + new URLSearchParams(params).toString() +
(this.animatedImages ? "" : app.getPreviewFormatParam()) (this.animatedImages ? "" : app.getPreviewFormatParam()) + app.getRandParam()
); );
}) })
); );

2
web/scripts/widgets.js

@ -310,7 +310,7 @@ export const ComfyWidgets = {
subfolder = name.substring(0, folder_separator); subfolder = name.substring(0, folder_separator);
name = name.substring(folder_separator + 1); name = name.substring(folder_separator + 1);
} }
img.src = api.apiURL(`/view?filename=${encodeURIComponent(name)}&type=input&subfolder=${subfolder}${app.getPreviewFormatParam()}`); img.src = api.apiURL(`/view?filename=${encodeURIComponent(name)}&type=input&subfolder=${subfolder}${app.getPreviewFormatParam()}${app.getRandParam()}`);
node.setSizeForImage?.(); node.setSizeForImage?.();
} }

Loading…
Cancel
Save