From 4bf5935b06863102aa462437d6f476da815418ec Mon Sep 17 00:00:00 2001 From: imeepos Date: Fri, 26 Sep 2025 23:04:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=8D=A1=E7=89=87=E5=92=8C=E9=A1=B5=E9=9D=A2=E7=9A=84=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=AE=89=E5=85=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复TemplateCard组件中url字段的可选类型处理 - 修复home页面中模板类型字段名称错误(templateType -> code) - 修复result页面中任务状态判断逻辑(processing -> running) - 增强代码类型安全,避免运行时错误 --- src/components/TemplateCard/index.tsx | 14 +++++++------- src/pages/home/index.tsx | 2 +- src/pages/result/index.tsx | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/TemplateCard/index.tsx b/src/components/TemplateCard/index.tsx index f5d243b..f921966 100644 --- a/src/components/TemplateCard/index.tsx +++ b/src/components/TemplateCard/index.tsx @@ -18,12 +18,12 @@ export default function TemplateCard({ template, onClick }: TemplateCardProps) { // 检测output是否为视频 const isOutputVideo = useMemo(() => { - return /\.(mp4|webm|ogg|mov|avi|mkv|flv)$/i.test(template.outputExampleUrl); + return /\.(mp4|webm|ogg|mov|avi|mkv|flv)$/i.test(template.outputExampleUrl || ''); }, [template.outputExampleUrl]); // 检测input是否为视频 const isInputVideo = useMemo(() => { - return /\.(mp4|webm|ogg|mov|avi|mkv|flv)$/i.test(template.inputExampleUrl); + return /\.(mp4|webm|ogg|mov|avi|mkv|flv)$/i.test(template.inputExampleUrl || ``); }, [template.inputExampleUrl]); const handleClick = () => { @@ -86,10 +86,10 @@ export default function TemplateCard({ template, onClick }: TemplateCardProps) { {isOutputVideo ? ( // 当output是视频时,只显示单个视频 - + @@ -138,7 +138,7 @@ export default function TemplateCard({ template, onClick }: TemplateCardProps) { clipPath: `polygon(${splitPosition}% 0%, 100% 0%, 100% 100%, ${splitPosition}% 100%)`, }} > - + {/* 可拖拽的分割线 */} diff --git a/src/pages/home/index.tsx b/src/pages/home/index.tsx index 906aeeb..063a95a 100644 --- a/src/pages/home/index.tsx +++ b/src/pages/home/index.tsx @@ -92,7 +92,7 @@ export default function Home() { const handleTemplateClick = async (template: Template) => { try { // 第一步:选择并上传图片 - const imageCount = template.templateType === '2image-to-video' ? 2 : 1; + const imageCount = template.code === '2image-to-video' ? 2 : 1; const imageUrl = await sdk.chooseAndUploadImage({ count: imageCount, onImageSelected: () => { diff --git a/src/pages/result/index.tsx b/src/pages/result/index.tsx index 90b76b7..41ad505 100644 --- a/src/pages/result/index.tsx +++ b/src/pages/result/index.tsx @@ -30,9 +30,9 @@ const ResultPage: React.FC = () => { return; } else if (result.status === 'failed') { // 任务失败,停止轮询并设置错误 - setError(result.error || result.errorMessage || '任务执行失败'); + setError('任务执行失败'); return; - } else if (result.status === 'processing' || result.status === 'pending') { + } else if (result.status === 'running' || result.status === 'pending') { // 任务仍在进行中,继续轮询 if (attempts < maxAttempts) { timerRef.current = setTimeout(poll, 1000);