Files
pqs-9100_tool_client/electron/main.ts
hongawen 51d607d970 调整界面
调整脚本
增加功能:备份、恢复、清空
2026-04-03 14:05:18 +08:00

45 lines
1.3 KiB
TypeScript

import fs from 'fs';
import path from 'path';
import { ElectronEgg } from 'ee-core';
import { Lifecycle } from './preload/lifecycle';
import { preload } from './preload';
import { app as electronApp } from 'electron';
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);
}
}
process.on('uncaughtException', (error) => {
writeRuntimeLog(`uncaughtException: ${error?.stack || error}`);
});
process.on('unhandledRejection', (reason) => {
writeRuntimeLog(`unhandledRejection: ${String(reason)}`);
});
writeRuntimeLog('app bootstrap start');
// New app
const app = new ElectronEgg();
// Register lifecycle
const life = new Lifecycle();
app.register("ready", life.ready);
app.register("electron-app-ready", life.electronAppReady);
app.register("window-ready", life.windowReady);
app.register("before-close", life.beforeClose);
// Register preload
app.register("preload", preload);
// Run
app.run();
writeRuntimeLog('app bootstrap end');