From ca12d653a697b2ef51686bcaf1b034d09f531920 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud <79562285+wangdan-fit2cloud@users.noreply.github.com> Date: Wed, 26 Mar 2025 16:00:19 +0800 Subject: [PATCH] perf: Optimize pressing enter to line breaks on mobile --- .../ai-chat/component/chat-input-operate/index.vue | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/src/components/ai-chat/component/chat-input-operate/index.vue b/ui/src/components/ai-chat/component/chat-input-operate/index.vue index 5a7986ef0..71ae6905e 100644 --- a/ui/src/components/ai-chat/component/chat-input-operate/index.vue +++ b/ui/src/components/ai-chat/component/chat-input-operate/index.vue @@ -589,6 +589,14 @@ function autoSendMessage() { } function sendChatHandle(event?: any) { + const isMobile = /Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( + navigator.userAgent + ) + // 如果是移动端,且按下回车键,不直接发送 + if ((isMobile || mode === 'mobile') && event?.key === 'Enter') { + // 阻止默认事件 + return + } if (!event?.ctrlKey && !event?.shiftKey && !event?.altKey && !event?.metaKey) { // 如果没有按下组合键,则会阻止默认事件 event?.preventDefault()