mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-19 01:17:00 +08:00
support load A1111 prompt from txt file, fix a bug if "Step:" is not first tag.
This commit is contained in:
parent
8e3d1cbf3b
commit
b83fe1ca8e
@ -1267,6 +1267,12 @@ export class ComfyApp {
|
||||
this.loadGraphData(JSON.parse(reader.result));
|
||||
};
|
||||
reader.readAsText(file);
|
||||
} else if (file.type === "text/plain" || file.name?.endsWith(".txt")) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
importA1111(this.graph, reader.result);
|
||||
};
|
||||
reader.readAsText(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -48,7 +48,10 @@ export function getPngMetadata(file) {
|
||||
}
|
||||
|
||||
export async function importA1111(graph, parameters) {
|
||||
const p = parameters.lastIndexOf("\nSteps:");
|
||||
var p = parameters.lastIndexOf("Steps:");
|
||||
if (p > -1) {
|
||||
p = parameters.substr(0, p).lastIndexOf("\n");
|
||||
}
|
||||
if (p > -1) {
|
||||
const embeddings = await api.getEmbeddings();
|
||||
const opts = parameters
|
||||
|
||||
@ -465,7 +465,7 @@ export class ComfyUI {
|
||||
const fileInput = $el("input", {
|
||||
id: "comfy-file-input",
|
||||
type: "file",
|
||||
accept: ".json,image/png",
|
||||
accept: ".json,.txt,image/png",
|
||||
style: { display: "none" },
|
||||
parent: document.body,
|
||||
onchange: () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user