From 0150e6ecf2f91bab4cb867d1ba1512f1e868bd25 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Fri, 7 Aug 2026 22:55:26 +0800 Subject: [PATCH] fix: add explicit string type annotations for previewVoiceIds AI Code Review incorrectly flagged selectedVoice/selectedClonedVoice as object types. They are string (voice IDs) per useGenerateFormState types. Added explicit type annotations and comments to make this unambiguous. --- apps/web/src/pages/generate/GeneratePage.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/web/src/pages/generate/GeneratePage.tsx b/apps/web/src/pages/generate/GeneratePage.tsx index a3adf2bbe..ec513f211 100644 --- a/apps/web/src/pages/generate/GeneratePage.tsx +++ b/apps/web/src/pages/generate/GeneratePage.tsx @@ -84,12 +84,16 @@ const GeneratePage: React.FC = () => { const [previewCount, setPreviewCount] = useState(1) /* ── 根据 voiceMode 构建 voiceIds 传给预览接口 ── */ - const previewVoiceIds = useMemo(() => { + /* selectedVoice / selectedClonedVoice 均为 string 类型(voice ID), + 见 useGenerateFormState 返回值类型定义 */ + const previewVoiceIds = useMemo((): string[] => { if (voiceMode === "clone") { - return selectedClonedVoice ? [String(selectedClonedVoice)] : [] + const id: string = selectedClonedVoice + return id ? [id] : [] } // preset / custom 模式 - return selectedVoice ? [String(selectedVoice)] : [] + const id: string = selectedVoice + return id ? [id] : [] }, [voiceMode, selectedVoice, selectedClonedVoice]) /* ── Step4 预览生成(多预览 + voice_ids) ── */