V 2.2.5
This commit is contained in:
@@ -27,6 +27,18 @@ function GlobalIpc() {
|
||||
return errorMessage("获取文件失败" + error)
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on(DEFINE_STRING.OPEN_DEV_TOOLS, (event) => {
|
||||
global.newWindow[0].win.webContents.openDevTools();
|
||||
})
|
||||
|
||||
ipcMain.handle(DEFINE_STRING.OPEN_DEV_TOOLS_PASSWORD, (event, value) => {
|
||||
if (value === "297ab55d41e9f5d3eba95b9df432f991") {
|
||||
return successMessage("打开成功")
|
||||
} else {
|
||||
return errorMessage("管理控制台密码错误")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const {
|
||||
ipcMain
|
||||
ipcMain, app
|
||||
} = require("electron")
|
||||
import { DEFINE_STRING } from '../../define/define_string'
|
||||
import {
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from '../setting/setting'
|
||||
let setting = new Setting(global);
|
||||
|
||||
function SettingIpc() {
|
||||
async function SettingIpc() {
|
||||
|
||||
// 获取背景音乐配置列表
|
||||
ipcMain.handle(DEFINE_STRING.GET_BACKGROUND_MUSIC_CONFIG_LIST, async (event) => await setting.GetBackGroundMusicConfigList());
|
||||
|
||||
@@ -246,19 +246,23 @@ export class ImageGenerate {
|
||||
let task_list_json = JSON.parse(await fspromises.readFile(taskPath, 'utf-8'));
|
||||
let auto_save_image = await this.tools.getJsonFilePropertyValue(define.img_base, "auto_save_image", {}, false);
|
||||
let png_files = [];
|
||||
|
||||
let images = await this.tools.getFilesWithExtensions(path.join(this.global.config.project_path, 'tmp/input_crop'), '.png');
|
||||
|
||||
if (images.length <= 0) {
|
||||
throw new Error("未检测到抽帧图片。请检查");
|
||||
}
|
||||
|
||||
if (auto_save_image.save_match_count && auto_save_image.auto_match && images.length > auto_save_image.save_match_count && auto_save_image.main_save_folder) {
|
||||
png_files = await this.tools.getFilesWithExtensions(auto_save_image.main_save_folder, '.png');
|
||||
}
|
||||
|
||||
// 读取队列中的任务,然后添加队列
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
const element = value[i];
|
||||
let task_list = task_list_json.task_list.filter(item => item.id == element)[0];
|
||||
let seed = -1;
|
||||
let images = await this.tools.getFilesWithExtensions(path.join(this.global.config.project_path, 'tmp/input_crop'), '.png');
|
||||
await fspromises.mkdir(path.join(this.global.config.project_path, 'tmp/' + task_list.out_folder), { recursive: true });
|
||||
if (images.length <= 0) {
|
||||
throw new Error("未检测到抽帧图片。请检查");
|
||||
}
|
||||
if (auto_save_image.save_match_count && auto_save_image.auto_match && images.length > auto_save_image.save_match_count) {
|
||||
png_files = await this.tools.getFilesWithExtensions(auto_save_image.main_save_folder, '.png');
|
||||
}
|
||||
this.global.requestQuene.enqueue(async () => {
|
||||
let res = await this.sd.OneImageGeneration(images[0], task_list, seed);
|
||||
let tmp_seed = -1;
|
||||
@@ -267,11 +271,13 @@ export class ImageGenerate {
|
||||
}
|
||||
for (let j = 1; j < images.length; j++) {
|
||||
const item = images[j];
|
||||
|
||||
// 判断item是不是一个图片的地址
|
||||
if (!item.endsWith('.png')) {
|
||||
continue;
|
||||
}
|
||||
let has_permission = false;
|
||||
// 判断权限
|
||||
let permission = this.global.permission;
|
||||
|
||||
if (permission && permission.length >= 0) {
|
||||
if (permission.indexOf(DEFINE_STRING.PERMISSIONS.AUTO_SAVE_IMAGE_PERMISSION) >= 0) {
|
||||
has_permission = true;
|
||||
@@ -279,7 +285,6 @@ export class ImageGenerate {
|
||||
} else {
|
||||
has_permission = true;
|
||||
}
|
||||
|
||||
if (auto_save_image.save_match_count && j >= auto_save_image.save_match_count && has_permission && auto_save_image.auto_match) {
|
||||
// 现在随机匹配视频
|
||||
// 获取指定的文件夹中的图片
|
||||
|
||||
@@ -67,30 +67,31 @@ export class VideoGenerate {
|
||||
await this.pm.AddWebuiJson();
|
||||
let batch = DEFINE_STRING.QUEUE_BATCH.AUTO_VIDEO_GENERATE;
|
||||
let taskPath = path.join(this.global.config.project_path, "scripts/task_list.json");
|
||||
// 获取自动保存相关的配置数据
|
||||
let auto_save_image = await this.tools.getJsonFilePropertyValue(define.img_base, "auto_save_image", {}, false);
|
||||
|
||||
// // 修改数据(保存srt字幕文件位置。配音文件位置。背景音乐文件)
|
||||
// this.global.fileQueue.enqueue(async () => {
|
||||
// let config_json = JSON.parse(await fspromises.readFile(path.join(this.global.config.project_path, "scripts/config.json"), 'utf-8'));
|
||||
// config_json.srt_path = value[1].srt_path;
|
||||
// config_json.audio_path = value[1].audio_path;
|
||||
// config_json.background_music = value[1].background_music;
|
||||
// await fspromises.writeFile(path.join(this.global.config.project_path, "scripts/config.json"), JSON.stringify(config_json));
|
||||
// })
|
||||
|
||||
// 保存基础配置(文案,配音,背景音乐等)
|
||||
await this.tools.writeJsonFilePropertyValue(path.join(this.global.config.project_path, "scripts/config.json"), "video_config", value[1]);
|
||||
|
||||
// 便利所有的队列任务
|
||||
let images = await this.tools.getFilesWithExtensions(path.join(this.global.config.project_path, 'tmp/input_crop'), '.png');
|
||||
if (images.length <= 0) {
|
||||
throw new Error("未检测到抽帧图片。请检查");
|
||||
}
|
||||
|
||||
let png_files = [];
|
||||
// 获取图片文件夹
|
||||
if (auto_save_image.save_match_count && auto_save_image.auto_match && images.length > auto_save_image.save_match_count && auto_save_image.main_save_folder) {
|
||||
png_files = await this.tools.getFilesWithExtensions(auto_save_image.main_save_folder, '.png');
|
||||
}
|
||||
// 遍历所有的队列任务
|
||||
for (let i = 0; i < value[0].length; i++) {
|
||||
// 将所有的数据天添加到队列(总的大队列,有很多的小队列)
|
||||
// 将所有生图任务添加到队列中
|
||||
const task_list = value[0][i];
|
||||
let seed = -1;
|
||||
let subBatchId = `${task_list.out_folder}_image`
|
||||
let images = await this.tools.getFilesWithExtensions(path.join(this.global.config.project_path, 'tmp/input_crop'), '.png');
|
||||
await fspromises.mkdir(path.join(this.global.config.project_path, 'tmp/' + task_list.out_folder), { recursive: true });
|
||||
if (images.length <= 0) {
|
||||
throw new Error("未检测到抽帧图片。请检查");
|
||||
}
|
||||
|
||||
this.global.requestQuene.enqueue(async () => {
|
||||
let res = await this.sd.OneImageGeneration(images[0], task_list, seed);
|
||||
let tmp_seed = -1;
|
||||
@@ -99,9 +100,31 @@ export class VideoGenerate {
|
||||
}
|
||||
for (let j = 1; j < images.length; j++) {
|
||||
const element = images[j];
|
||||
this.global.requestQuene.enqueue(async () => {
|
||||
await this.sd.OneImageGeneration(element, task_list, tmp_seed);
|
||||
}, `${task_list.out_folder}_${images[j]}`, batch, subBatchId)
|
||||
if (!element.endsWith('.png')) {
|
||||
continue;
|
||||
}
|
||||
let has_permission = false;
|
||||
// 判断权限
|
||||
let permission = this.global.permission;
|
||||
if (permission && permission.length >= 0) {
|
||||
if (permission.indexOf(DEFINE_STRING.PERMISSIONS.AUTO_SAVE_IMAGE_PERMISSION) >= 0) {
|
||||
has_permission = true;
|
||||
}
|
||||
} else {
|
||||
has_permission = true;
|
||||
}
|
||||
if (auto_save_image.save_match_count && auto_save_image.auto_match && j >= auto_save_image.save_match_count && has_permission) {
|
||||
// 现在随机匹配视频
|
||||
// 获取指定的文件夹中的图片
|
||||
let randomData = png_files[Math.floor(Math.random() * png_files.length)];
|
||||
let base_name = path.basename(element);
|
||||
let copy_path = path.join(this.global.config.project_path, 'tmp/' + task_list.out_folder, base_name);
|
||||
await this.tools.copyFileOrDirectory(randomData, copy_path);
|
||||
} else {
|
||||
this.global.requestQuene.enqueue(async () => {
|
||||
await this.sd.OneImageGeneration(element, task_list, tmp_seed);
|
||||
}, `${task_list.out_folder}_${images[j]}`, batch, subBatchId)
|
||||
}
|
||||
}
|
||||
|
||||
}, `${task_list.out_folder}_${images[0]}`, batch, subBatchId)
|
||||
|
||||
+5
-3
@@ -196,11 +196,12 @@ app.whenReady().then(async () => {
|
||||
tools.checkFolderExistsOrCreate(path.normalize(define.temp_sd_image));
|
||||
tools.checkFolderExistsOrCreate(path.normalize(path.join(define.image_path, "c_s")));
|
||||
|
||||
app.on('activate', function () {
|
||||
app.on('activate', async function () {
|
||||
// On macOS it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (BrowserWindow.getAllWindows().length === 0) mainWindow = createWindow('ShowMessage', null)
|
||||
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
mainWindow = createWindow('ShowMessage', null)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -213,6 +214,7 @@ app.on('window-all-closed', () => {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
SettingIpc();
|
||||
ImageGenerateIpc();
|
||||
WritingIpc();
|
||||
|
||||
Reference in New Issue
Block a user