From bec111444e1257abc82fd1651a584624fb993bef Mon Sep 17 00:00:00 2001 From: thzxx Date: Thu, 18 Jun 2026 13:09:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=86=E9=A2=91=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E5=8C=BA=E5=90=8C=E6=97=B6=E6=B8=B2=E6=9F=93=20pending=20?= =?UTF-8?q?=E5=92=8C=20completedVideos=EF=BC=8C=E4=B8=8D=E5=86=8D=E4=BA=92?= =?UTF-8?q?=E7=9B=B8=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/components/input-area.ts | 42 +++++++++++++++++++-------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/renderer/components/input-area.ts b/src/renderer/components/input-area.ts index 85f9cd3..55ec44c 100644 --- a/src/renderer/components/input-area.ts +++ b/src/renderer/components/input-area.ts @@ -311,25 +311,43 @@ async function handleVideoPath(filePath: string): Promise { } function renderVideoPreview(): void { - if (!pendingVideoMeta || pendingVideoFrames.length === 0) { + const all: Array<{ fileName: string; frameCount: number; duration: number; isPending: boolean }> = []; + if (pendingVideoMeta) { + all.push({ fileName: pendingVideoMeta.fileName, frameCount: pendingVideoFrames.length, duration: pendingVideoMeta.duration, isPending: true }); + } + for (const v of completedVideos) { + all.push({ fileName: v.fileName, frameCount: v.frames.length, duration: v.duration, isPending: false }); + } + + if (all.length === 0) { videoPreviewEl.style.display = 'none'; videoPreviewEl.innerHTML = ''; return; } - const m = pendingVideoMeta; videoPreviewEl.style.display = ''; - videoPreviewEl.innerHTML = ` + videoPreviewEl.innerHTML = all.map((v, i) => { + const meta = v.isPending && v.duration <= 0 ? '提取中...' : `${v.frameCount}帧 · ${v.duration.toFixed(0)}s`; + return `
🎬 - ${escapeHtml(m.fileName)} - ${pendingVideoFrames.length}帧 · ${m.duration.toFixed(0)}s - -
- `; - videoPreviewEl.querySelector('.remove-video')!.addEventListener('click', () => { - pendingVideoFrames = []; - pendingVideoMeta = null; - renderVideoPreview(); + ${escapeHtml(v.fileName)} + ${meta} + + `; + }).join(''); + videoPreviewEl.querySelectorAll('.remove-video').forEach(btn => { + btn.addEventListener('click', (e) => { + const idx = parseInt((e.target as HTMLElement).dataset.idx!); + // 从 all 数组反查是 pending 还是 completed + if (idx === 0 && pendingVideoMeta) { + pendingVideoFrames = []; + pendingVideoMeta = null; + } else { + const completedIdx = pendingVideoMeta ? idx - 1 : idx; + completedVideos.splice(completedIdx, 1); + } + renderVideoPreview(); + }); }); }