diff --git a/DownKyi/ViewModels/PageViewModels/Favorites.cs b/DownKyi/ViewModels/PageViewModels/Favorites.cs index b5dc48d..2a8a2f8 100644 --- a/DownKyi/ViewModels/PageViewModels/Favorites.cs +++ b/DownKyi/ViewModels/PageViewModels/Favorites.cs @@ -1,5 +1,6 @@ using Avalonia.Media.Imaging; using DownKyi.Images; +using DownKyi.Utils; using Prism.Mvvm; namespace DownKyi.ViewModels.PageViewModels; @@ -133,17 +134,17 @@ public class Favorites : BindableBase { #region 属性初始化 - // Play = NormalIcon.Instance().Play; - // Play.Fill = DictionaryResource.GetColor("ColorTextGrey2"); - // - // Like = NormalIcon.Instance().Like; - // Like.Fill = DictionaryResource.GetColor("ColorTextGrey2"); - // - // Favorite = NormalIcon.Instance().Favorite; - // Favorite.Fill = DictionaryResource.GetColor("ColorTextGrey2"); - // - // Share = NormalIcon.Instance().Share; - // Share.Fill = DictionaryResource.GetColor("ColorTextGrey2"); + Play = NormalIcon.Instance().Play; + Play.Fill = DictionaryResource.GetColor("ColorTextGrey2"); + + Like = NormalIcon.Instance().Like; + Like.Fill = DictionaryResource.GetColor("ColorTextGrey2"); + + Favorite = NormalIcon.Instance().Favorite; + Favorite.Fill = DictionaryResource.GetColor("ColorTextGrey2"); + + Share = NormalIcon.Instance().Share; + Share.Fill = DictionaryResource.GetColor("ColorTextGrey2"); #endregion } diff --git a/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs b/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs index dea7f89..33d549d 100644 --- a/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs +++ b/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs @@ -160,10 +160,9 @@ public class ViewPublicFavoritesViewModel : ViewModelBase #region 命令申明 // 返回 - private DelegateCommand backSpaceCommand; + private DelegateCommand? _backSpaceCommand; - public DelegateCommand BackSpaceCommand => - backSpaceCommand ?? (backSpaceCommand = new DelegateCommand(ExecuteBackSpace)); + public DelegateCommand BackSpaceCommand => _backSpaceCommand ??= new DelegateCommand(ExecuteBackSpace); /// /// 返回 @@ -183,11 +182,9 @@ public class ViewPublicFavoritesViewModel : ViewModelBase } // 前往下载管理页面 - private DelegateCommand downloadManagerCommand; + private DelegateCommand? _downloadManagerCommand; - public DelegateCommand DownloadManagerCommand => downloadManagerCommand ?? - (downloadManagerCommand = - new DelegateCommand(ExecuteDownloadManagerCommand)); + public DelegateCommand DownloadManagerCommand => _downloadManagerCommand ??= new DelegateCommand(ExecuteDownloadManagerCommand); /// /// 前往下载管理页面 @@ -204,10 +201,9 @@ public class ViewPublicFavoritesViewModel : ViewModelBase } // 复制封面事件 - private DelegateCommand copyCoverCommand; + private DelegateCommand? _copyCoverCommand; - public DelegateCommand CopyCoverCommand => - copyCoverCommand ?? (copyCoverCommand = new DelegateCommand(ExecuteCopyCoverCommand)); + public DelegateCommand CopyCoverCommand => _copyCoverCommand ??= new DelegateCommand(ExecuteCopyCoverCommand); /// /// 复制封面事件 @@ -220,11 +216,9 @@ public class ViewPublicFavoritesViewModel : ViewModelBase } // 复制封面URL事件 - private DelegateCommand copyCoverUrlCommand; + private DelegateCommand? _copyCoverUrlCommand; - public DelegateCommand CopyCoverUrlCommand => copyCoverUrlCommand ?? - (copyCoverUrlCommand = - new DelegateCommand(ExecuteCopyCoverUrlCommand)); + public DelegateCommand CopyCoverUrlCommand => _copyCoverUrlCommand ??= new DelegateCommand(ExecuteCopyCoverUrlCommand); /// /// 复制封面URL事件 @@ -237,8 +231,8 @@ public class ViewPublicFavoritesViewModel : ViewModelBase } // 前往UP主页事件 - private DelegateCommand upperCommand; - public DelegateCommand UpperCommand => upperCommand ?? (upperCommand = new DelegateCommand(ExecuteUpperCommand)); + private DelegateCommand? _upperCommand; + public DelegateCommand UpperCommand => _upperCommand ??= new DelegateCommand(ExecuteUpperCommand); /// /// 前往UP主页事件 @@ -249,11 +243,9 @@ public class ViewPublicFavoritesViewModel : ViewModelBase } // 添加选中项到下载列表事件 - private DelegateCommand addToDownloadCommand; + private DelegateCommand? _addToDownloadCommand; - public DelegateCommand AddToDownloadCommand => addToDownloadCommand ?? - (addToDownloadCommand = - new DelegateCommand(ExecuteAddToDownloadCommand)); + public DelegateCommand AddToDownloadCommand => _addToDownloadCommand ??= new DelegateCommand(ExecuteAddToDownloadCommand); /// /// 添加选中项到下载列表事件 @@ -264,11 +256,9 @@ public class ViewPublicFavoritesViewModel : ViewModelBase } // 添加所有视频到下载列表事件 - private DelegateCommand addAllToDownloadCommand; + private DelegateCommand? _addAllToDownloadCommand; - public DelegateCommand AddAllToDownloadCommand => addAllToDownloadCommand ?? - (addAllToDownloadCommand = - new DelegateCommand(ExecuteAddAllToDownloadCommand)); + public DelegateCommand AddAllToDownloadCommand => _addAllToDownloadCommand ??= new DelegateCommand(ExecuteAddAllToDownloadCommand); /// /// 添加所有视频到下载列表事件 @@ -279,12 +269,9 @@ public class ViewPublicFavoritesViewModel : ViewModelBase } // 列表选择事件 - private DelegateCommand favoritesMediasCommand; + private DelegateCommand? _favoritesMediasCommand; - public DelegateCommand FavoritesMediasCommand => favoritesMediasCommand ?? - (favoritesMediasCommand = - new DelegateCommand( - ExecuteFavoritesMediasCommand)); + public DelegateCommand FavoritesMediasCommand => _favoritesMediasCommand ??= new DelegateCommand(ExecuteFavoritesMediasCommand); /// /// 列表选择事件 @@ -401,7 +388,7 @@ public class ViewPublicFavoritesViewModel : ViewModelBase MediaLoadingVisibility = true; - List medias = FavoritesResource.GetAllFavoritesMedia(favoritesId); + var medias = FavoritesResource.GetAllFavoritesMedia(favoritesId); if (medias == null || medias.Count == 0) { MediaLoadingVisibility = false; @@ -426,18 +413,18 @@ public class ViewPublicFavoritesViewModel : ViewModelBase base.OnNavigatedTo(navigationContext); // 根据传入参数不同执行不同任务 - long parameter = navigationContext.Parameters.GetValue("Parameter"); + var parameter = navigationContext.Parameters.GetValue("Parameter"); if (parameter == 0) { return; } InitView(); - await Task.Run(new Action(() => + await Task.Run(() => { - CancellationToken cancellationToken = tokenSource.Token; + var cancellationToken = tokenSource.Token; UpdateView(new FavoritesService(), parameter, cancellationToken); - }), (tokenSource = new CancellationTokenSource()).Token); + }, (tokenSource = new CancellationTokenSource()).Token); } } \ No newline at end of file diff --git a/DownKyi/Views/ViewPublicFavorites.axaml b/DownKyi/Views/ViewPublicFavorites.axaml index a51f806..3863598 100644 --- a/DownKyi/Views/ViewPublicFavorites.axaml +++ b/DownKyi/Views/ViewPublicFavorites.axaml @@ -112,7 +112,8 @@ + Orientation="Horizontal" + IsVisible="{Binding Favorites.MediaCount}"> - @@ -280,7 +269,7 @@ + CommandParameter="{Binding ElementName=NameFavoritesMedias, Path=SelectedItem}" /> @@ -296,7 +285,9 @@ - + + + @@ -306,13 +297,8 @@ - - - - - - - + + CommandParameter="{ReflectionBinding DataContext.PageName, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" /> - - + + + + @@ -427,42 +412,36 @@ FontSize="12" Text="{Binding UpName, StringFormat={}UP: {0}}"> - + + CommandParameter="{ReflectionBinding DataContext.PageName, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" /> - - + + + + - - - + + + @@ -480,7 +459,7 @@ Foreground="Gray" IsActive="{Binding MediaLoading}" /> - +