/** * ============================================================ * src/cli/wizards/ttsWizard.tsx —— 语音合成子向导 * ------------------------------------------------------------ * 对应 ToolConfigs.textToSpeech(GenerateSpeech 工具,MiniMax T2A)。 * apiKey + groupId 两个字段,基于通用 FieldForm。两者是否齐全的校验 * 直接复用 configService.savePatch 内部的 applyConfigPatch 校验 * (缺一个会抛错,被 FieldForm 的 onSubmit 捕获展示,不在此重复校验)。 * ============================================================ */ import React from 'react'; import { configService } from '../../config/configService.js'; import { FieldForm } from './fieldForm.js'; interface Props { existing?: { apiKey: string; groupId: string } | null; onDone: () => void; onCancel: () => void; } export function TtsWizard({ existing, onDone, onCancel }: Props): JSX.Element { return ( { const apiKey = String(values.apiKey ?? '').trim(); const groupId = String(values.groupId ?? '').trim(); // 全空 = 用户只是走进来看了一眼,安静回菜单;只填一项进入安全草稿桶。 if (!apiKey && !groupId) { onDone(); return; } await configService.autosave('tools', { tools: { textToSpeech: { apiKey, groupId } }, }); onDone(); }} onCancel={onCancel} /> ); }