fix(video-history): 失败或中断任务自动移除历史卡片
This commit is contained in:
1 parent
a3f2009eb1
commit
b74c507e2e
2 files changed
+39
-2
No files matched your search
@@ -134,6 +134,32 @@
|
||||
historyCount.textContent = String(count);
|
||||
}
|
||||
|
||||
function removePreviewItem(item) {
|
||||
if (!item || !videoStage) return;
|
||||
const idx = String(item.dataset.index || '');
|
||||
const url = String(item.dataset.url || '').trim();
|
||||
if (selectedVideoItemId && selectedVideoItemId === idx) {
|
||||
selectedVideoItemId = '';
|
||||
selectedVideoUrl = '';
|
||||
if (enterEditBtn) enterEditBtn.disabled = true;
|
||||
closeEditPanel();
|
||||
}
|
||||
if (mergeTargetVideoUrl && url && mergeTargetVideoUrl === url) {
|
||||
mergeTargetVideoUrl = '';
|
||||
mergeTargetVideoName = '';
|
||||
}
|
||||
item.remove();
|
||||
const hasAny = videoStage.querySelector('.video-item');
|
||||
if (!hasAny) {
|
||||
videoStage.classList.add('hidden');
|
||||
if (videoEmpty) videoEmpty.classList.remove('hidden');
|
||||
}
|
||||
updateHistoryCount();
|
||||
refreshVideoSelectionUi();
|
||||
updateMergeLabels();
|
||||
updateManualActionsVisibility();
|
||||
}
|
||||
|
||||
function updateMergeLabels() {
|
||||
if (mergeVideoA) {
|
||||
mergeVideoA.textContent = selectedVideoUrl ? shortHash(selectedVideoUrl) : '-';
|
||||
@@ -1356,11 +1382,16 @@
|
||||
if (!taskState || taskState.done) {
|
||||
return;
|
||||
}
|
||||
const previewItem = taskState.previewItem || null;
|
||||
const hasVideoUrl = Boolean(previewItem && String(previewItem.dataset.url || '').trim());
|
||||
taskState.done = true;
|
||||
if (!hasError) {
|
||||
if (!hasError && hasVideoUrl) {
|
||||
taskState.progress = 100;
|
||||
} else {
|
||||
hasRunError = true;
|
||||
if (previewItem) {
|
||||
removePreviewItem(previewItem);
|
||||
}
|
||||
}
|
||||
if (taskState.source) {
|
||||
try {
|
||||
@@ -1506,6 +1537,12 @@
|
||||
if (authHeader !== null) {
|
||||
await stopVideoTask(activeTaskIds, authHeader);
|
||||
}
|
||||
taskStates.forEach((taskState) => {
|
||||
if (!taskState || taskState.done) return;
|
||||
if (taskState.previewItem) {
|
||||
removePreviewItem(taskState.previewItem);
|
||||
}
|
||||
});
|
||||
closeAllSources();
|
||||
isRunning = false;
|
||||
taskStates = new Map();
|
||||
|
||||
@@ -307,7 +307,7 @@
|
||||
<script src="/static/common/js/pwa.js?v=0.1.1"></script>
|
||||
<script src="/static/vendor/ffmpeg/ffmpeg.js?v=0.1.0"></script>
|
||||
<script src="/static/vendor/ffmpeg/ffmpeg-util.js?v=0.1.0"></script>
|
||||
<script src="/static/public/js/video.js?v=0.5.11"></script>
|
||||
<script src="/static/public/js/video.js?v=0.5.12"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in new issue
Block a user