diff --git a/apps/client/components/CustomShortcutDialog.vue b/apps/client/components/CustomShortcutDialog.vue new file mode 100644 index 00000000..4d495829 --- /dev/null +++ b/apps/client/components/CustomShortcutDialog.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/apps/client/components/UserMenu.vue b/apps/client/components/UserMenu.vue index ad546868..d8b219b8 100644 --- a/apps/client/components/UserMenu.vue +++ b/apps/client/components/UserMenu.vue @@ -48,7 +48,7 @@ :name="item.icon" class="mr-3 h-7 w-7" > - {{ item.title }} + {{ item.title }} diff --git a/apps/client/composables/user/shortcutKey.ts b/apps/client/composables/user/shortcutKey.ts index 0fa85e20..620d4b7e 100644 --- a/apps/client/composables/user/shortcutKey.ts +++ b/apps/client/composables/user/shortcutKey.ts @@ -51,30 +51,30 @@ export function convertMacKey(key: string) { } // 自定义快捷键 -export function useShortcutKeyMode() { - const showModal = ref(false); - const currentKeyType = ref(""); - const shortcutKeyStr = ref(""); - const shortcutKeys = ref<{ [key: string]: any }>({ - ...DEFAULT_SHORTCUT_KEYS, - }); - const shortcutKeyTip = computed(() => { - return shortcutKeyStr.value.replace(/\+/g, "+"); - }); - const hasSameShortcutKey = ref(false); - - // 初始化快捷键 - setShortcutKeys(); - - function setShortcutKeys() { - const localKeys = localStorage.getItem(SHORTCUT_KEYS); - if (localKeys) { - shortcutKeys.value = { ...shortcutKeys.value, ...JSON.parse(localKeys) }; - } else { - localStorage.setItem(SHORTCUT_KEYS, JSON.stringify(shortcutKeys.value)); - } +const showModal = ref(false); +const currentKeyType = ref(""); +const shortcutKeyStr = ref(""); +const shortcutKeys = ref<{ [key: string]: any }>({ + ...DEFAULT_SHORTCUT_KEYS, +}); +const hasSameShortcutKey = ref(false); +const shortcutKeyTip = computed(() => { + return shortcutKeyStr.value.replace(/\+/g, "+"); +}); + +// 初始化快捷键 +setShortcutKeys(); + +function setShortcutKeys() { + const localKeys = localStorage.getItem(SHORTCUT_KEYS); + if (localKeys) { + shortcutKeys.value = { ...shortcutKeys.value, ...JSON.parse(localKeys) }; + } else { + localStorage.setItem(SHORTCUT_KEYS, JSON.stringify(shortcutKeys.value)); } +} +export function useShortcutKeyMode() { function handleEdit(type: SHORTCUT_KEY_TYPES) { showModal.value = true; shortcutKeyStr.value = ""; @@ -121,6 +121,12 @@ export function useShortcutKeyMode() { if (!showModal.value) return; e.preventDefault(); + + if (e.key === "Escape") { + handleCloseDialog(); + return; + } + const mainKey = getKeyModifier(e); if (!mainKey && isEnterKey(e.key)) { if (checkSameShortcutKey(shortcutKeyStr.value)) { diff --git a/apps/client/pages/User/Setting.vue b/apps/client/pages/User/Setting.vue index 497b2bbb..7f4243d9 100644 --- a/apps/client/pages/User/Setting.vue +++ b/apps/client/pages/User/Setting.vue @@ -173,51 +173,10 @@ - - - - - - - +