diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index da8ebbe..6c2387d 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -741,9 +741,8 @@ const VideoSourceConfig = ({ const handleSelectAll = (checked: boolean) => { if (checked) { - // 只选择可删除的视频源(from !== 'config') - const deletableSources = sources.filter(source => source.from !== 'config'); - setSelectedSources(new Set(deletableSources.map(source => source.key))); + // 选择所有视频源(包括示例源) + setSelectedSources(new Set(sources.map(source => source.key))); } else { setSelectedSources(new Set()); } @@ -757,68 +756,43 @@ const VideoSourceConfig = ({ const selectedArray = Array.from(selectedSources); const result = await Swal.fire({ - title: '确认批量删除', - text: `即将删除 ${selectedArray.length} 个视频源,此操作不可撤销!`, + title: '⚡ 一键批量删除', + html: ` +
即将瞬间删除 ${selectedArray.length} 个视频源
+包含所有选中的视频源(含示例源)
+⚠️ 此操作不可撤销!
+ `, icon: 'warning', showCancelButton: true, - confirmButtonText: '确认删除', + confirmButtonText: '⚡ 瞬间删除', cancelButtonText: '取消', confirmButtonColor: '#ef4444', - cancelButtonColor: '#6b7280' + cancelButtonColor: '#6b7280', + showLoaderOnConfirm: true, + allowOutsideClick: () => !Swal.isLoading(), + preConfirm: async () => { + try { + // 并行删除所有选中的视频源,实现真正的一键删除 + const deletePromises = selectedArray.map(key => + callSourceApi({ action: 'delete', key }) + ); + + await Promise.all(deletePromises); + return { success: true, count: selectedArray.length }; + } catch (error) { + Swal.showValidationMessage( + `删除失败: ${error instanceof Error ? error.message : '未知错误'}` + ); + return false; + } + } }); - if (!result.isConfirmed) return; - - // 批量删除 - let successCount = 0; - let errorCount = 0; - const errors: string[] = []; - - for (const key of selectedArray) { - try { - await callSourceApi({ action: 'delete', key }); - successCount++; - } catch (error) { - errorCount++; - const sourceName = sources.find(s => s.key === key)?.name || key; - errors.push(`${sourceName}: ${error instanceof Error ? error.message : '删除失败'}`); - } - } - - // 显示删除结果 - if (errorCount === 0) { - showSuccess(`成功删除 ${successCount} 个视频源`); - setSelectedSources(new Set()); // 清空选择 - setBatchMode(false); // 退出批量模式 - } else { - await Swal.fire({ - title: '删除完成', - html: ` -✅ 成功删除: ${successCount} 个
-❌ 删除失败: ${errorCount} 个
- ${errors.length > 0 ? ` -