From 70a1355c4a941418e49a31ee3a6ff5419f96267f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=93=86=E5=95=A6=E5=A5=BD=E6=A2=A6?= <530353222@qq.com> Date: Mon, 3 Apr 2023 19:34:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=91=E5=90=AC=E4=BB=BB=E5=8A=A1=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/config/config.default.js | 9 +++++++++ electron/controller/example.js | 18 +++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/electron/config/config.default.js b/electron/config/config.default.js index e2d4c06..711033d 100644 --- a/electron/config/config.default.js +++ b/electron/config/config.default.js @@ -137,6 +137,15 @@ module.exports = (appInfo) => { enable: false }; + /** + * 异常捕获 + */ + config.exception = { + mainExit: false, + childExit: true, + rendererExit: true, + }; + /** * 插件功能 */ diff --git a/electron/controller/example.js b/electron/controller/example.js index b3466af..0726a12 100644 --- a/electron/controller/example.js +++ b/electron/controller/example.js @@ -686,16 +686,24 @@ class ExampleController extends Controller { let jobId = args.id; if (args.type == 'timer') { let myjob = new ChildJob(); - myjob.exec('./jobs/example/timer', {jobId}); - + let timerTask = myjob.exec('./jobs/example/timer', {jobId}); + // 监听任务进度 const channel = 'controller.example.timerJobProgress'; - myjob.on('job-timer-progress', (data) => { - Log.info('[main-process] from TimerJob data:', data); + + timerTask.emitter.on('job-timer-progress', (data) => { + Log.info('[main-process] timerTask, from TimerJob data:', data); // 发送数据到渲染进程 event.reply(`${channel}`, data) }) + + // myjob.on('job-timer-progress', (data) => { + // Log.info('[main-process] myjob, from TimerJob data:', data); + + // // 发送数据到渲染进程 + // event.reply(`${channel}`, data) + // }) } return; @@ -706,7 +714,7 @@ class ExampleController extends Controller { */ createJobPool (args, event) { - + return; }