diff --git a/frontend/app/web-gold/src/views/kling/IdentifyFace.vue b/frontend/app/web-gold/src/views/kling/IdentifyFace.vue index bd30c471e6..a346f7eb4d 100644 --- a/frontend/app/web-gold/src/views/kling/IdentifyFace.vue +++ b/frontend/app/web-gold/src/views/kling/IdentifyFace.vue @@ -131,7 +131,14 @@
- +

{{ videoState.videoFile?.name }}

@@ -262,6 +269,7 @@ const { handleSelectFromLibrary, handleVideoSelect, handleVideoLoaded, + handleVideoError, replaceVideo, // UI 辅助方法 diff --git a/frontend/app/web-gold/src/views/kling/hooks/useDigitalHumanGeneration.ts b/frontend/app/web-gold/src/views/kling/hooks/useDigitalHumanGeneration.ts index e9e2c107e6..1d869d0f62 100644 --- a/frontend/app/web-gold/src/views/kling/hooks/useDigitalHumanGeneration.ts +++ b/frontend/app/web-gold/src/views/kling/hooks/useDigitalHumanGeneration.ts @@ -59,6 +59,11 @@ export function useDigitalHumanGeneration() { return } + // 释放旧的 blob URL + if (videoState.value.uploadedVideo && videoState.value.uploadedVideo.startsWith('blob:')) { + URL.revokeObjectURL(videoState.value.uploadedVideo) + } + videoState.value.videoFile = file videoState.value.uploadedVideo = URL.createObjectURL(file) videoState.value.selectedVideo = null @@ -119,6 +124,10 @@ export function useDigitalHumanGeneration() { } function resetVideoState(): void { + // 释放 blob URL 避免内存泄漏 + if (videoState.value.uploadedVideo && videoState.value.uploadedVideo.startsWith('blob:')) { + URL.revokeObjectURL(videoState.value.uploadedVideo) + } videoState.value.uploadedVideo = '' videoState.value.videoFile = null videoState.value.selectedVideo = null diff --git a/frontend/app/web-gold/src/views/kling/hooks/useIdentifyFaceController.ts b/frontend/app/web-gold/src/views/kling/hooks/useIdentifyFaceController.ts index 245b0c1d97..7db2894f0c 100644 --- a/frontend/app/web-gold/src/views/kling/hooks/useIdentifyFaceController.ts +++ b/frontend/app/web-gold/src/views/kling/hooks/useIdentifyFaceController.ts @@ -290,6 +290,11 @@ export function useIdentifyFaceController() { digitalHuman.videoState.value.previewVideoUrl = videoUrl } + function handleVideoError(event: Event): void { + console.error('视频加载失败:', event) + message.error('视频无法播放,请尝试其他视频文件') + } + // ==================== UI 工具方法 ==================== function formatDuration(seconds: number): string { @@ -347,6 +352,7 @@ export function useIdentifyFaceController() { handleSelectFromLibrary, handleVideoSelect, handleVideoLoaded, + handleVideoError, // UI 工具 formatDuration,