feat: Q5 智能匹配前端简化 — 一键AI选素材 (#1241) #1241
Reference in New Issue
Block a user
Delete Branch "feat/smart-match-simplify"
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?
改动概要
Q5 智能匹配前端简化:去掉「输入描述→匹配→确认」的冗余流程,改为一键触发 AI 选素材。
改动文件
apps/web/src/api/assets/assets.ts— 新增smartMatchAssets()API 函数,调用POST /assets/smart-matchapps/web/src/api/assets/index.ts— 导出smartMatchAssetshooks/step2-materials/useSmartMatch.ts— 重写:去掉描述输入/随机匹配/匹配分数,改为一键调用后端 API,失败时回退全选hooks/useStep2Materials.ts— 适配新 hook 接口(传入libraryId,移除smartMatchInput/smartMatchedResults)components/material/SmartMatchInput.tsx— 简化为一键按钮「让 AI 帮你选」,无 textareacomponents/material/SmartMatchResults.tsx— 简化为直接展示选中素材,无匹配分数/理由components/material/SmartMatchCard.tsx— 移除matchScore/matchReason,只保留缩略图+名称+时长components/Step2MaterialSelect.tsx— 适配新组件 propsgenerate.css— 移除 textarea/score/reason 相关样式,新增 action-row 布局test/pages/GeneratePage.test.tsx— 新增smartMatchAssetsmock行为变化
注意
POST /assets/smart-match端点尚未实现,当前调用失败时回退为全选当前库素材🚀 预览环境已部署
CI全绿,自动审批通过。
CI全绿,自动审批通过。
代码审查结果 - PR #1241
⚠️ 问题(1个需要修改)
handleSelectAllMatched逻辑错误。该函数用于在智能匹配结果区点击“全选”按钮,预期行为是选中所有 AI 推荐的素材(即smartMatchedResults)。但当前代码实现为materials.items.map(...),这会选中整个素材库的所有素材。如果素材库包含大量素材,这将导致用户意外选中所有非推荐素材,造成严重的功能逻辑偏差和潜在的性能问题。应修改为遍历smartMatchedResults。💡 建议(1个可选)
const resolved = result.items?.length ? result.items : ...优先使用了 API 返回的对象。如果后端smart-match接口返回的AssetItem对象不完整(例如缺少前端渲染所需的duration、url或thumb等字段),会导致 UI 渲染报错或显示异常。建议始终通过 ID 从本地materials.items中映射查找完整对象,以确保数据结构的一致性。✅ 格式检查通过 | ❌ 逻辑审查需修改 | ✅ 建议关注性能
🤖 由 AI 代码审查机器人自动生成 | 2026-08-04 16:32:54 | 模型:
🗑️ 预览环境已清理
PR #1241 已关闭或合并,对应的预览环境已被清理。