From 5ba802482f72f5c91d4902cd5a63d1a001e731da Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Thu, 27 Mar 2025 19:53:35 +0800 Subject: [PATCH] perf: Optimize voice recording (#2707) --- .../chat-input-operate/TouchChat.vue | 11 +- .../component/chat-input-operate/index.vue | 227 +++++++++++------- ui/src/components/ai-chat/index.vue | 5 + 3 files changed, 149 insertions(+), 94 deletions(-) diff --git a/ui/src/components/ai-chat/component/chat-input-operate/TouchChat.vue b/ui/src/components/ai-chat/component/chat-input-operate/TouchChat.vue index b2941d77e..e7cb014ac 100644 --- a/ui/src/components/ai-chat/component/chat-input-operate/TouchChat.vue +++ b/ui/src/components/ai-chat/component/chat-input-operate/TouchChat.vue @@ -8,9 +8,9 @@ @touchstart="onTouchStart" @touchmove="onTouchMove" @touchend="onTouchEnd" - :disabled="props.disabled" + :disabled="disabled" > - 按住说话 + {{ disabled ? '对话中' : '按住说话' }} @@ -94,10 +94,13 @@ watch( ) function onTouchStart(event: any) { - emit('TouchStart') - startY.value = event.touches[0].clientY // 阻止默认滚动行为 event.preventDefault() + if (props.disabled) { + return + } + emit('TouchStart') + startY.value = event.touches[0].clientY } function onTouchMove(event: any) { if (!isTouching.value) return 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 b4d62b23e..549ad029c 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 @@ -119,7 +119,7 @@ @TouchStart="startRecording" @TouchEnd="TouchEnd" :time="recorderTime" - :start="!mediaRecorderStatus" + :start="recorderStatus === 'START'" :disabled="loading" /> + + @@ -154,7 +156,7 @@ :disabled="loading" text @click="startRecording" - v-if="mediaRecorderStatus" + v-if="recorderStatus === 'STOP'" > @@ -165,14 +167,19 @@ 00:{{ recorderTime < 10 ? `0${recorderTime}` : recorderTime }} - + -