mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-29 22:39:45 +08:00
ref: suport shift+escape to quit app
This commit is contained in:
@@ -7,10 +7,12 @@ const configPath = path.join(getlocalDataFile(), './rubick-config.json');
|
||||
|
||||
let defaultConfig = {
|
||||
Darwin: {
|
||||
version: 2,
|
||||
perf: {
|
||||
shortCut: {
|
||||
showAndHidden: 'Option+R',
|
||||
separate: 'Ctrl+D'
|
||||
separate: 'Ctrl+D',
|
||||
quit: 'Shift+Escape'
|
||||
},
|
||||
common: {
|
||||
start: true,
|
||||
@@ -30,10 +32,12 @@ let defaultConfig = {
|
||||
global: []
|
||||
},
|
||||
Windows_NT: {
|
||||
version: 2,
|
||||
perf: {
|
||||
shortCut: {
|
||||
showAndHidden: 'Option+R',
|
||||
separate: 'Ctrl+D'
|
||||
separate: 'Ctrl+D',
|
||||
quit: 'Shift+Escape'
|
||||
},
|
||||
common: {
|
||||
start: true,
|
||||
@@ -62,7 +66,7 @@ global.opConfig = {
|
||||
opConfig.config = JSON.parse(fs.readFileSync(configPath) || JSON.stringify(defaultConfig[platform]));
|
||||
}
|
||||
// 重置
|
||||
if (!opConfig.config.perf || !opConfig.config.superPanel || !opConfig.config.global) {
|
||||
if (!opConfig.version || opConfig.version < defaultConfig[platform].version) {
|
||||
opConfig.config = defaultConfig[platform];
|
||||
fs.writeFileSync(configPath, JSON.stringify(opConfig.config));
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ class Listener {
|
||||
// 延时一定时间才能从剪切板内读取到内容
|
||||
const text = clipboard.readText('clipboard') || ''
|
||||
const fileUrl = clipboard.read('public.file-url');
|
||||
if (this.isWin) {
|
||||
// todo https://github.com/njzydark/Aragorn/blob/afe4a60972b4255dd417480ca6aca2af1fd8e637/packages/aragorn-app-main/src/uploaderManager.ts#L88
|
||||
}
|
||||
// 如果之前是文案,则回填
|
||||
clipboard.writeText(lastText);
|
||||
|
||||
@@ -63,6 +66,11 @@ class Listener {
|
||||
mainWindow.webContents.send('new-window');
|
||||
});
|
||||
|
||||
globalShortcut.register(config.perf.shortCut.quit, () => {
|
||||
mainWindow.webContents.send('init-rubick');
|
||||
mainWindow.show();
|
||||
});
|
||||
|
||||
// 注册自定义全局快捷键
|
||||
config.global.forEach(sc => {
|
||||
if (!sc.key || !sc.value) return;
|
||||
|
||||
Reference in New Issue
Block a user