From 4e35a2c85537a6490eaf4d39e2bc282e7c36233f Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 5 Aug 2026 00:36:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Q5=20=E6=99=BA=E8=83=BD=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E5=89=8D=E7=AB=AF=E7=AE=80=E5=8C=96=20=E2=80=94=20?= =?UTF-8?q?=E4=B8=80=E9=94=AEAI=E9=80=89=E7=B4=A0=E6=9D=90=20(#1241)=20(#1?= =?UTF-8?q?241)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: xiaoxia Co-committed-by: xiaoxia --- apps/web/src/api/assets/assets.ts | 11 ++ apps/web/src/api/assets/index.ts | 3 +- .../components/Step2MaterialSelect.tsx | 4 +- .../components/material/SmartMatchCard.tsx | 18 +-- .../components/material/SmartMatchInput.tsx | 36 ++--- .../components/material/SmartMatchResults.tsx | 35 ++--- apps/web/src/pages/generate/generate.css | 45 ++---- .../hooks/step2-materials/useSmartMatch.ts | 144 ++++++++---------- .../pages/generate/hooks/useStep2Materials.ts | 7 +- apps/web/src/test/pages/GeneratePage.test.tsx | 1 + 10 files changed, 119 insertions(+), 185 deletions(-) diff --git a/apps/web/src/api/assets/assets.ts b/apps/web/src/api/assets/assets.ts index 902aface1..d54e52c54 100644 --- a/apps/web/src/api/assets/assets.ts +++ b/apps/web/src/api/assets/assets.ts @@ -49,6 +49,17 @@ export const getAssetsByKind = async ( return response.data.items || [] } +/** + * 智能匹配素材(后端 AI 选素材) + * 调用后端 smart-match 端点,由后端根据素材库内容智能选择素材 + */ +export const smartMatchAssets = async (libraryId: string): Promise<{ items: AssetItem[] }> => { + const response = await apiClient.post("/assets/smart-match", { + library_id: libraryId, + }) + return response.data +} + /** 创建素材(上传文件后调用,附带 metadata) */ export const createAsset = async (data: { library_id: string diff --git a/apps/web/src/api/assets/index.ts b/apps/web/src/api/assets/index.ts index a69db9a6c..22654854e 100644 --- a/apps/web/src/api/assets/index.ts +++ b/apps/web/src/api/assets/index.ts @@ -29,10 +29,11 @@ export { deleteAssetLibrary, } from "./libraries" -// 素材 CRUD +// 素材 CRUD + 智能匹配 export { getAssets, getAssetsByKind, + smartMatchAssets, createAsset, updateAsset, updateAssetReviewStatus, diff --git a/apps/web/src/pages/generate/components/Step2MaterialSelect.tsx b/apps/web/src/pages/generate/components/Step2MaterialSelect.tsx index 905c38829..395916d42 100644 --- a/apps/web/src/pages/generate/components/Step2MaterialSelect.tsx +++ b/apps/web/src/pages/generate/components/Step2MaterialSelect.tsx @@ -65,8 +65,6 @@ const Step2MaterialSelect: React.FC = (props) => { {m.materialMode === "auto" && (
= (props) => { /> void formatDuration: (seconds: number) => string } const SmartMatchCard: React.FC = ({ - result, + asset, selected, onClick, formatDuration, }) => { - const { asset, matchScore, matchReason } = result return (
{/* 缩略图 */} @@ -36,7 +30,6 @@ const SmartMatchCard: React.FC = ({
)} -
{matchScore}%
{selected && (
@@ -46,12 +39,11 @@ const SmartMatchCard: React.FC = ({
{formatDuration(asset.duration)}
)}
- {/* 信息区 */} + {/* 名称 */}
{asset.name}
-
🎯 {matchReason}
) diff --git a/apps/web/src/pages/generate/components/material/SmartMatchInput.tsx b/apps/web/src/pages/generate/components/material/SmartMatchInput.tsx index 4cb6be046..875d911a3 100644 --- a/apps/web/src/pages/generate/components/material/SmartMatchInput.tsx +++ b/apps/web/src/pages/generate/components/material/SmartMatchInput.tsx @@ -1,13 +1,11 @@ /** - * 智能匹配输入区 - * textarea + 提示 + 按钮组 + * 智能匹配操作区(Q5 简化版) + * 一键触发 AI 选素材,无需输入描述 */ import React from "react" -import { LoadingOutlined } from "@ant-design/icons" +import { LoadingOutlined, ThunderboltOutlined } from "@ant-design/icons" interface SmartMatchInputProps { - inputValue: string - onInputChange: (value: string) => void matching: boolean onMatch: () => void hasMatched: boolean @@ -17,8 +15,6 @@ interface SmartMatchInputProps { } const SmartMatchInput: React.FC = ({ - inputValue, - onInputChange, matching, onMatch, hasMatched, @@ -28,22 +24,9 @@ const SmartMatchInput: React.FC = ({ }) => { return (
- -