mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-09 12:24:09 +08:00
优化-全局快捷键优化及提示信息更正错别字
This commit is contained in:
parent
1dfb39c2e7
commit
7802d359c4
@ -213,6 +213,10 @@ const examples = [
|
|||||||
title: '快捷键 「 Alt + Q」 关键字 「 取色」',
|
title: '快捷键 「 Alt + Q」 关键字 「 取色」',
|
||||||
desc: '按下Alt + Q 直接打开屏幕取色功能',
|
desc: '按下Alt + Q 直接打开屏幕取色功能',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '快捷键 「 Ctrl + Alt + Q」 关键字 「 截屏」',
|
||||||
|
desc: '按下 Ctrl + Alt + Q 进行截屏',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
@ -255,43 +259,29 @@ const setConfig = debounce(() => {
|
|||||||
|
|
||||||
watch(state, setConfig);
|
watch(state, setConfig);
|
||||||
|
|
||||||
const changeShortCutOld = (e, key) => {
|
|
||||||
if (e.altKey && e.keyCode !== 18) {
|
|
||||||
const compose = `Option+${keycodes[e.keyCode].toUpperCase()}`;
|
|
||||||
state.shortCut[key] = compose;
|
|
||||||
}
|
|
||||||
if (e.ctrlKey && e.keyCode !== 17) {
|
|
||||||
const compose = `Ctrl+${keycodes[e.keyCode].toUpperCase()}`;
|
|
||||||
state.shortCut[key] = compose;
|
|
||||||
}
|
|
||||||
if (e.shiftKey && e.keyCode !== 16) {
|
|
||||||
const compose = `Shift+${keycodes[e.keyCode].toUpperCase()}`;
|
|
||||||
state.shortCut[key] = compose;
|
|
||||||
}
|
|
||||||
if (e.metaKey && e.keyCode !== 93) {
|
|
||||||
const compose = `Command+${keycodes[e.keyCode].toUpperCase()}`;
|
|
||||||
state.shortCut[key] = compose;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const changeShortCut = (e, key) => {
|
const changeShortCut = (e, key) => {
|
||||||
let compose = '';
|
let compose = '';
|
||||||
|
// 添加是否包含功能键的判断
|
||||||
|
let incluFuncKeys = false;
|
||||||
if (e.ctrlKey && e.keyCode !== 17) {
|
if (e.ctrlKey && e.keyCode !== 17) {
|
||||||
compose += '+Ctrl';
|
compose += '+Ctrl';
|
||||||
|
incluFuncKeys = true;
|
||||||
}
|
}
|
||||||
if (e.shiftKey && e.keyCode !== 16) {
|
if (e.shiftKey && e.keyCode !== 16) {
|
||||||
compose += '+Shift';
|
compose += '+Shift';
|
||||||
|
incluFuncKeys = true;
|
||||||
}
|
}
|
||||||
if (e.altKey && e.keyCode !== 18) {
|
if (e.altKey && e.keyCode !== 18) {
|
||||||
compose += '+Option';
|
compose += '+Option';
|
||||||
|
incluFuncKeys = true;
|
||||||
}
|
}
|
||||||
if (e.metaKey && e.keyCode !== 93) {
|
if (e.metaKey && e.keyCode !== 93) {
|
||||||
compose += '+Command';
|
compose += '+Command';
|
||||||
|
incluFuncKeys = true;
|
||||||
}
|
}
|
||||||
compose += '+'+keycodes[e.keyCode].toUpperCase();
|
compose += '+'+keycodes[e.keyCode].toUpperCase();
|
||||||
compose = compose.substring(1)
|
compose = compose.substring(1)
|
||||||
console.log(compose);
|
if(incluFuncKeys && e.keyCode !== 16 && e.keyCode !== 17 && e.keyCode !== 18 && e.keyCode !== 93){
|
||||||
if(e.keyCode !== 16 && e.keyCode !== 17 && e.keyCode !== 18 && e.keyCode !== 93){
|
|
||||||
state.shortCut[key] = compose;
|
state.shortCut[key] = compose;
|
||||||
}else{
|
}else{
|
||||||
// 不做处理
|
// 不做处理
|
||||||
@ -299,27 +289,35 @@ const changeShortCut = (e, key) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const changeGlobalKey = (e, index) => {
|
const changeGlobalKey = (e, index) => {
|
||||||
let compose;
|
let compose = '';
|
||||||
if (e.altKey && e.keyCode !== 18) {
|
// 添加是否包含功能键的判断
|
||||||
compose = `Alt+${keycodes[e.keyCode].toUpperCase()}`;
|
let incluFuncKeys = false;
|
||||||
}
|
|
||||||
if (e.ctrlKey && e.keyCode !== 17) {
|
if (e.ctrlKey && e.keyCode !== 17) {
|
||||||
compose = `Ctrl+${keycodes[e.keyCode].toUpperCase()}`;
|
compose += '+Ctrl';
|
||||||
|
incluFuncKeys = true;
|
||||||
}
|
}
|
||||||
if (e.shiftKey && e.keyCode !== 16) {
|
if (e.shiftKey && e.keyCode !== 16) {
|
||||||
compose = `Shift+${keycodes[e.keyCode].toUpperCase()}`;
|
compose += '+Shift';
|
||||||
|
incluFuncKeys = true;
|
||||||
|
}
|
||||||
|
if (e.altKey && e.keyCode !== 18) {
|
||||||
|
compose += '+Option';
|
||||||
|
incluFuncKeys = true;
|
||||||
}
|
}
|
||||||
if (e.metaKey && e.keyCode !== 93) {
|
if (e.metaKey && e.keyCode !== 93) {
|
||||||
compose = `Command+${keycodes[e.keyCode].toUpperCase()}`;
|
compose += '+Command';
|
||||||
|
incluFuncKeys = true;
|
||||||
}
|
}
|
||||||
if (compose) {
|
compose += '+' + keycodes[e.keyCode].toUpperCase();
|
||||||
|
compose = compose.substring(1)
|
||||||
|
if (incluFuncKeys && e.keyCode !== 16 && e.keyCode !== 17 && e.keyCode !== 18 && e.keyCode !== 93) {
|
||||||
state.global[index].key = compose;
|
state.global[index].key = compose;
|
||||||
|
} else {
|
||||||
|
// 不做处理
|
||||||
}
|
}
|
||||||
// f1 - f12
|
// f1 - f12
|
||||||
if (e.keyCode >= 112 && e.keyCode <= 123) {
|
if (!incluFuncKeys && e.keyCode >= 112 && e.keyCode <= 123) {
|
||||||
compose = keycodes[e.keyCode].toUpperCase();
|
compose = keycodes[e.keyCode].toUpperCase();
|
||||||
}
|
|
||||||
if (compose) {
|
|
||||||
state.global[index].key = compose;
|
state.global[index].key = compose;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -84,7 +84,7 @@ const registerHotKey = (mainWindow: BrowserWindow): void => {
|
|||||||
data &&
|
data &&
|
||||||
new Notification({
|
new Notification({
|
||||||
title: '截图完成',
|
title: '截图完成',
|
||||||
body: '截图以存储到系统剪贴板中',
|
body: '截图已存储到系统剪贴板中',
|
||||||
}).show();
|
}).show();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user