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) => {
let compose = '';
//
let incluFuncKeys = false;
const currentTime = Date.now();
const isDoubleClick =
currentTime - lastKeyPressTime.value < DOUBLE_CLICK_THRESHOLD;
const isDoubleClick = currentTime - lastKeyPressTime.value < DOUBLE_CLICK_THRESHOLD;
lastKeyPressTime.value = currentTime;
//
if (e.keyCode === 17 && isDoubleClick) {
// Ctrl
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';
// F1-F12
if (e.keyCode >= 112 && e.keyCode <= 123) {
state.shortCut[key] = keycodes[e.keyCode].toUpperCase();
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) {
compose += '+Ctrl';
incluFuncKeys = true;
hasModifierKey = true;
}
if (e.shiftKey && e.keyCode !== 16) {
compose += '+Shift';
incluFuncKeys = true;
hasModifierKey = true;
}
if (e.altKey && e.keyCode !== 18) {
compose += '+Option';
incluFuncKeys = true;
hasModifierKey = true;
}
if (e.metaKey && e.keyCode !== 93) {
compose += '+Command';
incluFuncKeys = true;
hasModifierKey = true;
}
//
if (incluFuncKeys) {
if (hasModifierKey) {
compose += '+' + keycodes[e.keyCode].toUpperCase();
compose = compose.substring(1);
state.shortCut[key] = compose;