From 72a1b44cca5a83294d510d05a6ce2aca3efb0ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=BC=9F?= <421281095@qq.com> Date: Tue, 22 Apr 2025 14:01:48 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=B7=B2=E5=AE=8C=E6=88=90=E5=80=92?= =?UTF-8?q?=E5=BA=8F=EF=BC=88=E6=9C=AA=E5=AE=8C=E6=88=90=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Services/MinioDownloadTask.cs | 1 + ViewModel/Send/DownViewModel.cs | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Services/MinioDownloadTask.cs b/Services/MinioDownloadTask.cs index 75e5cc7..a1a9727 100644 --- a/Services/MinioDownloadTask.cs +++ b/Services/MinioDownloadTask.cs @@ -205,6 +205,7 @@ public class MinioDownloadTask : NotifyPropertyChangedBase }, offset: offset); Status = "已完成"; updateTask.Status = Status; + updateTask.Downloaded = TotalSize; updateTask.FinishedTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); using (var client = SqlSugarConfig.GetSqlSugarScope()) { diff --git a/ViewModel/Send/DownViewModel.cs b/ViewModel/Send/DownViewModel.cs index c1e6f6f..9227fbc 100644 --- a/ViewModel/Send/DownViewModel.cs +++ b/ViewModel/Send/DownViewModel.cs @@ -1,8 +1,10 @@ using System.Collections.Concurrent; using System.Collections.ObjectModel; +using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Windows; +using System.Windows.Data; using System.Windows.Input; using HeBianGu.Base.WpfBase; using HeBianGu.Service.Mvc; @@ -140,6 +142,18 @@ public class DownViewModel : MvcViewModelBase } } + private CollectionViewSource _finishedTasksViewSource; + + public CollectionViewSource FinishedTasksViewSource + { + get => _finishedTasksViewSource; + set + { + _finishedTasksViewSource = value; + RaisePropertyChanged(); // 触发INotifyProperty + } + } + private int _maxConcurrent = 3; public int MaxConcurrent @@ -167,6 +181,8 @@ public class DownViewModel : MvcViewModelBase public DownViewModel(MinioService minioService) { _minioService = minioService; + FinishedTasksViewSource = new CollectionViewSource { Source = FinishedTasks }; + FinishedTasksViewSource.SortDescriptions.Add(new SortDescription("FinishedTime", ListSortDirection.Descending)); Console.WriteLine("初始化DownViewModel"); using var client = SqlSugarConfig.GetSqlSugarScope(); OpenDownItemFolder = new RelayCommand(DoOpenDownItemFolder); @@ -188,7 +204,7 @@ public class DownViewModel : MvcViewModelBase { item.Status = "已暂停"; item.StartOrPauseIcon = "\xe748"; - // 速度及剩余时间 + // 速度及剩余时间(视图显示信息) item.Speed = "已暂停"; //暂停下载 item.StopDownTs.Cancel(); @@ -247,6 +263,11 @@ public class DownViewModel : MvcViewModelBase { if (_taskQueue.TryDequeue(out var task)) { + if (task.Status == "已暂停") + { + // 跳过暂停,但之前已加入队列 + continue; + } Console.WriteLine("存在可下载任务,正在申请许可..."); await _semaphore.WaitAsync(); Console.WriteLine("申请下载许可成功!马上开启下载"); @@ -329,7 +350,7 @@ public class DownViewModel : MvcViewModelBase public void DoOpenDownItemFolder(MinioDownloadTask para) { - Console.WriteLine($"点击item值:{JsonConvert.SerializeObject(para)}"); + //Console.WriteLine($"点击item值:{JsonConvert.SerializeObject(para)}"); //Process.Start("explorer.exe", para.FilePath); var file = Path.Combine(para.FilePath, para.FileName); Process.Start("explorer.exe", $"/select,\"{file}\"");