feat: 任务3.11 配音库页面升级 — 对接后端真实API #167
Reference in New Issue
Block a user
Delete Branch "feature/task-311-voice-library-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
任务 3.11:配音库页面升级
将前端 Mock 数据替换为后端真实 API 对接(依赖后端 3.04 + 3.05)。
修改文件(6个)
api/voices.tsapi/voiceClone.tspages/voices/VoiceLibrary.tsxcomponents/modals/CloneVoiceModal.tsxcomponents/modals/VoiceCloneModal.tsxpages/voice-clone/VoiceClone.tsxAPI 对接
GET /api/v1/voices→ 统一音色列表(skip/limit 分页,返回 preset_count/clone_count)GET /api/v1/voices/presets→ 预置音色列表GET /api/v1/voice-clones→ 克隆音色列表(skip/limit 分页)POST /api/v1/voice-clones→ 创建克隆验证
npx tsc --noEmit)PR #167 审查报告:任务 3.11 配音库页面升级
分支: feature/task-311-voice-library-api → develop
Commit:
b0aee55ff5变更: 6 文件,+335/-203
结论:✅ 有条件通过(0 P0 / 0 P1 / 1 P2 / 3 P3,mergeable=True)
一、整体评价
前端从 Mock 数据到真实 API 的迁移做得干净利落。使用
useQuery管理数据获取,类型定义完整,toVoiceClone转换函数集中处理了后端到前端的适配逻辑。向后兼容旧接口的处理也很周到。二、亮点
useQuery+ 真实 API,代码量反而减少(+102/-124)toVoiceClone()函数集中处理后端→前端的转换,包括 status 映射(pending → processing),避免在多处重复转换逻辑/voices/legacy,不影响其他页面toVoiceClone导入和调用,改动精准三、问题清单
P2(建议修复)
P2-1:
updateVoiceClone是静默空操作的 Stubapps/web/src/api/voiceClone.ts—updateVoiceClone()函数throw new Error("更新功能暂未开放"),让调用方的 onError 捕获并提示用户P3(建议关注)
P3-1:分页参数使用 skip/limit 而非 page/page_size
apps/web/src/api/voiceClone.ts、apps/web/src/api/voices.tsVoiceCloneListParams和UnifiedVoiceListParams使用skip/limit分页。虽然这与当前后端 API 一致(后端 voice-clones 和 voices 端点使用 skip/limit),但项目标准已明确为page/page_size(任务 3.06 明确要求)。后端修复后前端需同步更新P3-2:
handleToggleStar空实现但 UI 仍然展示星标按钮apps/web/src/pages/voices/VoiceLibrary.tsxhandleToggleStar是空函数(仅有 TODO 注释),但预置音色卡片上仍显示收藏星标按钮。用户点击无反应,体验不佳starred设为undefined而非false,VoiceCard 中已有starred !== undefined的条件渲染)P3-3:VoiceLibrary 中存在双重映射
apps/web/src/pages/voices/VoiceLibrary.tsxclonedVoices的计算经过两次映射:VoiceCloneProfile → VoiceClone → ClonedVoiceDisplay。虽然逻辑正确,但中间层增加了理解成本mapProfileToDisplay(profile: VoiceCloneProfile): ClonedVoiceDisplay,直接在转换中完成所有字段映射四、各文件审查详情
api/voiceClone.ts(+139/-69)
toVoiceClone正确处理 status 映射:pending → processinggetVoiceClones(返回数组)和getVoiceClonesWithTotal(返回完整响应含 total)updateVoiceClone为静默空操作(见 P2-1)api/voices.ts(+89/-5)
/voices/legacyVoiceLibrary.tsx(+102/-124)
CloneVoiceModal.tsx(+2/-2)
toVoiceClone,在onSuccess回调中转换数据VoiceCloneModal.tsx(+2/-2)
VoiceClone.tsx(+1/-1)
queryFn: getVoiceClones→queryFn: () => getVoiceClones(),功能等价五、结论
结论:✅ 有条件通过 — P2-1 建议修复(至少让 updateVoiceClone 抛出错误而非静默失败),P3 可在后续迭代处理。整体迁移质量良好,可合并。