diff --git a/src/components/Toolbar/SettingModal.vue b/src/components/Toolbar/SettingModal.vue index 881614f3..bea93204 100644 --- a/src/components/Toolbar/SettingModal.vue +++ b/src/components/Toolbar/SettingModal.vue @@ -8,6 +8,7 @@ import {useChangeAllSound, useWatchAllSound} from "@/hooks/sound.ts"; import {useDisableEventListener, useEventListener} from "@/hooks/event.ts"; import {$computed, $ref} from "vue/macros"; import {cloneDeep} from "lodash-es"; +import {DefaultShortcutKeyMap} from "@/types.ts"; const tabIndex = $ref(2) const settingStore = useSettingStore() @@ -20,14 +21,8 @@ const emit = defineEmits([ useDisableEventListener() useWatchAllSound() -let ShortcutKeyMap = { - Show: 'Esc', - Ignore: 'Tab', - Remove: '`', - Collect: 'Enter', -} + let editShortcutKey = $ref('') -let shortcutKeyMapRef = $ref(cloneDeep(ShortcutKeyMap)) useEventListener('keydown', (e: KeyboardEvent) => { console.log('e', e, e.keyCode, e.ctrlKey, e.altKey, e.shiftKey) @@ -48,13 +43,13 @@ useEventListener('keydown', (e: KeyboardEvent) => { shortcutKey = shortcutKey.trim() if (editShortcutKey) { - for (const [k, v] of Object.entries(shortcutKeyMapRef)) { + for (const [k, v] of Object.entries(settingStore.shortcutKeyMap)) { if (v === shortcutKey && k !== editShortcutKey) { - shortcutKeyMapRef[editShortcutKey] = ShortcutKeyMap[editShortcutKey] + settingStore.shortcutKeyMap[editShortcutKey] = DefaultShortcutKeyMap[editShortcutKey] return ElMessage.warning('快捷键重复!') } } - shortcutKeyMapRef[editShortcutKey] = shortcutKey + settingStore.shortcutKeyMap[editShortcutKey] = shortcutKey } console.log('key', shortcutKey) @@ -281,7 +276,7 @@ useEventListener('keydown', (e: KeyboardEvent) => {