From b6a1aea177022d404939f66c51648980a2ba8634 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Thu, 27 Mar 2025 19:51:06 +0800 Subject: [PATCH] perf: Optimize voice recording --- .../chat-input-operate/TouchChat.vue | 11 +- .../component/chat-input-operate/index.vue | 229 +++++++++++------- ui/src/components/ai-chat/index.vue | 5 + 3 files changed, 150 insertions(+), 95 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 b2941d77e35..e7cb014ac5e 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 de216fd25c4..9d4ef724087 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 }} - + -