Skip to content

Commit

Permalink
log--快捷键自动注册 (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
qinyang912 authored Nov 27, 2018
1 parent c40fb78 commit 66d611e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion native/hotkey.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,18 @@ async function configHotkey(config) {
Object.keys(config).forEach((key) => {
if (!HotKeyFunctionMap[key] || NotRegisterMap[env.platform][key]) return; // 如果没有对应的处理函数,则直接返回
if (!config[key]) return;
globalShortcut.register(config[key], HotKeyFunctionMap[key]);
function registerShortcut(k) {
globalShortcut.register(config[k], HotKeyFunctionMap[k]);
// mac系统允许注册相同的快捷键
const isRegistered = globalShortcut.isRegistered(config[k]);
// 如果注册失败,自动再注册
if (!isRegistered) {
setTimeout(() => {
registerShortcut(k);
}, 2000);
}
}
registerShortcut(key);
})
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rishiqing-electron",
"version": "3.1.10",
"version": "3.1.11",
"author": "北京创仕科锐信息技术有限责任公司",
"electronVersion": "3.0.10",
"main": "main.js",
Expand Down

0 comments on commit 66d611e

Please sign in to comment.