From 1a9ec06ec2c3b7db51a8b401be9b715cb8d442bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E5=BD=AA?= <1315508912@qq.com> Date: Tue, 7 May 2024 22:28:25 +0800 Subject: [PATCH] chore(release): prepare for 1.0.10 --- CHANGELOG.md | 10 + DownKyi.Core/Storage/StorageCover.cs | 24 +-- DownKyi.Core/Storage/StorageUtils.cs | 2 +- DownKyi/Models/AppInfo.cs | 2 +- DownKyi/Utils/NavigateToView.cs | 6 +- DownKyi/ViewModels/ViewFriendsViewModel.cs | 2 +- DownKyi/ViewModels/ViewIndexViewModel.cs | 7 +- .../ViewModels/ViewPublicationViewModel.cs | 198 ++++++++---------- script/macos/Info.plist | 2 +- version.txt | 2 +- 10 files changed, 126 insertions(+), 129 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bfc57b..37bb6c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## [1.0.10] - 2024-05-07 + +### Bug Fixes + +- 修复多分类错误应用解析项问题 Fixes: #79 +- 修复没有可以打开网址的程序导致的打开链接崩溃的问题 Fixes: #84 +- 移除TextTrimming="CharacterEllipsis"导致的带有emoji的textblock崩溃 Fixes: #86 +- 修复样式问题 Fixes: #80 +- 修复下载时开启自动添加后缀文件夹不存在时闪退问题 Fixes: #78 #74 + ## [1.0.9] - 2024-04-08 ### Bug Fixes diff --git a/DownKyi.Core/Storage/StorageCover.cs b/DownKyi.Core/Storage/StorageCover.cs index 719b0a2..14339a6 100644 --- a/DownKyi.Core/Storage/StorageCover.cs +++ b/DownKyi.Core/Storage/StorageCover.cs @@ -27,7 +27,7 @@ public class StorageCover /// public Bitmap GetCoverThumbnail(long avid, string bvid, long cid, string url, int width, int height) { - string header = GetCover(avid, bvid, cid, url); + var header = GetCover(avid, bvid, cid, url); return GetCoverThumbnail(header, width, height); } @@ -48,7 +48,7 @@ public class StorageCover try { - Bitmap bitmap = new Bitmap(cover); + var bitmap = new Bitmap(cover); return bitmap.CreateScaledBitmap(new PixelSize(width, height), BitmapInterpolationMode.Unspecified); // return StorageUtils.BitmapToBitmapImage(new Bitmap(thumbnail)); @@ -101,17 +101,17 @@ public class StorageCover /// public string GetCover(long avid, string bvid, long cid, string url) { - CoverDb coverDb = new CoverDb(); - Cover cover = coverDb.QueryByUrl(url); + var coverDb = new CoverDb(); + var cover = coverDb.QueryByUrl(url); // 如果存在,直接返回 // 如果不存在,则先下载 if (cover != null) { - string coverPath = $"{StorageManager.GetCover()}/{cover.Md5}"; + var coverPath = $"{StorageManager.GetCover()}/{cover.Md5}"; if (File.Exists(coverPath)) { - Cover newCover = new Cover + var newCover = new Cover { Avid = avid, Bvid = bvid, @@ -126,7 +126,7 @@ public class StorageCover } else { - string md5 = DownloadImage(url); + var md5 = DownloadImage(url); if (md5 != null) { Cover newCover = new Cover @@ -151,7 +151,7 @@ public class StorageCover } else { - string md5 = DownloadImage(url); + var md5 = DownloadImage(url); if (md5 != null) { Cover newCover = new Cover @@ -182,10 +182,10 @@ public class StorageCover /// private string DownloadImage(string url) { - string localFile = Path.GetTempPath() + Guid.NewGuid().ToString("N"); + var localFile = Path.GetTempPath() + Guid.NewGuid().ToString("N"); // 下载 - bool isSuccessed = StorageUtils.DownloadImage(url, localFile); + var isSuccessed = StorageUtils.DownloadImage(url, localFile); if (isSuccessed) { try @@ -232,7 +232,7 @@ public class StorageCover /// public bool IsLocal(CoverDb coverDb, string url) { - Cover cover = coverDb.QueryByUrl(url); + var cover = coverDb.QueryByUrl(url); return cover != null; } @@ -244,7 +244,7 @@ public class StorageCover /// public string LocalCover(CoverDb coverDb, string url) { - Cover cover = coverDb.QueryByUrl(url); + var cover = coverDb.QueryByUrl(url); return cover.Md5; } } \ No newline at end of file diff --git a/DownKyi.Core/Storage/StorageUtils.cs b/DownKyi.Core/Storage/StorageUtils.cs index 8f67e05..b99fe6f 100644 --- a/DownKyi.Core/Storage/StorageUtils.cs +++ b/DownKyi.Core/Storage/StorageUtils.cs @@ -16,7 +16,7 @@ internal static class StorageUtils { try { - WebClient mywebclient = new WebClient(); + var mywebclient = new WebClient(); mywebclient.DownloadFile(url, localFile); } catch (Exception e) diff --git a/DownKyi/Models/AppInfo.cs b/DownKyi/Models/AppInfo.cs index e3855fe..ae64602 100644 --- a/DownKyi/Models/AppInfo.cs +++ b/DownKyi/Models/AppInfo.cs @@ -11,7 +11,7 @@ public class AppInfo private const int A = 1; private const int B = 0; - private const int C = 9; + private const int C = 10; public AppInfo() { diff --git a/DownKyi/Utils/NavigateToView.cs b/DownKyi/Utils/NavigateToView.cs index a5d55ee..6db4203 100644 --- a/DownKyi/Utils/NavigateToView.cs +++ b/DownKyi/Utils/NavigateToView.cs @@ -15,6 +15,8 @@ public static class NavigateToView /// 如果传入的mid与本地登录的mid一致, /// 则进入我的用户空间。 /// + /// + /// /// public static void NavigateToViewUserSpace(IEventAggregator eventAggregator, string parentViewName, long mid) { @@ -32,9 +34,11 @@ public static class NavigateToView /// /// 导航到其他页面 /// + /// /// + /// /// - public static void NavigationView(IEventAggregator eventAggregator, string viewName, string parentViewName, object param) + public static void NavigationView(IEventAggregator eventAggregator, string viewName, string parentViewName, object? param) { // LogManager.Debug(Tag, $"NavigationView: {viewName}, Parameter: {param}"); var parameter = new NavigationParam diff --git a/DownKyi/ViewModels/ViewFriendsViewModel.cs b/DownKyi/ViewModels/ViewFriendsViewModel.cs index b07c7b7..8ef08b1 100644 --- a/DownKyi/ViewModels/ViewFriendsViewModel.cs +++ b/DownKyi/ViewModels/ViewFriendsViewModel.cs @@ -127,7 +127,7 @@ namespace DownKyi.ViewModels // isFirst参数表示是否是从PageFriends的headerTable的item点击进入的 // true表示加载PageFriends后第一次进入 // false表示从headerTable的item点击进入 - NavigationParameters param = new NavigationParameters() + var param = new NavigationParameters() { { "mid", mid }, { "isFirst", isFirst }, diff --git a/DownKyi/ViewModels/ViewIndexViewModel.cs b/DownKyi/ViewModels/ViewIndexViewModel.cs index ea439cf..87c79b1 100644 --- a/DownKyi/ViewModels/ViewIndexViewModel.cs +++ b/DownKyi/ViewModels/ViewIndexViewModel.cs @@ -132,8 +132,7 @@ public class ViewIndexViewModel : ViewModelBase { EnterBili(); } - - + // 登录事件 private DelegateCommand? _loginCommand; public DelegateCommand LoginCommand => _loginCommand ??= new DelegateCommand(ExecuteLogin); @@ -192,7 +191,7 @@ public class ViewIndexViewModel : ViewModelBase /// /// 进入工具箱页面 /// - private async void ExecuteToolboxCommand() + private void ExecuteToolboxCommand() { NavigateToView.NavigationView(EventAggregator, ViewToolboxViewModel.Tag, Tag, null); } @@ -205,7 +204,7 @@ public class ViewIndexViewModel : ViewModelBase /// private void EnterBili() { - if (InputText == null || InputText == string.Empty) + if (string.IsNullOrEmpty(InputText)) { return; } diff --git a/DownKyi/ViewModels/ViewPublicationViewModel.cs b/DownKyi/ViewModels/ViewPublicationViewModel.cs index 3738fa0..697e76d 100644 --- a/DownKyi/ViewModels/ViewPublicationViewModel.cs +++ b/DownKyi/ViewModels/ViewPublicationViewModel.cs @@ -1,8 +1,10 @@ -using System; +#nullable disable +using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; +using System.Text; using System.Threading; using System.Threading.Tasks; using Avalonia.Media.Imaging; @@ -22,116 +24,115 @@ using Prism.Commands; using Prism.Events; using Prism.Regions; -#nullable disable namespace DownKyi.ViewModels { public class ViewPublicationViewModel : ViewModelBase { public const string Tag = "PagePublication"; - private CancellationTokenSource tokenSource; + private CancellationTokenSource _tokenSource; - private long mid = -1; + private long _mid = -1; // 每页视频数量,暂时在此写死,以后在设置中增加选项 - private readonly int VideoNumberInPage = 30; + private readonly int _videoNumberInPage = 30; #region 页面属性申明 - private string pageName = Tag; + private string _pageName = Tag; public string PageName { - get => pageName; - set => SetProperty(ref pageName, value); + get => _pageName; + set => SetProperty(ref _pageName, value); } - private bool loading; + private bool _loading; public bool Loading { - get => loading; - set => SetProperty(ref loading, value); + get => _loading; + set => SetProperty(ref _loading, value); } - private bool loadingVisibility; + private bool _loadingVisibility; public bool LoadingVisibility { - get => loadingVisibility; - set => SetProperty(ref loadingVisibility, value); + get => _loadingVisibility; + set => SetProperty(ref _loadingVisibility, value); } - private bool noDataVisibility; + private bool _noDataVisibility; public bool NoDataVisibility { - get => noDataVisibility; - set => SetProperty(ref noDataVisibility, value); + get => _noDataVisibility; + set => SetProperty(ref _noDataVisibility, value); } - private VectorImage arrowBack; + private VectorImage _arrowBack; public VectorImage ArrowBack { - get => arrowBack; - set => SetProperty(ref arrowBack, value); + get => _arrowBack; + set => SetProperty(ref _arrowBack, value); } - private VectorImage downloadManage; + private VectorImage _downloadManage; public VectorImage DownloadManage { - get => downloadManage; - set => SetProperty(ref downloadManage, value); + get => _downloadManage; + set => SetProperty(ref _downloadManage, value); } - private ObservableCollection tabHeaders; + private ObservableCollection _tabHeaders; public ObservableCollection TabHeaders { - get => tabHeaders; - set => SetProperty(ref tabHeaders, value); + get => _tabHeaders; + set => SetProperty(ref _tabHeaders, value); } - private int selectTabId; + private int _selectTabId; public int SelectTabId { - get => selectTabId; - set => SetProperty(ref selectTabId, value); + get => _selectTabId; + set => SetProperty(ref _selectTabId, value); } - private bool isEnabled = true; + private bool _isEnabled = true; public bool IsEnabled { - get => isEnabled; - set => SetProperty(ref isEnabled, value); + get => _isEnabled; + set => SetProperty(ref _isEnabled, value); } - private CustomPagerViewModel pager; + private CustomPagerViewModel _pager; public CustomPagerViewModel Pager { - get => pager; - set => SetProperty(ref pager, value); + get => _pager; + set => SetProperty(ref _pager, value); } - private ObservableCollection medias; + private ObservableCollection _medias; public ObservableCollection Medias { - get => medias; - set => SetProperty(ref medias, value); + get => _medias; + set => SetProperty(ref _medias, value); } - private bool isSelectAll; + private bool _isSelectAll; public bool IsSelectAll { - get => isSelectAll; - set => SetProperty(ref isSelectAll, value); + get => _isSelectAll; + set => SetProperty(ref _isSelectAll, value); } #endregion @@ -139,7 +140,7 @@ namespace DownKyi.ViewModels public ViewPublicationViewModel(IEventAggregator eventAggregator, IDialogService dialogService) : base( eventAggregator) { - this.DialogService = dialogService; + DialogService = dialogService; #region 属性初始化 @@ -166,10 +167,9 @@ namespace DownKyi.ViewModels #region 命令申明 // 返回事件 - private DelegateCommand backSpaceCommand; + private DelegateCommand _backSpaceCommand; - public DelegateCommand BackSpaceCommand => - backSpaceCommand ?? (backSpaceCommand = new DelegateCommand(ExecuteBackSpace)); + public DelegateCommand BackSpaceCommand => _backSpaceCommand ??= new DelegateCommand(ExecuteBackSpace); /// /// 返回事件 @@ -179,9 +179,9 @@ namespace DownKyi.ViewModels ArrowBack.Fill = DictionaryResource.GetColor("ColorText"); // 结束任务 - tokenSource?.Cancel(); + _tokenSource?.Cancel(); - NavigationParam parameter = new NavigationParam + var parameter = new NavigationParam { ViewName = ParentView, ParentViewName = null, @@ -191,18 +191,16 @@ namespace DownKyi.ViewModels } // 前往下载管理页面 - private DelegateCommand downloadManagerCommand; + private DelegateCommand _downloadManagerCommand; - public DelegateCommand DownloadManagerCommand => downloadManagerCommand ?? - (downloadManagerCommand = - new DelegateCommand(ExecuteDownloadManagerCommand)); + public DelegateCommand DownloadManagerCommand => _downloadManagerCommand ??= new DelegateCommand(ExecuteDownloadManagerCommand); /// /// 前往下载管理页面 /// private void ExecuteDownloadManagerCommand() { - NavigationParam parameter = new NavigationParam + var parameter = new NavigationParam { ViewName = ViewDownloadManagerViewModel.Tag, ParentViewName = Tag, @@ -212,10 +210,10 @@ namespace DownKyi.ViewModels } // 左侧tab点击事件 - private DelegateCommand leftTabHeadersCommand; + private DelegateCommand _leftTabHeadersCommand; - public DelegateCommand LeftTabHeadersCommand => leftTabHeadersCommand ?? (leftTabHeadersCommand = - new DelegateCommand(ExecuteLeftTabHeadersCommand, CanExecuteLeftTabHeadersCommand)); + public DelegateCommand LeftTabHeadersCommand => + _leftTabHeadersCommand ??= new DelegateCommand(ExecuteLeftTabHeadersCommand, CanExecuteLeftTabHeadersCommand); /// /// 左侧tab点击事件 @@ -223,14 +221,14 @@ namespace DownKyi.ViewModels /// private void ExecuteLeftTabHeadersCommand(object parameter) { - if (!(parameter is TabHeader tabHeader)) + if (parameter is not TabHeader tabHeader) { return; } // 页面选择 Pager = new CustomPagerViewModel(1, - (int)Math.Ceiling(double.Parse(tabHeader.SubTitle) / VideoNumberInPage)); + (int)Math.Ceiling(double.Parse(tabHeader.SubTitle) / _videoNumberInPage)); Pager.CurrentChanged += OnCurrentChanged_Pager; Pager.CountChanged += OnCountChanged_Pager; Pager.Current = 1; @@ -247,11 +245,9 @@ namespace DownKyi.ViewModels } // 全选按钮点击事件 - private DelegateCommand selectAllCommand; + private DelegateCommand _selectAllCommand; - public DelegateCommand SelectAllCommand => selectAllCommand ?? - (selectAllCommand = - new DelegateCommand(ExecuteSelectAllCommand)); + public DelegateCommand SelectAllCommand => _selectAllCommand ??= new DelegateCommand(ExecuteSelectAllCommand); /// /// 全选按钮点击事件 @@ -276,10 +272,9 @@ namespace DownKyi.ViewModels } // 列表选择事件 - private DelegateCommand mediasCommand; + private DelegateCommand _mediasCommand; - public DelegateCommand MediasCommand => - mediasCommand ?? (mediasCommand = new DelegateCommand(ExecuteMediasCommand)); + public DelegateCommand MediasCommand => _mediasCommand ??= new DelegateCommand(ExecuteMediasCommand); /// /// 列表选择事件 @@ -287,27 +282,18 @@ namespace DownKyi.ViewModels /// private void ExecuteMediasCommand(object parameter) { - if (!(parameter is IList selectedMedia)) + if (parameter is not IList selectedMedia) { return; } - if (selectedMedia.Count == Medias.Count) - { - IsSelectAll = true; - } - else - { - IsSelectAll = false; - } + IsSelectAll = selectedMedia.Count == Medias.Count; } // 添加选中项到下载列表事件 - private DelegateCommand addToDownloadCommand; + private DelegateCommand _addToDownloadCommand; - public DelegateCommand AddToDownloadCommand => addToDownloadCommand ?? - (addToDownloadCommand = - new DelegateCommand(ExecuteAddToDownloadCommand)); + public DelegateCommand AddToDownloadCommand => _addToDownloadCommand ??= new DelegateCommand(ExecuteAddToDownloadCommand); /// /// 添加选中项到下载列表事件 @@ -318,11 +304,9 @@ namespace DownKyi.ViewModels } // 添加所有视频到下载列表事件 - private DelegateCommand addAllToDownloadCommand; + private DelegateCommand _addAllToDownloadCommand; - public DelegateCommand AddAllToDownloadCommand => addAllToDownloadCommand ?? - (addAllToDownloadCommand = - new DelegateCommand(ExecuteAddAllToDownloadCommand)); + public DelegateCommand AddAllToDownloadCommand => _addAllToDownloadCommand ??= new DelegateCommand(ExecuteAddAllToDownloadCommand); /// /// 添加所有视频到下载列表事件 @@ -341,13 +325,13 @@ namespace DownKyi.ViewModels private async void AddToDownload(bool isOnlySelected) { // 收藏夹里只有视频 - AddToDownloadService addToDownloadService = new AddToDownloadService(PlayStreamType.VIDEO); + var addToDownloadService = new AddToDownloadService(PlayStreamType.VIDEO); // 选择文件夹 - string directory = await addToDownloadService.SetDirectory(DialogService); + var directory = await addToDownloadService.SetDirectory(DialogService); // 视频计数 - int i = 0; + var i = 0; await Task.Run(async () => { // 为了避免执行其他操作时, @@ -355,19 +339,8 @@ namespace DownKyi.ViewModels var list = Medias.ToList(); // 添加到下载 - foreach (var media in list) + foreach (var videoInfoService in from media in list where !isOnlySelected || media.IsSelected select new VideoInfoService(media.Bvid)) { - // 只下载选中项,跳过未选中项 - if (isOnlySelected && !media.IsSelected) - { - continue; - } - - /// 有分P的就下载全部 - - // 开启服务 - VideoInfoService videoInfoService = new VideoInfoService(media.Bvid); - addToDownloadService.SetVideoInfoService(videoInfoService); addToDownloadService.GetVideo(); addToDownloadService.ParseVideo(videoInfoService); @@ -415,6 +388,19 @@ namespace DownKyi.ViewModels return true; } + + private static string StringToUnicode(string s) + { + var charbuffers = s.ToCharArray(); + byte[] buffer; + var sb = new StringBuilder(); + for (var i = 0; i < charbuffers.Length; i++) + { + buffer = Encoding.Unicode.GetBytes(charbuffers[i].ToString()); + sb.Append($"\\u{buffer[1]:X2}{buffer[0]:X2}"); + } + return sb.ToString(); + } private async void UpdatePublication(int current) { @@ -426,9 +412,9 @@ namespace DownKyi.ViewModels await Task.Run(() => { - var cancellationToken = tokenSource.Token; + var cancellationToken = _tokenSource.Token; - var publications = Core.BiliApi.Users.UserSpace.GetPublication(mid, current, VideoNumberInPage, tab.Id); + var publications = Core.BiliApi.Users.UserSpace.GetPublication(_mid, current, _videoNumberInPage, tab.Id); if (publications == null) { // 没有数据,UI提示 @@ -487,15 +473,13 @@ namespace DownKyi.ViewModels { Avid = video.Aid, Bvid = video.Bvid, - Cover = cover ?? - ImageHelper.LoadFromResource( - new Uri("avares://DownKyi/Resources/video-placeholder.png")), + Cover = cover ?? ImageHelper.LoadFromResource(new Uri("avares://DownKyi/Resources/video-placeholder.png")), Duration = video.Length, Title = video.Title, PlayNumber = play, CreateTime = ctime }; - medias.Add(media); + _medias.Add(media); LoadingVisibility = false; NoDataVisibility = false; @@ -507,7 +491,7 @@ namespace DownKyi.ViewModels break; } } - }, (tokenSource = new CancellationTokenSource()).Token); + }, (_tokenSource = new CancellationTokenSource()).Token); IsEnabled = true; } @@ -546,9 +530,9 @@ namespace DownKyi.ViewModels InitView(); - mid = (long)parameter["mid"]; - int tid = (int)parameter["tid"]; - List zones = (List)parameter["list"]; + _mid = (long)parameter["mid"]; + var tid = (int)parameter["tid"]; + var zones = (List)parameter["list"]; foreach (var item in zones) { @@ -566,7 +550,7 @@ namespace DownKyi.ViewModels // 页面选择 Pager = new CustomPagerViewModel(1, - (int)Math.Ceiling(double.Parse(selectTab.SubTitle) / VideoNumberInPage)); + (int)Math.Ceiling(double.Parse(selectTab.SubTitle) / _videoNumberInPage)); Pager.CurrentChanged += OnCurrentChanged_Pager; Pager.CountChanged += OnCountChanged_Pager; Pager.Current = 1; diff --git a/script/macos/Info.plist b/script/macos/Info.plist index 66278eb..387d396 100644 --- a/script/macos/Info.plist +++ b/script/macos/Info.plist @@ -9,7 +9,7 @@ CFBundleName 哔哩下载姬 CFBundleVersion - 1.0.9 + 1.0.10 LSMinimumSystemVersion 10.15 CFBundleExecutable diff --git a/version.txt b/version.txt index e5a4a5e..437d26b 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.0.9 \ No newline at end of file +1.0.10 \ No newline at end of file