Update index.vue

This commit is contained in:
lanxiuyun 2025-06-10 10:25:25 +08:00
parent 42aec3403a
commit 69218a728b

View File

@ -274,12 +274,16 @@ const state = reactive({
custom: {}, custom: {},
}); });
// lastKeyPressTime
const lastKeyPressTime = ref(0);
const DOUBLE_CLICK_THRESHOLD = 300; //
const isWindows = window?.rubick?.isWindows(); const isWindows = window?.rubick?.isWindows();
const tipText = computed(() => { const tipText = computed(() => {
const optionKeyName = isWindows ? 'Alt' : 'Option、Command'; const optionKeyName = isWindows ? 'Alt' : 'Option、Command';
return t('feature.settings.global.addShortcutKeyTips', { return t('feature.settings.global.addShortcutKeyTips', {
optionKeyName: optionKeyName, optionKeyName: optionKeyName,
}); }) + `此外你也可以双击修饰键Ctrl+Ctrl`;
}); });
const currentSelect = ref(['userInfo']); const currentSelect = ref(['userInfo']);
@ -316,6 +320,34 @@ const changeShortCut = (e, key) => {
let compose = ''; let compose = '';
// //
let incluFuncKeys = false; let incluFuncKeys = false;
const currentTime = Date.now();
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';
return;
}
// +
if (e.ctrlKey && e.keyCode !== 17) { if (e.ctrlKey && e.keyCode !== 17) {
compose += '+Ctrl'; compose += '+Ctrl';
incluFuncKeys = true; incluFuncKeys = true;
@ -332,15 +364,11 @@ const changeShortCut = (e, key) => {
compose += '+Command'; compose += '+Command';
incluFuncKeys = true; incluFuncKeys = true;
} }
//
if (incluFuncKeys) {
compose += '+' + keycodes[e.keyCode].toUpperCase(); compose += '+' + keycodes[e.keyCode].toUpperCase();
compose = compose.substring(1); compose = compose.substring(1);
if (
incluFuncKeys &&
e.keyCode !== 16 &&
e.keyCode !== 17 &&
e.keyCode !== 18 &&
e.keyCode !== 93
) {
state.shortCut[key] = compose; state.shortCut[key] = compose;
} else { } else {
// //