diff --git a/electron/config.js b/electron/config.js index 834e5c8..d5a9a81 100644 --- a/electron/config.js +++ b/electron/config.js @@ -45,7 +45,7 @@ const config = { //titleBarStyle: 'hidden' }, egg: { - title: 'electron-egg', + title: 'electron-egg', // 进程的title属性标识,无需改动 env: 'prod', port: 7068, hostname: 'localhost', diff --git a/electron/lib/shortcut.js b/electron/lib/shortcut.js index 3544bfd..ebba328 100644 --- a/electron/lib/shortcut.js +++ b/electron/lib/shortcut.js @@ -8,23 +8,41 @@ exports.setup = function () { storage.iniPreferences(); } +/** + * 快捷键注册 + * @param {Object} shortcutObj - shortcut object + * @param {Boolean} force - force register + * @param {Function} fn - callback + * @return {Boolean} + */ exports.register = function (shortcutObj, force = true, fn) { if (!shortcutObj['id'] || !shortcutObj['name'] || !shortcutObj['cmd']) { return false; } const isRegistered = this.isRegistered(shortcutObj['cmd']); - // console.log('[shortcut] [register] cmd:', [shortcutObj['cmd'], isRegistered]); if (isRegistered && !force) { return false; } storage.setShortcuts(shortcutObj); globalShortcut.register(shortcutObj['cmd'], fn) + + return true; } +/** + * 快捷键是否注册成功 + * @param {String} cmd - shortcut string + * @return {Boolean} + */ exports.isRegistered = function (cmd) { return globalShortcut.isRegistered(cmd) } +/** + * 注销全局快捷键 + * @param {String} cmd - shortcut string + * @return {Boolean} + */ exports.unregister = function (cmd) { globalShortcut.unregister(cmd) } diff --git a/main.js b/main.js index 8c97f55..35bd0ce 100644 --- a/main.js +++ b/main.js @@ -69,10 +69,6 @@ async function createWindow () { // egg server await startServer(eggConfig) - // process.on('uncaughtException', function(err) { - // eLogger.error(err); - // }); - return MAIN_WINDOW } diff --git a/update.md b/update.md index 45fec46..3a634dc 100644 --- a/update.md +++ b/update.md @@ -1,7 +1,8 @@ ## 1.10.0 -1. 优化代码结构。 -2. 升级electron到12版本。 +1. 优化代码结构,功能模块更加合理。 +2. 升级electron核心到12版本。 3. 升级electron-builder,支持Mac M1芯片架构。 -4. 增加快捷键功能模块和demo。 +4. 增加快捷键功能模块并提供demo。 5. 修复ejs bug。 -6. 修复引入路径bug。 \ No newline at end of file +6. 修复引入路径。 +7. 优化自动升级重复代码、废弃旧的api。 \ No newline at end of file