| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- 'use strict';
- const { globalShortcut } = require('electron');
- const storage = require('./storage');
- const shortcutList = {
- 'CommandOrControl+Shift+s': 'showWindow',
- 'CommandOrControl+Shift+h': 'hideWindow',
- }
- exports.setup = function () {
- // default
- //const preferences = storage.getPreferences();
- // const shortcuts = preferences.hasOwnProperty('shortcuts') ? preferences.shortcuts : {};
- // storage.setShortcuts(shortcuts);
- // for (let key in shortcuts) {
- // const fn = this.shortcuts[key]();
- // console.log(fn.toString());
- // this.register(key, fn);
- // }
- }
- exports.register = function (cmd, force = true, fn) {
- const isRegistered = this.isRegistered(cmd);
- console.log('[shortcut] [register] cmd:', [cmd, isRegistered]);
- if (isRegistered && !force) {
- return;
- }
- globalShortcut.register(cmd, fn)
- }
- exports.isRegistered = function (cmd) {
- return globalShortcut.isRegistered(cmd)
- }
- exports.unregister = function (cmd) {
- globalShortcut.unregister(cmd)
- }
- // function showWindow () {
- // MAIN_WINDOW.show()
- // }
- // function hideWindow () {
- // MAIN_WINDOW.hide()
- // }
- exports = module.exports;
|