From c83f5a4a7e7558c27e23dad62a00e9e4bd3f07f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Fri, 4 Jul 2025 19:38:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=BE=AE=E8=B0=83=E7=A9=BA=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/common/EmptyStateAnimation.tsx | 57 ++++++++++++------- components/pages/create-to-video2.tsx | 31 +++++++--- .../pages/work-flow/use-workflow-data.tsx | 2 +- 3 files changed, 61 insertions(+), 29 deletions(-) diff --git a/components/common/EmptyStateAnimation.tsx b/components/common/EmptyStateAnimation.tsx index a6d377c..7d9c902 100644 --- a/components/common/EmptyStateAnimation.tsx +++ b/components/common/EmptyStateAnimation.tsx @@ -586,10 +586,9 @@ const ImageQueue = ({ shouldStart, onComplete }: { shouldStart: boolean; onCompl const containers = Array.from(imagesRef.current.children) as HTMLElement[]; const videos = containers.map(container => container.querySelector('video')).filter(Boolean) as HTMLVideoElement[]; - if (videos.length > 0) { + const finalVideoContainer = document.getElementById('final-video-container') as HTMLDivElement; + if (videos.length > 0 && finalVideoContainer) { // 创建最终的大视频容器 - const finalVideoContainer = document.createElement('div'); - finalVideoContainer.className = 'fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[600px] rounded-lg overflow-hidden shadow-2xl opacity-0'; const finalVideo = document.createElement('video'); finalVideo.src = finalVideoUrl; @@ -600,7 +599,6 @@ const ImageQueue = ({ shouldStart, onComplete }: { shouldStart: boolean; onCompl finalVideo.className = 'w-full h-full object-cover'; finalVideoContainer.appendChild(finalVideo); - document.body.appendChild(finalVideoContainer); finalVideoContainerRef.current = finalVideoContainer; // 等待最终视频准备就绪 @@ -821,7 +819,7 @@ const ImageQueue = ({ shouldStart, onComplete }: { shouldStart: boolean; onCompl }; // 主要的空状态动画组件 -export const EmptyStateAnimation = () => { +export const EmptyStateAnimation = ({className}: {className: string}) => { const [showText, setShowText] = useState(false); const [showImages, setShowImages] = useState(false); const [animationCycle, setAnimationCycle] = useState(0); @@ -829,21 +827,40 @@ export const EmptyStateAnimation = () => { // 全局清理函数 const globalCleanup = () => { - // 清理所有可能的最终视频容器 - const existingFinalVideos = document.querySelectorAll('div[class*="fixed"][class*="top-1/2"][class*="w-[400px]"]'); - existingFinalVideos.forEach(container => { - if (container.parentNode === document.body) { - container.remove(); + // 清理最终视频容器中的视频元素 + const finalVideoContainer = document.getElementById('final-video-container') as HTMLDivElement; + if (finalVideoContainer) { + const finalVideo = finalVideoContainer.querySelector('video'); + if (finalVideo) { + finalVideo.remove(); + } + // 重置容器透明度 + finalVideoContainer.style.opacity = '0'; + } + + // 清理所有图片容器中的视频元素 + const allVideoElements = document.querySelectorAll('video'); + allVideoElements.forEach(video => { + // 确保视频不是在final-video-container中(已经处理过了) + if (!finalVideoContainer?.contains(video)) { + // 停止播放并移除 + video.pause(); + video.removeAttribute('src'); + video.load(); // 释放资源 + video.remove(); } }); - - // 清理所有body下的视频相关元素 - const bodyChildren = Array.from(document.body.children); - bodyChildren.forEach(child => { - if (child instanceof HTMLElement && - (child.querySelector('video') || child.tagName === 'VIDEO')) { - child.remove(); - } + + // 清理任何可能遗留的视频容器 + const imageContainers = document.querySelectorAll('[class*="w-[200px]"][class*="h-[150px]"]'); + imageContainers.forEach(container => { + const videos = container.querySelectorAll('video'); + videos.forEach(video => { + video.pause(); + video.removeAttribute('src'); + video.load(); + video.remove(); + }); }); }; @@ -899,7 +916,7 @@ export const EmptyStateAnimation = () => { } return ( -