From d2ea8ba57971375711bea95feb2eb5cd0205a90f Mon Sep 17 00:00:00 2001 From: CI Bot Date: Wed, 15 Jul 2026 13:45:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20TemplateItem=20=E7=B1=BB=E5=9E=8B=20esti?= =?UTF-8?q?mated=5Fduration=20=E5=AD=97=E6=AE=B5=E5=AF=B9=E9=BD=90?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - TemplateItem 新增 estimated_duration 字段,匹配后端实际返回字段名 - target_duration 标记为 deprecated,保留向后兼容 - TemplateLibrary 两处引用改为 estimated_duration ?? target_duration 回退 - 新增 mode/user_id 可选字段,description/clip_count/is_active 改 optional 修复模板卡片时长显示 NaN 问题(根因:前端读 target_duration 但后端返回 estimated_duration) --- apps/web/src/api/templates.ts | 13 +++++++++---- apps/web/src/pages/templates/TemplateLibrary.tsx | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/web/src/api/templates.ts b/apps/web/src/api/templates.ts index 626a196a8..dc132f1dc 100644 --- a/apps/web/src/api/templates.ts +++ b/apps/web/src/api/templates.ts @@ -16,17 +16,22 @@ import type { EditPlanConfig } from "./editPlans"; /** 模板条目(后端 TemplateResponse) */ export interface TemplateItem { id: string; + user_id?: string; name: string; - description: string; + description?: string; + mode?: string; category: string; tags?: string[]; - target_duration: number; - clip_count: number; + /** 预估时长(后端字段名 estimated_duration) */ + estimated_duration?: number; + /** @deprecated 后端已改名为 estimated_duration,保留兼容 */ + target_duration?: number; + clip_count?: number; /** 使用次数 */ usage_count?: number; thumbnail_url?: string; preview_url?: string; - is_active: boolean; + is_active?: boolean; is_favorite?: boolean; /** 素材规则(片段配置) */ segments?: TemplateSegment[]; diff --git a/apps/web/src/pages/templates/TemplateLibrary.tsx b/apps/web/src/pages/templates/TemplateLibrary.tsx index 9b4ad6265..d0b478ade 100644 --- a/apps/web/src/pages/templates/TemplateLibrary.tsx +++ b/apps/web/src/pages/templates/TemplateLibrary.tsx @@ -236,7 +236,7 @@ const TemplateDetailModal: React.FC = ({ { key: "duration", label: "目标时长", - children: formatDuration(template.target_duration), + children: formatDuration(template.estimated_duration ?? template.target_duration), }, { key: "clips", @@ -408,7 +408,7 @@ const TemplateCard: React.FC = ({
{template.name}
- {formatDuration(template.target_duration)} + {formatDuration(template.estimated_duration ?? template.target_duration)}
点击查看详情