调整界面

调整脚本
增加功能:备份、恢复、清空
This commit is contained in:
2026-04-03 14:05:18 +08:00
parent 4d0ce274e0
commit 51d607d970
15 changed files with 1494 additions and 679 deletions

View File

@@ -2,6 +2,19 @@ import { app as electronApp, screen } from 'electron';
import { logger } from 'ee-core/log';
import { getConfig } from 'ee-core/config';
import { getMainWindow } from 'ee-core/electron';
import fs from 'fs';
import path from 'path';
function writeRuntimeLog(message: string): void {
try {
const baseDir = electronApp.isPackaged ? path.dirname(process.execPath) : process.cwd();
const logFile = path.join(baseDir, 'runtime.log');
const line = `[${new Date().toISOString()}] ${message}\n`;
fs.appendFileSync(logFile, line, 'utf8');
} catch (error) {
console.error('[runtime-log] write failed:', error);
}
}
class Lifecycle {
/**
@@ -36,6 +49,16 @@ class Lifecycle {
const win = getMainWindow();
win.webContents.on('did-finish-load', () => {
logger.info('[window] did-finish-load');
writeRuntimeLog('window did-finish-load');
});
win.webContents.on('did-fail-load', (_event, errorCode, errorDescription, validatedURL) => {
logger.error('[window] did-fail-load errorCode:', errorCode, 'errorDescription:', errorDescription, 'url:', validatedURL);
writeRuntimeLog(`window did-fail-load errorCode=${errorCode} errorDescription=${errorDescription} url=${validatedURL}`);
});
// The window is centered and scaled proportionally
// Obtain the size information of the main screen, calculate the width and height of the window as a percentage of the screen,
// and calculate the coordinates of the upper left corner when the window is centered
@@ -67,4 +90,4 @@ class Lifecycle {
}
Lifecycle.toString = () => '[class Lifecycle]';
export { Lifecycle };
export { Lifecycle };