Update index.vue

This commit is contained in:
lanxiuyun 2025-06-10 10:39:44 +08:00
parent 69218a728b
commit d41caa742b

View File

@ -318,55 +318,58 @@ watch(state, setConfig);
const changeShortCut = (e, key) => { const changeShortCut = (e, key) => {
let compose = ''; let compose = '';
//
let incluFuncKeys = false;
const currentTime = Date.now(); const currentTime = Date.now();
const isDoubleClick = const isDoubleClick = currentTime - lastKeyPressTime.value < DOUBLE_CLICK_THRESHOLD;
currentTime - lastKeyPressTime.value < DOUBLE_CLICK_THRESHOLD;
lastKeyPressTime.value = currentTime; lastKeyPressTime.value = currentTime;
// // F1-F12
if (e.keyCode === 17 && isDoubleClick) { if (e.keyCode >= 112 && e.keyCode <= 123) {
// Ctrl state.shortCut[key] = keycodes[e.keyCode].toUpperCase();
state.shortCut[key] = 'Ctrl+Ctrl';
return;
}
if (e.keyCode === 18 && isDoubleClick) {
// Alt
state.shortCut[key] = 'Option+Option';
return;
}
if (e.keyCode === 16 && isDoubleClick) {
// Shift
state.shortCut[key] = 'Shift+Shift';
return;
}
if (e.keyCode === 93 && isDoubleClick) {
// Command
state.shortCut[key] = 'Command+Command';
return; return;
} }
// + //
if (isDoubleClick) {
if (e.keyCode === 17) { // Ctrl
state.shortCut[key] = 'Ctrl+Ctrl';
return;
}
if (e.keyCode === 18) { // Alt
state.shortCut[key] = 'Option+Option';
return;
}
if (e.keyCode === 16) { // Shift
state.shortCut[key] = 'Shift+Shift';
return;
}
if (e.keyCode === 93) { // Command
state.shortCut[key] = 'Command+Command';
return;
}
}
// +
let hasModifierKey = false;
if (e.ctrlKey && e.keyCode !== 17) { if (e.ctrlKey && e.keyCode !== 17) {
compose += '+Ctrl'; compose += '+Ctrl';
incluFuncKeys = true; hasModifierKey = true;
} }
if (e.shiftKey && e.keyCode !== 16) { if (e.shiftKey && e.keyCode !== 16) {
compose += '+Shift'; compose += '+Shift';
incluFuncKeys = true; hasModifierKey = true;
} }
if (e.altKey && e.keyCode !== 18) { if (e.altKey && e.keyCode !== 18) {
compose += '+Option'; compose += '+Option';
incluFuncKeys = true; hasModifierKey = true;
} }
if (e.metaKey && e.keyCode !== 93) { if (e.metaKey && e.keyCode !== 93) {
compose += '+Command'; compose += '+Command';
incluFuncKeys = true; hasModifierKey = true;
} }
// //
if (incluFuncKeys) { if (hasModifierKey) {
compose += '+' + keycodes[e.keyCode].toUpperCase(); compose += '+' + keycodes[e.keyCode].toUpperCase();
compose = compose.substring(1); compose = compose.substring(1);
state.shortCut[key] = compose; state.shortCut[key] = compose;