From fad06a926b496cef7fc636b0fb25efb3cfce9269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E6=A2=A6=E5=8D=83=E5=B9=B4?= <421281095@qq.com> Date: Tue, 20 Jan 2026 10:45:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(send):=20=E4=BF=AE=E5=A4=8D=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0=E8=BF=9B=E5=BA=A6=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将进度字段类型从 double 改为 decimal 以提高精度 - 移除原有的进度更新频率限制逻辑 - 重构进度计算公式,使用已完成项目数与总项目数的比例 - 修复除零错误的处理逻辑 - 更新文件计数显示格式为完成数量/总数量 --- ViewModel/Send/SendViewModel.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ViewModel/Send/SendViewModel.cs b/ViewModel/Send/SendViewModel.cs index e0b1ba4..3b1ed16 100644 --- a/ViewModel/Send/SendViewModel.cs +++ b/ViewModel/Send/SendViewModel.cs @@ -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(() => {