From 3db72452100f65ff9d32fae2bf492c1b92956743 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:44:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=A7=E8=A1=8C=E4=BB=BB=E5=8A=A1=E5=8F=8A?= =?UTF-8?q?=E7=9B=91=E5=90=AC=E8=BF=9B=E5=BA=A6=20=E5=BC=82=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/controller/example.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/electron/controller/example.js b/electron/controller/example.js index 0726a12..e4e5a44 100644 --- a/electron/controller/example.js +++ b/electron/controller/example.js @@ -686,11 +686,10 @@ class ExampleController extends Controller { let jobId = args.id; if (args.type == 'timer') { let myjob = new ChildJob(); + + // 执行任务及监听进度 let timerTask = myjob.exec('./jobs/example/timer', {jobId}); - - // 监听任务进度 const channel = 'controller.example.timerJobProgress'; - timerTask.emitter.on('job-timer-progress', (data) => { Log.info('[main-process] timerTask, from TimerJob data:', data); @@ -698,12 +697,15 @@ class ExampleController extends Controller { event.reply(`${channel}`, data) }) - // myjob.on('job-timer-progress', (data) => { - // Log.info('[main-process] myjob, from TimerJob data:', data); + // 执行任务及监听进度 异步 + // myjob.execPromise('./jobs/example/timer', {jobId}).then(task => { + // task.emitter.on('job-timer-progress', (data) => { + // Log.info('[main-process] timerTask, from TimerJob data:', data); - // // 发送数据到渲染进程 - // event.reply(`${channel}`, data) - // }) + // // 发送数据到渲染进程 + // event.reply(`${channel}`, data) + // }) + // }); } return;