Explorar el Código

feat(main): Set up Electron main process with ESM, window creation, lifecycle events, and IPC for logging

sw hace 3 semanas
padre
commit
db0a648167
Se han modificado 1 ficheros con 6 adiciones y 1 borrados
  1. 6 1
      main.js

+ 6 - 1
main.js

@@ -6,7 +6,7 @@ import { writeLog } from './src/log/log-writer.js';
 
 // -------------- 构造 ESM 版 __dirname --------------
 const __filename = fileURLToPath(import.meta.url);
-const __dirname  = dirname(__filename);
+const __dirname = dirname(__filename);
 
 // -------------- 创建窗口 --------------
 function createWindow() {
@@ -32,6 +32,11 @@ function createWindow() {
   win.loadFile(join(process.cwd(), 'h5/index.html'));
 
   win.once('ready-to-show', () => win.show());
+  //渲染进程死了,纪录日志
+  win.webContents.on('render-process-gone', (event, details) => {
+    writeLog('error',`渲染进程崩溃 ${details}`);
+    // writeLog('error', JSON.stringify(details));
+  });
 }
 
 // -------------- 应用生命周期 --------------