V2.2.4 版本
This commit is contained in:
+30
-10
@@ -1,3 +1,8 @@
|
||||
import fspromises from "fs/promises";
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { version } from '../../package.json'
|
||||
|
||||
|
||||
import { app, shell, BrowserWindow, ipcMain, dialog, nativeTheme } from 'electron'
|
||||
import path, { join } from 'path'
|
||||
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
||||
@@ -6,10 +11,6 @@ import { define } from '../define/define.js'
|
||||
import { func } from './func.js'
|
||||
import { AsyncQueue } from "./quene.js"
|
||||
import { DEFINE_STRING } from '../define/define_string.js'
|
||||
const fspromises = require("fs").promises;
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
const { version } = require('../../package.json')
|
||||
|
||||
import { Tools } from './tools.js'
|
||||
import { ImageGenerate } from './backPrompt/imageGenerate.js'
|
||||
import { Setting } from './setting/setting.js'
|
||||
@@ -27,12 +28,14 @@ import { OriginalImageGenerateIpc } from './IPCEvent/originalImageGenerateIpc'
|
||||
import { SdIpc } from './IPCEvent/sdIpc.js'
|
||||
import { DiscordIpc, RemoveDiscordIpc } from './IPCEvent/discordIpc.js'
|
||||
import { MainIpc } from './IPCEvent/mainIpc.js'
|
||||
import { GlobalIpc } from "./IPCEvent/globalIpc.js";
|
||||
|
||||
let tools = new Tools();
|
||||
let imageGenerate = new ImageGenerate(global);
|
||||
let setting = new Setting(global);
|
||||
|
||||
|
||||
|
||||
async function InitData(gl) {
|
||||
let res = await setting.getSettingDafultData();
|
||||
gl.config = res;
|
||||
@@ -55,11 +58,17 @@ function removeIpcHandler(hash) {
|
||||
|
||||
async function createWindow(hash = "ShowMessage", data, url = null) {
|
||||
// Create the browser window.
|
||||
await InitData(global);
|
||||
global.currentHash = hash;
|
||||
// 判断当前是不是有设置的宽高,用的话记忆
|
||||
let isRe = global.config.window_wh_bm_remember && hash == "ShowMessage" && global.config.window_wh_bm;
|
||||
|
||||
|
||||
let mainWindow = new BrowserWindow({
|
||||
width: 900,
|
||||
height: 670,
|
||||
width: isRe ? global.config.window_wh_bm.width : 900,
|
||||
height: isRe ? global.config.window_wh_bm.height : 675,
|
||||
x: isRe ? global.config.window_wh_bm.x : 100,
|
||||
y: isRe ? global.config.window_wh_bm.y : 100,
|
||||
title: 'LAITool',
|
||||
icon: '../../resources/icon.ico',
|
||||
show: false,
|
||||
@@ -104,10 +113,16 @@ async function createWindow(hash = "ShowMessage", data, url = null) {
|
||||
}
|
||||
}
|
||||
|
||||
mainWindow.on("closed", () => {
|
||||
mainWindow.on("close", async () => {
|
||||
// 判断指定的窗口,移除指定的监听
|
||||
removeIpcHandler(hash);
|
||||
global.newWindow = global.newWindow.filter(item => item.id != mainWindow.id)
|
||||
// 判断当前的是不是开启了记录功能
|
||||
if (global.config.window_wh_bm_remember && hash == "ShowMessage") {
|
||||
let window_wh_bm = mainWindow.getBounds();
|
||||
// 记录到文件中
|
||||
await setting.ModifySampleSetting(JSON.stringify({ window_wh_bm: window_wh_bm }))
|
||||
}
|
||||
})
|
||||
|
||||
// 创建一个新的窗口,添加对应的监听
|
||||
@@ -120,7 +135,6 @@ async function createWindow(hash = "ShowMessage", data, url = null) {
|
||||
})
|
||||
|
||||
setIpcHandler(hash);
|
||||
await InitData(global);
|
||||
return mainWindow;
|
||||
}
|
||||
|
||||
@@ -141,6 +155,8 @@ app.whenReady().then(async () => {
|
||||
optimizer.watchWindowShortcuts(window)
|
||||
})
|
||||
|
||||
//
|
||||
|
||||
global.newWindow = [];
|
||||
mainWindow = createWindow('ShowMessage', null)
|
||||
|
||||
@@ -173,9 +189,12 @@ app.whenReady().then(async () => {
|
||||
}
|
||||
|
||||
// 判断动态文件是不是存在
|
||||
tools.checkJsonFileExistsOrCreate(path.join(define.dynamic_setting));
|
||||
tools.checkJsonFileExistsOrCreate(path.normalize(define.dynamic_setting));
|
||||
// 判断标签文件是不是存在
|
||||
tools.checkJsonFileExistsOrCreate(path.join(define.tag_setting));
|
||||
tools.checkJsonFileExistsOrCreate(path.normalize(define.tag_setting));
|
||||
// 判断SD图片缓存文件是不是存在(不存在创建)
|
||||
tools.checkFolderExistsOrCreate(path.normalize(define.temp_sd_image));
|
||||
tools.checkFolderExistsOrCreate(path.normalize(path.join(define.image_path, "c_s")));
|
||||
|
||||
app.on('activate', function () {
|
||||
// On macOS it's common to re-create a window in the app when the
|
||||
@@ -204,6 +223,7 @@ SdIpc();
|
||||
MjIpc();
|
||||
MainIpc(createWindow);
|
||||
OriginalImageGenerateIpc();
|
||||
GlobalIpc();
|
||||
|
||||
|
||||
ipcMain.handle('dark-mode:toggle', (event, value) => {
|
||||
|
||||
Reference in New Issue
Block a user