mirror of
https://gitee.com/dromara/electron-egg.git
synced 2026-05-14 03:52:07 +08:00
代码注释
This commit is contained in:
@@ -45,7 +45,7 @@ const config = {
|
||||
//titleBarStyle: 'hidden'
|
||||
},
|
||||
egg: {
|
||||
title: 'electron-egg',
|
||||
title: 'electron-egg', // 进程的title属性标识,无需改动
|
||||
env: 'prod',
|
||||
port: 7068,
|
||||
hostname: 'localhost',
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
4
main.js
4
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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user