From 348f0fdcfdc926defee6ca8befa0829e6d8ab5f3 Mon Sep 17 00:00:00 2001 From: sophie Date: Thu, 9 Jul 2026 15:48:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(voice):=20=E5=BC=80=E5=90=AF=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3=E8=BE=93=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/features/chat/page/useChatPageVoice.ts | 17 ++++++++++------- .../kb/components/KbWorkspaceOverlays.vue | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/frontend/src/features/chat/page/useChatPageVoice.ts b/frontend/src/features/chat/page/useChatPageVoice.ts index 1ef5a4ee..0cd9ca01 100644 --- a/frontend/src/features/chat/page/useChatPageVoice.ts +++ b/frontend/src/features/chat/page/useChatPageVoice.ts @@ -1,12 +1,13 @@ /** - * 对话页:语音输入(当前功能开关关闭,保留占位与思考态取消录音)。 + * features/chat/page/useChatPageVoice.ts + * 用途:封装对话页语音输入按钮行为,将浏览器录音结果回填到输入框。 + * 依赖:Vue watch、shared/composables/useAudioTranscription、聊天页 message/i18n 上下文。 + * 逻辑:ChatViewContent 触发按钮点击后,本文件先做思考态与浏览器能力校验,再交给转写 composable 录音并调用后端 ASR。 */ import { watch } from 'vue'; import { getVoiceUnavailableErrorKey, useAudioTranscription } from '@/shared/composables/useAudioTranscription'; import type { Ref } from 'vue'; -const VOICE_INPUT_ENABLED = false; - export interface ChatPageVoiceContext { input: Ref; isThinking: Ref; @@ -14,6 +15,12 @@ export interface ChatPageVoiceContext { t: (key: string) => string; } +/** + * 绑定聊天页语音输入状态与操作。 + * 核心逻辑:复用 useAudioTranscription 完成录音/转写;点击时只拦截思考中、转写中、非 HTTPS 或浏览器不支持的场景。 + * @param ctx - 聊天页输入框、思考态、消息提示与 i18n 翻译上下文。 + * @returns 语音录制状态、转写状态、点击处理函数与取消函数。 + */ export function useChatPageVoice(ctx: ChatPageVoiceContext) { const { isRecording: isVoiceRecording, @@ -30,10 +37,6 @@ export function useChatPageVoice(ctx: ChatPageVoiceContext) { }); const handleVoiceFeatureClick = () => { - if (!VOICE_INPUT_ENABLED) { - ctx.msg.info(ctx.t('chat.devComingSoon')); - return; - } if (ctx.isThinking.value || isVoiceTranscribing.value) return; const unavailable = getVoiceUnavailableErrorKey(); if (unavailable) { diff --git a/frontend/src/features/kb/components/KbWorkspaceOverlays.vue b/frontend/src/features/kb/components/KbWorkspaceOverlays.vue index 6c7d149c..e77aa042 100644 --- a/frontend/src/features/kb/components/KbWorkspaceOverlays.vue +++ b/frontend/src/features/kb/components/KbWorkspaceOverlays.vue @@ -166,7 +166,7 @@ defineProps<{ @@ -465,7 +465,7 @@ defineProps<{