fix(web): 成片库卡片查重率显示 "-" — mapVideoToProductItem 硬编码 undefined #1608
Reference in New Issue
Block a user
Delete Branch "fix/web-duplicate-rate-mapping"
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?
根因
apps/web/src/api/products/utils.ts的mapVideoToProductItem函数中duplicate_rate被硬编码为undefined:虽然后端 API 已经返回了
duplicate_rate字段(VideoItemResponseschema 确认),但前端映射函数把它写死了undefined。前端链路:
mapVideoToProductItem→duplicate_rate: undefinedProductCard→duplicateRate = item.duplicate_rate ?? 0→0duplicateRate > 0 ? "X%" : "-"→0 > 0 = false→"-"所以无论后端返回什么值,前端永远显示 "-"。
修复
types.ts—VideoItem接口增加duplicate_rate?: number字段utils.ts—mapVideoToProductItem改为duplicate_rate: video.duplicate_rate影响范围
仅前端代码,不涉及后端/API/DB 变更。
【阻塞级判定】
📊 审查概览
🔴 阻塞级问题(必须修复)
无
💡 改进建议(不阻塞合并)
无
✅ 良好实践
VideoItem接口中正确使用了可选类型duplicate_rate?: number,确保了在旧版本接口数据未包含该字段时,TypeScript 编译不会报错,保证了向后兼容性。mapVideoToProductItem函数直接映射了新增字段,逻辑简单直接,符合预期。🤖 由 AI 代码审查机器人自动生成 | 2026-09-01 07:18:34 | 模型:
🚀 预览环境已部署
🗑️ 预览环境已清理
PR #1608 已关闭或合并,对应的预览环境已被清理。