From bcc9c30afc190eb6b9b0d783680b9c21621c6df7 Mon Sep 17 00:00:00 2001 From: zjt <937178071@qq.com> Date: Sat, 25 May 2024 22:21:50 +0800 Subject: [PATCH] get image --- src/biz/txt2img.ts | 10 ++++++++++ src/biz/upScale.ts | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/biz/txt2img.ts b/src/biz/txt2img.ts index a3d876b..c55182e 100644 --- a/src/biz/txt2img.ts +++ b/src/biz/txt2img.ts @@ -54,6 +54,16 @@ const Txt2ImgHandler: RequestHandler = async (ctx, next) => } if (data.node === '94') { console.log(data.output); + const filePath = './data.json'; + + readJSONFile(filePath) + .then((data: any) => { + console.log('读取的JSON数据:', data); + // 修改对象 + data.push({ prompt: prompt, url: baseUrl + '/view?filename=' + data.output.images[0].filename, like: 0, index: data.length }) + // 保存回JSON文件 + return saveJSONFile(filePath, data); + }) // 综合使用示例 resolve({ prompt: temp, url: baseUrl + '/view?filename=' + data.output.images[0].filename }); diff --git a/src/biz/upScale.ts b/src/biz/upScale.ts index 976f8ce..fbbede0 100644 --- a/src/biz/upScale.ts +++ b/src/biz/upScale.ts @@ -42,16 +42,6 @@ const UpscaleHandler: RequestHandler = async (ctx) => { if (type === "executed") { console.log(data.output); if (data.node === '47') { - const filePath = './data.json'; - - readJSONFile(filePath) - .then((data: any) => { - console.log('读取的JSON数据:', data); - // 修改对象 - data.push({ prompt: prompt, url: baseUrl + '/view?filename=' + data.output.images[0].filename, like: 0,index: data.length }) - // 保存回JSON文件 - return saveJSONFile(filePath, data); - }) resolve(data.output.images[0].filename) }