fix(send): 修复文件上传进度计算错误

- 修正了进度计算公式,将乘以100移到分子位置避免整数除法精度丢失
- 在上传完成事件中添加了进度计算的条件判断防止除零错误
- 增加了控制台输出用于调试当前上传进度
- 统一了进度计算逻辑确保数值准确性
dev2.0
一梦千年 2026-01-25 16:50:20 +08:00
parent 71194a02b6
commit 0718a29850
1 changed files with 6 additions and 2 deletions

View File

@ -562,7 +562,7 @@ namespace HeBianGu.App.Disk
FileCount = (CompleteItems.Count) + "/" + (UpLoadItems.Count + CompleteItems.Count);
// 避免除零错误
var progress = UpLoadItems.Count > 0
? Math.Round((decimal)(CompleteItems.Count / (UpLoadItems.Count + CompleteItems.Count)) * 100, 2)
? Math.Round((decimal)(CompleteItems.Count * 100/ (UpLoadItems.Count + CompleteItems.Count)) , 2)
: 0;
Application.Current.Dispatcher.Invoke(() =>
@ -831,7 +831,11 @@ namespace HeBianGu.App.Disk
// 触发上传完成事件
FileUploadCompleted?.Invoke(CurrentMinIOPath);
Progress = (CompleteItems.Count) / (UpLoadItems.Count + CompleteItems.Count);
Progress = UpLoadItems.Count > 0
? Math.Round((decimal)(CompleteItems.Count * 100/ (UpLoadItems.Count + CompleteItems.Count)) ,
2)
: 0;
Console.WriteLine($"当前上传进度:{Progress}%");
// 更新网盘空间页面状态
/*if (_explorerBehavior != null)
{