Workflow saving/loading

This commit is contained in:
space-nuko
2023-05-06 21:39:21 -05:00
parent 2a2d04803b
commit da65d1b439
6 changed files with 78 additions and 18 deletions

View File

@@ -404,7 +404,7 @@ export default class ComfyApp {
}
}
reset() {
clear() {
this.clean();
const blankGraph: SerializedLGraph = {
@@ -634,16 +634,21 @@ export default class ComfyApp {
if (file.type === "image/png") {
const pngInfo = await getPngMetadata(file);
if (pngInfo) {
if (pngInfo.workflow) {
this.loadGraphData(JSON.parse(pngInfo.workflow));
if (pngInfo.comfyBoxConfig) {
this.deserialize(JSON.parse(pngInfo.comfyBoxConfig));
} else if (pngInfo.parameters) {
importA1111(this.lGraph, pngInfo.parameters, this.api);
throw "TODO import A111 import!"
// importA1111(this.lGraph, pngInfo.parameters, this.api);
}
else {
console.error("No metadata found in image file.", pngInfo)
toast.push("No metadata found in image file.")
}
}
} else if (file.type === "application/json" || file.name.endsWith(".json")) {
const reader = new FileReader();
reader.onload = () => {
this.loadGraphData(JSON.parse(reader.result as string));
this.deserialize(JSON.parse(reader.result as string));
};
reader.readAsText(file);
}