mirror of
https://gitee.com/dromara/electron-egg.git
synced 2026-05-14 11:52:07 +08:00
监听任务进度
This commit is contained in:
@@ -137,6 +137,15 @@ module.exports = (appInfo) => {
|
|||||||
enable: false
|
enable: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异常捕获
|
||||||
|
*/
|
||||||
|
config.exception = {
|
||||||
|
mainExit: false,
|
||||||
|
childExit: true,
|
||||||
|
rendererExit: true,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插件功能
|
* 插件功能
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -686,16 +686,24 @@ class ExampleController extends Controller {
|
|||||||
let jobId = args.id;
|
let jobId = args.id;
|
||||||
if (args.type == 'timer') {
|
if (args.type == 'timer') {
|
||||||
let myjob = new ChildJob();
|
let myjob = new ChildJob();
|
||||||
myjob.exec('./jobs/example/timer', {jobId});
|
let timerTask = myjob.exec('./jobs/example/timer', {jobId});
|
||||||
|
|
||||||
// 监听任务进度
|
// 监听任务进度
|
||||||
const channel = 'controller.example.timerJobProgress';
|
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)
|
event.reply(`${channel}`, data)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// myjob.on('job-timer-progress', (data) => {
|
||||||
|
// Log.info('[main-process] myjob, from TimerJob data:', data);
|
||||||
|
|
||||||
|
// // 发送数据到渲染进程
|
||||||
|
// event.reply(`${channel}`, data)
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -706,7 +714,7 @@ class ExampleController extends Controller {
|
|||||||
*/
|
*/
|
||||||
createJobPool (args, event) {
|
createJobPool (args, event) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user