From 4f0f639e8f439e73e4998b9be5c65befe50ec963 Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Tue, 9 Jun 2026 15:28:24 +0800 Subject: [PATCH] Refactor AssistantPage and DebugDrawer components - Remove debug mode state management from AssistantPage, simplifying the component structure. - Update DebugDrawer to eliminate mode selection, focusing on voice interaction features. - Enhance the VoiceVisualizer component with improved visual effects and responsiveness to audio input. - Adjust styles and layout for better user experience in the debugging interface. --- .../src/components/pages/AssistantPage.tsx | 229 +++++++++--------- .../src/components/ui/voice-visualizer.tsx | 117 +++++++-- 2 files changed, 216 insertions(+), 130 deletions(-) diff --git a/frontend/src/components/pages/AssistantPage.tsx b/frontend/src/components/pages/AssistantPage.tsx index cd6be22..075a9e8 100644 --- a/frontend/src/components/pages/AssistantPage.tsx +++ b/frontend/src/components/pages/AssistantPage.tsx @@ -23,13 +23,12 @@ import { Save, Mic, Send, - MessageCircle, HelpCircle, Waypoints, AudioLines, - Square, Terminal, Loader2, + PhoneOff, } from "lucide-react"; import { Button } from "@/components/ui/button"; @@ -201,8 +200,6 @@ type AssistantListItem = { updatedAt: string; }; -type DebugMode = "text" | "voice"; - type TypeFilter = "全部" | AssistantType; const typeFilters: TypeFilter[] = ["全部", ...assistantTypes]; @@ -271,8 +268,6 @@ export function AssistantPage() { const [searchQuery, setSearchQuery] = useState(""); const [typeFilter, setTypeFilter] = useState("全部"); const [currentPage, setCurrentPage] = useState(1); - // 右侧调试 drawer 的当前模式 - const [debugMode, setDebugMode] = useState("text"); // choose 步骤的草稿:名称与已选类型,确认后才决定进入哪个构建页 const [draftName, setDraftName] = useState(""); const [draftType, setDraftType] = useState(null); @@ -1229,7 +1224,7 @@ export function AssistantPage() { - + ); @@ -1333,7 +1328,7 @@ export function AssistantPage() { - + ); @@ -1451,7 +1446,7 @@ export function AssistantPage() { - + ); @@ -1661,88 +1656,121 @@ export function AssistantPage() { - + ); } -function DebugDrawer({ - mode, - onModeChange, -}: { - mode: DebugMode; - onModeChange: (mode: DebugMode) => void; -}) { - const modeTabs: { key: DebugMode; label: string; icon: React.ReactNode }[] = [ - { key: "text", label: "文字测试", icon: }, - { key: "voice", label: "语音测试", icon: }, - ]; +function DebugDrawer() { + const [showTranscript, setShowTranscript] = useState(false); return ( ); } -function DebugTextPanel() { +function DebugVoicePanel({ showTranscript }: { showTranscript: boolean }) { + const [recording, setRecording] = useState(false); + const [micError, setMicError] = useState(false); + return (
-
-
-
- 您好,我是 AI 视频助手,请问有什么可以帮您? -
- 助手 -
+ {showTranscript ? ( + + ) : ( +
+
-
-
- 我想咨询一下社保卡的办理流程。 -
- -
+ + + {recording ? "会话进行中" : "准备开始"} + -
-
- 社保卡可通过线上或线下渠道办理。线上可在政务服务 App - 提交申请,线下可前往社保经办网点…… -
- 助手 -
-
+ { + setMicError(true); + setRecording(false); + }} + /> -
+
+
+ {recording ? "我在聆听" : "开始一次语音对话"} +
+

+ {micError + ? "无法访问麦克风,请检查浏览器权限后重试。" + : recording + ? "直接说话即可。助手会在您停顿后自然回应。" + : "测试语音识别、响应速度与助手的播报效果。"} +

+
+ +
+ +
+
+ )} + +