优化调整

This commit is contained in:
zhongluofeng
2026-08-14 17:47:06 +08:00
parent 6c7897bf47
commit 7d49a7395f
50 changed files with 2805 additions and 259 deletions
+6 -3
View File
@@ -761,7 +761,7 @@ impl DownloadEngine {
last_time = now;
// 更新任务状态 + 发送进度事件
let total_size = {
let (total_size, live_status) = {
let mut tasks = engine.inner.tasks.lock().unwrap_or_else(|e| e.into_inner());
if let Some(task) = tasks.get_mut(&id_monitor) {
task.completed_size = completed;
@@ -771,7 +771,10 @@ impl DownloadEngine {
seg.completed = prog.load(Ordering::Relaxed);
}
}
task.total_size
// 读取任务实时状态而非硬编码 Active:
// 暂停后监控循环 break 前可能发出的最后一次事件
// 必须携带 Paused,否则前端会把任务状态覆盖回"下载中"
(task.total_size, task.status.clone())
} else {
break;
}
@@ -784,7 +787,7 @@ impl DownloadEngine {
completed_size: completed,
total_size,
speed,
status: TaskStatus::Active,
status: live_status,
},
);
}