From b20b705e4697c166da1d10dba39fc8bbea03c854 Mon Sep 17 00:00:00 2001 From: wangshun <932054296@qq.com> Date: Wed, 10 Sep 2025 17:44:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BF=AB=E6=8D=B7=E9=94=AE?= =?UTF-8?q?=20+=20=E4=B8=8D=E6=98=AF=E6=89=8B=E6=9C=BA=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=E4=B8=8D=E5=90=AF=E7=94=A8=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend_nuxt/components/CommentEditor.vue | 33 +++++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/frontend_nuxt/components/CommentEditor.vue b/frontend_nuxt/components/CommentEditor.vue index 7e94e8051..b613a72d5 100644 --- a/frontend_nuxt/components/CommentEditor.vue +++ b/frontend_nuxt/components/CommentEditor.vue @@ -59,6 +59,7 @@ export default { }, components: { LoginOverlay }, setup(props, { emit }) { + const isMobile = useIsMobile() const vditorInstance = ref(null) const text = ref('') const editorId = ref(props.editorId) @@ -112,23 +113,27 @@ export default { applyTheme() }, }) + // 不是手机的情况下不添加快捷键 + if(!isMobile.value){ + // 添加快捷键监听 (Ctrl+Enter 或 Cmd+Enter) + const handleKeydown = (e) => { + if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') { + e.preventDefault() + submit() + } + } - // 添加快捷键监听 (Ctrl+Enter 或 Cmd+Enter) - const handleKeydown = (e) => { - if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') { - e.preventDefault() - submit() - } - } - const el = document.getElementById(editorId.value) - if (el) { - el.addEventListener('keydown', handleKeydown) - } - onUnmounted(() => { + const el = document.getElementById(editorId.value) if (el) { - el.removeEventListener('keydown', handleKeydown) + el.addEventListener('keydown', handleKeydown) } - }) + + onUnmounted(() => { + if (el) { + el.removeEventListener('keydown', handleKeydown) + } + }) + } }) onUnmounted(() => {