fix(send): 修复文件上传进度计算逻辑

- 将进度字段类型从 double 改为 decimal 以提高精度
- 移除原有的进度更新频率限制逻辑
- 重构进度计算公式,使用已完成项目数与总项目数的比例
- 修复除零错误的处理逻辑
- 更新文件计数显示格式为完成数量/总数量
dev2.0
一梦千年 2026-01-20 10:45:58 +08:00
parent 2df02c7136
commit fad06a926b
1 changed files with 9 additions and 7 deletions

View File

@ -203,9 +203,9 @@ namespace HeBianGu.App.Disk
//文件上传进度
private double _progress;
private decimal _progress;
public double Progress
public decimal Progress
{
get { return _progress; }
set
@ -549,19 +549,21 @@ namespace HeBianGu.App.Disk
private void UpdateProgress(object sender, ElapsedEventArgs e)
{
if (UpLoadItems.Count == 0) return;
// 限制进度更新频率
var now = DateTime.Now;
/*// 限制进度更新频率
if ((now - _lastProgressUpdate).TotalMilliseconds < 500) // 至少500ms更新一次
{
return;
}
double currentBytes = UpLoadItems.Sum(r => r.Double2);
double totalBytes = UpLoadItems.Sum(r => r.Double1);
double totalBytes = UpLoadItems.Sum(r => r.Double1);*/
FileCount = (CompleteItems.Count) + "/" + (UpLoadItems.Count + CompleteItems.Count);
// 避免除零错误
double progress = totalBytes > 0 ? Math.Round((currentBytes / totalBytes) * 100, 2) : 0;
var progress = UpLoadItems.Count > 0
? Math.Round((decimal)(CompleteItems.Count / (UpLoadItems.Count + CompleteItems.Count)) * 100, 2)
: 0;
Application.Current.Dispatcher.Invoke(() =>
{