From ea0a78a2fe3b22e17cb117cc6e06edcdec1f1cf9 Mon Sep 17 00:00:00 2001 From: Aresn Date: Thu, 20 Jun 2024 14:46:30 +0800 Subject: [PATCH] add esc --- components/i/search/Ask.vue | 11 ++++++++++- pages/search/[id].vue | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/components/i/search/Ask.vue b/components/i/search/Ask.vue index 66c4a41..918f3f4 100644 --- a/components/i/search/Ask.vue +++ b/components/i/search/Ask.vue @@ -29,7 +29,7 @@ size="xl" @click.stop="handleAsk" /> - + const { metaSymbol } = useShortcuts() const { isDesktop } = useDevice() +const Search = inject('Search') const placeholder = computed(() => `提出后续问题${isDesktop ? '(' + metaSymbol.value + 'L)' : ''}`) const props = defineProps({ asking: { @@ -90,6 +91,14 @@ defineShortcuts({ } } }) +defineShortcuts({ + escape: { + whenever: [Search.asking], + handler: () => { + if (!isFocus.value) handleStop() + } + } +}) function handleFocus () { queryInput.value.textarea.focus() } diff --git a/pages/search/[id].vue b/pages/search/[id].vue index d466f09..50b0ecf 100644 --- a/pages/search/[id].vue +++ b/pages/search/[id].vue @@ -371,7 +371,8 @@ async function handleUpdateOpenState(url) { } } provide('Search', { - handleUpdateOpenState + handleUpdateOpenState, + asking }) function handleShare (url) { if (isShareSupported) { -- GitLab