From d4b912b8ce799e7fff6d2fb8a568e7e164d93c4f Mon Sep 17 00:00:00 2001 From: Nlick47 <2247717951@qq.com> Date: Sat, 12 Oct 2024 00:05:54 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=A1=A5=E5=85=A8=E6=89=93?= =?UTF-8?q?=E5=BC=80=E6=96=87=E4=BB=B6=E5=A4=B9=E5=90=8E=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DownloadManager/DownloadedItem.cs | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs b/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs index 31dd33e..3511788 100644 --- a/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs +++ b/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs @@ -93,13 +93,13 @@ namespace DownKyi.ViewModels.DownloadManager public DelegateCommand OpenFolderCommand => _openFolderCommand ??= new DelegateCommand(ExecuteOpenFolderCommand); - private static IReadOnlyDictionary FileSuffixMap = new Dictionary + private static IReadOnlyDictionary FileSuffixMap = new Dictionary { - { "downloadVideo", ".mp4" }, - { "downloadAudio", ".aac" }, - { "downloadCover", ".jpg" }, - { "downloadDanmaku",".ass"}, - { "downloadSubtitle",".srt"} + { "downloadVideo", new[] { ".mp4", ".flv" } }, + { "downloadAudio", new[] { ".aac", ".mp3" } }, + { "downloadCover", new[] { ".jpg" } }, + { "downloadDanmaku", new[] { ".ass" } }, + { "downloadSubtitle", new[] { ".srt" } } }; /// /// 打开文件夹事件 @@ -111,20 +111,24 @@ namespace DownKyi.ViewModels.DownloadManager return; } var downLoadContents = DownloadBase.NeedDownloadContent.Where(e => e.Value == true).Select(e => e.Key); - var fileSuffix = downLoadContents - .Where(content => FileSuffixMap.ContainsKey(content)) - .Select(content => FileSuffixMap[content]) - .FirstOrDefault(); - var videoPath = $"{DownloadBase.FilePath}{fileSuffix}"; - var fileInfo = new FileInfo(videoPath); - if (File.Exists(fileInfo.FullName) && fileInfo.DirectoryName != null) + var fileSuffixes = downLoadContents + .Where(content => FileSuffixMap.ContainsKey(content)) + .SelectMany(content => FileSuffixMap[content]) + .ToArray(); + if (fileSuffixes.Length > 0) { - PlatformHelper.OpenFolder(fileInfo.DirectoryName); - } - else - { - //eventAggregator.GetEvent().Publish("没有找到视频文件,可能被删除或移动!"); + foreach (var suffix in fileSuffixes) + { + var videoPath = $"{DownloadBase.FilePath}{suffix}"; + var fileInfo = new FileInfo(videoPath); + if (File.Exists(fileInfo.FullName) && fileInfo.DirectoryName != null) + { + PlatformHelper.OpenFolder(fileInfo.DirectoryName); + return; + } + } } + // eventAggregator.GetEvent().Publish("没有找到视频文件,可能被删除或移动!"); } // 打开视频事件