Skip to content

Commit

Permalink
[fix] Fix the issue where the “Civitai resources” field cannot be par…
Browse files Browse the repository at this point in the history
…sed in the image of A1111
  • Loading branch information
hbl917070 committed Nov 10, 2023
1 parent 30883b6 commit 03afe05
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
9 changes: 5 additions & 4 deletions Www/ts/Lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,6 @@ class Lib {
domBox.setAttribute("open", "true");
funcChange("true");
}


}


Expand Down Expand Up @@ -575,7 +573,10 @@ class Lib {
if (typeof str === "object") {
jsonFormat = JSON.stringify(str, null, space);
ok = true;
} else if (str.startsWith('{') && str.endsWith('}')) {
} else if (
(str.startsWith('{') && str.endsWith('}'))
|| (str.startsWith('[') && str.endsWith(']'))
) {
try {
json = JSON.parse(str);
jsonFormat = JSON.stringify(json, null, space);
Expand Down Expand Up @@ -666,4 +667,4 @@ class Throttle {
this.timer(); //遞迴
}, this.timeout);
}
}
}
59 changes: 29 additions & 30 deletions Www/ts/MainWindow/AiDrawingPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,28 @@ class AiDrawingPrompt {
let stack = [];
let partStart = 0;
for (let i = 0; i < input.length; i++) {
if (input[i] === '{') {
if (input[i] === '[') {
stack.push('[');
} else if (input[i] === ']') {
if (stack.length > 0 && stack[stack.length - 1] === '[') {
stack.pop();
}
}
else if (input[i] === '{') {
stack.push('{');
} else if (input[i] === '}') {
if (stack.length > 0 && stack[stack.length - 1] === '{') {
stack.pop();
}
} else if (input[i] === '"') {
}
else if (input[i] === '"') {
if (stack.length > 0 && stack[stack.length - 1] === '"') {
stack.pop();
} else {
stack.push('"');
}
} else if (input[i] === ',' && stack.length === 0) {
}
else if (input[i] === ',' && stack.length === 0) {
parts.push(input.slice(partStart, i));
partStart = i + 1;
}
Expand Down Expand Up @@ -106,12 +115,10 @@ class AiDrawingPrompt {

function retPush(title: string, text: string | undefined) {
if (text !== undefined && text !== "") {
retData.push(
{
title: title,
text: text
}
);
retData.push({
title: title,
text: text
});
}
}

Expand Down Expand Up @@ -164,12 +171,10 @@ class AiDrawingPrompt {

function retPush(title: string, text: string | undefined) {
if (text !== undefined && text !== null && text !== "") {
retData.push(
{
title: title,
text: text.toString().trim()
}
);
retData.push({
title: title,
text: text.toString().trim()
});
}
}
function getKey(obj: any) {
Expand Down Expand Up @@ -351,12 +356,10 @@ class AiDrawingPrompt {

function retPush(title: string, text: string | undefined) {
if (text !== undefined && text !== null && text !== "") {
retData.push(
{
title: title,
text: text.toString().trim()
}
);
retData.push({
title: title,
text: text.toString().trim()
});
}
}

Expand All @@ -380,9 +383,7 @@ class AiDrawingPrompt {
retPush(title, text);
}


if (objImage !== undefined) {

let prompt = objImage.prompt[0].prompt;
let seed = objImage.seed;
let steps = objImage.steps;
Expand Down Expand Up @@ -417,12 +418,10 @@ class AiDrawingPrompt {

function retPush(title: string, text: string | undefined) {
if (text !== undefined && text !== null && text !== "") {
retData.push(
{
title: title,
text: text.toString().trim()
}
);
retData.push({
title: title,
text: text.toString().trim()
});
}
}

Expand All @@ -439,4 +438,4 @@ class AiDrawingPrompt {

return retData;
}
}
}

0 comments on commit 03afe05

Please sign in to comment.