From 26385f06b0d0f4fbb15501a0ba976b9120612ebd 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 Jul 2023 18:00:31 +0800 Subject: [PATCH] 3.5.0 --- electron/config/config.default.js | 4 +-- electron/jobs/example/timer.js | 31 +++------------------- frontend/src/utils/ipcRenderer.js | 14 ++++++---- package.json | 10 ++++--- public/images/{tray_logo.png => tray.png} | Bin 5 files changed, 20 insertions(+), 39 deletions(-) rename public/images/{tray_logo.png => tray.png} (100%) diff --git a/electron/config/config.default.js b/electron/config/config.default.js index 7ccdeb2..f3feec8 100644 --- a/electron/config/config.default.js +++ b/electron/config/config.default.js @@ -132,7 +132,7 @@ module.exports = (appInfo) => { * 主进程 */ config.mainServer = { - protocol: 'http://', + protocol: 'file://', indexPath: '/public/dist/index.html', host: 'localhost', port: 7072, @@ -164,7 +164,7 @@ module.exports = (appInfo) => { tray: { enable: true, title: 'EE程序', - icon: '/public/images/tray_logo.png' + icon: '/public/images/tray.png' }, security: { enable: true, diff --git a/electron/jobs/example/timer.js b/electron/jobs/example/timer.js index 7f8bad3..343b1d8 100644 --- a/electron/jobs/example/timer.js +++ b/electron/jobs/example/timer.js @@ -1,9 +1,6 @@ const Job = require('ee-core/jobs/baseJobClass'); -const Loader = require('ee-core/loader'); const Log = require('ee-core/log'); const Ps = require('ee-core/ps'); -const { childMessage } = require('ee-core/message'); -const Hello = Loader.requireJobsModule('./example/hello'); /** * example - TimerJob @@ -22,31 +19,9 @@ class TimerJob extends Job { async handle () { Log.info("[child-process] TimerJob params: ", this.params); - // 计时器任务 - let eventName = 'job-timer-progress'; - let number = 0; - let jobId = this.params.jobId; - let timer = setInterval(function() { - Hello.welcome(); - - childMessage.send(eventName, {jobId, number}); - number++; - }, 1000); - - // 用 setTimeout 模拟任务运行时长 - setTimeout(() => { - // 关闭定时器 - clearInterval(timer); - - // 任务结束,重置前端显示 - childMessage.send(eventName, {jobId, number:0, pid:0}); - - // 如果是childJob任务,必须调用 Ps.exit() 方法,让进程退出,否则会常驻内存 - // 如果是childPoolJob任务,常驻内存,等待下一个业务 - if (Ps.isChildJob()) { - Ps.exit(); - } - }, 10 * 1000) + if (Ps.isChildJob()) { + Ps.exit(); + } } } diff --git a/frontend/src/utils/ipcRenderer.js b/frontend/src/utils/ipcRenderer.js index 6dd0388..d060168 100644 --- a/frontend/src/utils/ipcRenderer.js +++ b/frontend/src/utils/ipcRenderer.js @@ -1,4 +1,4 @@ -const { ipcRenderer: ipc } = (window.require && window.require('electron')) || window.electron || {}; +const Renderer = (window.require && window.require('electron')) || window.electron || {}; /** * ipc @@ -17,12 +17,16 @@ const { ipcRenderer: ipc } = (window.require && window.require('electron')) || w * ipc.sendToHost(channel, ...args) - 消息会被发送到 host 页面上的 元素 */ +/** + * ipc + */ +const ipc = Renderer.ipcRenderer || undefined; + /** * 是否为EE环境 */ const isEE = ipc ? true : false; -export { - ipc, - isEE -} +export default { + Renderer, ipc, isEE +} \ No newline at end of file diff --git a/package.json b/package.json index b2bd23f..ff17750 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ee", - "version": "3.4.0", + "version": "3.5.0", "description": "A fast, desktop software development framework", "main": "main.js", "scripts": { @@ -29,12 +29,14 @@ "encrypt": "ee-core encrypt", "clean": "ee-core clean", "rebuild": "electron-rebuild", - "re-sqlite": "electron-rebuild -f -w better-sqlite3" + "re-sqlite": "electron-rebuild -f -w better-sqlite3", + "icon": "ee-core icon -i /public/images/logo.png -o /build/icons/" }, "repository": "https://github.com/dromara/electron-egg.git", "keywords": [ "Electron", - "electron-egg" + "electron-egg", + "ElectronEgg" ], "author": "哆啦好梦, Inc <530353222@qq.com>", "license": "Apache", @@ -49,7 +51,7 @@ }, "dependencies": { "dayjs": "^1.10.7", - "ee-core": "^2.2.4", + "ee-core": "^2.3.0", "electron-updater": "^5.3.0", "lodash": "^4.17.21" } diff --git a/public/images/tray_logo.png b/public/images/tray.png similarity index 100% rename from public/images/tray_logo.png rename to public/images/tray.png