V2.2.4 版本

This commit is contained in:
2024-05-24 13:46:19 +08:00
parent 74009113fa
commit 17709c1a0b
57 changed files with 4484 additions and 2338 deletions
+2
View File
@@ -15,6 +15,7 @@ if (!app.isPackaged) {
scripts_path: path.join(__dirname, "../../resources/scripts"),
package_path: path.join(__dirname, "../../resources/package"),
image_path: path.join(__dirname, "../../resources/image"),
temp_sd_image: path.join(__dirname, "../../resources/image/TempSDImage"),
draft_temp_path: path.join(__dirname, "../../resources/tmp/temp.zip"),
clip_speed_temp_path: path.join(__dirname, "../../resources/tmp/Clip/speeds_tmp.json"),
add_canvases_temp_path: path.join(__dirname, "../../resources/tmp/Clip/canvases_tmp.json"),
@@ -45,6 +46,7 @@ if (!app.isPackaged) {
package_path: path.join(__dirname, "../../../resources/package"),
discordScript: path.join(__dirname, "../../../resources/scripts/discordScript.js"),
image_path: path.join(__dirname, "../../../resources/image"),
temp_sd_image: path.join(__dirname, "../../../resources/image/TempSDImage"),
draft_temp_path: path.join(__dirname, "../../../resources/tmp/temp.zip"),
clip_speed_temp_path: path.join(__dirname, "../../../resources/tmp/Clip/speeds_tmp.json"),
add_canvases_temp_path: path.join(__dirname, "../../../resources/tmp/Clip/canvases_tmp.json"),
+5
View File
@@ -1,4 +1,5 @@
export const DEFINE_STRING = {
GET_FILE_BASE64: "GET_FILE_BASE64",
SAVE_DEFINE_CONFIG_JSON_BY_PROPERTY: "SAVE_DEFINE_CONFIG_JSON_BY_PROPERTY",
GET_DEFINE_CONFIG_JSON_BY_PROPERTY: "GET_DEFINE_CONFIG_JSON_BY_PROPERTY",
GET_IMAGE_GENERATE_CATEGORY: "GET_IMAGE_GENERATE_CATEGORY",
@@ -134,6 +135,10 @@ export const DEFINE_STRING = {
NORMAL_PERMISSION: "NORMAL_PERMISSION",
AUTO_SAVE_IMAGE_PERMISSION: "AUTO_SAVE_IMAGE_PERMISSION",
},
SD: {
LOAD_SD_SERVICE_DATA: "LOAD_SD_SERVICE_DATA",
TXT2IMG: "TXT2IMG",
},
MJ: {
SAVE_WORD_SRT: "SAVE_WORD_SRT",
GET_MJ_CONFIG_SRT_INFORMATION: "GET_MJ_CONFIG_SRT_INFORMATION",
+3
View File
@@ -39,6 +39,9 @@ export const ClipSetting = {
}, {
label: "缩放",
value: "KFTypeScale"
}, {
label: "随机",
value: "KFTypeRandom"
}]
}
},
+23
View File
@@ -1,6 +1,9 @@
import { get } from "lodash";
import { define } from "../define";
let fspromises = require("fs").promises;
import { Tools } from "../../main/tools";
import { errorMessage } from "../../main/generalTools";
let tools = new Tools();
// Create a shared object
export const SdSettingDefine = {
@@ -42,6 +45,26 @@ export const SdSettingDefine = {
return get(setting, "webui", null);
} else
return get(setting.webui, property, null);
},
/**
* 保存一个大的属性添加到配置文件中
* @param {*} property
* @param {*} value
*/
SavePropertyValue: async function (property, value) {
try {
global.fileQueue.enqueue(async () => {
// 复制文件到指定的文件夹
await tools.writeJsonFilePropertyValue(define.sd_setting, property, value);
})
} catch (error) {
throw error;
}
}
};
+44 -2
View File
@@ -2,11 +2,14 @@
let fspromises = require('fs').promises;
import { get, cloneDeep } from 'lodash';
import { define } from './define';
import path from 'path';
import { Tools } from '../main/tools';
const { v4: uuidv4 } = require('uuid');
export class TagDefine {
constructor(global) {
this.global = global;
this.tools = new Tools();
}
/**
@@ -54,6 +57,30 @@ export class TagDefine {
else {
throw new Error(`不存在的类型 : ${value}`);
}
// 返回之前,判断里面是不是有预览图片路径
if (res.hasOwnProperty("character_tags")) {
res.character_tags.forEach(item => {
if (item.show_image && item.show_image != "") {
item.show_image = path.join(define.image_path, item.show_image);
}
});
}
if (res.hasOwnProperty("scene_tags")) {
res.scene_tags.forEach(item => {
if (item.show_image && item.show_image != "") {
item.show_image = path.join(define.image_path, item.show_image);
}
});
}
if (res.hasOwnProperty("style_tags")) {
res.style_tags.forEach(item => {
if (item.show_image && item.show_image != "") {
item.show_image = path.join(define.image_path, item.show_image);
}
});
}
return {
code: 1,
data: res
@@ -75,6 +102,22 @@ export class TagDefine {
try {
let property = value[1];
value = JSON.parse(value[0]);
let tmp_key = uuidv4();
// 特殊操作。为角色和场景的时候,需要copy图片
if (property == "character_tags" || property == "scene_tags" || property == "style_tags") {
let show_image = value.show_image;
if (show_image && show_image != "") {
let file_name = `c_s/${value.key ? value.key : tmp_key}.png`
let new_image_path = path.join(define.image_path, file_name);
await this.tools.copyFileOrDirectory(show_image, new_image_path);
value.show_image = file_name;
value.children?.forEach(item => {
item.show_image = file_name;
});
}
}
// 获取自定义的GPT数据
let tag_setting = JSON.parse(await fspromises.readFile(define.tag_setting, 'utf-8'));
let tag = get(tag_setting, property, []);
@@ -96,7 +139,7 @@ export class TagDefine {
if (tag.some(item => item.label == value.label)) {
throw new Error("已存在相同名称的数据,请修改名称后再保存");
}
value.key = uuidv4();
value.key = tmp_key;
value.value = value.key;
tag.push(value);
}
@@ -107,7 +150,6 @@ export class TagDefine {
code: 1,
message: "保存成功"
}
} catch (error) {
return {
code: 0,