From 90525e105f1e0cba11e2e661b73b8b35156b6c35 Mon Sep 17 00:00:00 2001 From: Miaoyww Date: Tue, 23 Jul 2024 01:52:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=AF=8F=E6=97=A5=E6=8E=A8?= =?UTF-8?q?=E8=8D=90=E6=AD=8C=E6=9B=B2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Contracts/Adapters/ICommonAdapter.cs | 3 ++- .../Contracts/Models/Music/IAlbum.cs | 4 ++-- NonsPlayer.Core/Models/LocalAlbum.cs | 4 ++-- .../RecommendedPlaylistCardViewModel.cs | 24 ++++++++++++------- .../Views/Home/RecentlyPlayItemCard.xaml | 9 +++---- .../Views/RecommendedPlaylistCard.xaml | 19 +++++++++++---- .../Views/RecommendedPlaylistCard.xaml.cs | 8 ++++++- 7 files changed, 47 insertions(+), 24 deletions(-) diff --git a/NonsPlayer.Core/Contracts/Adapters/ICommonAdapter.cs b/NonsPlayer.Core/Contracts/Adapters/ICommonAdapter.cs index e9bcf02..fd73662 100644 --- a/NonsPlayer.Core/Contracts/Adapters/ICommonAdapter.cs +++ b/NonsPlayer.Core/Contracts/Adapters/ICommonAdapter.cs @@ -7,5 +7,6 @@ namespace NonsPlayer.Core.Contracts.Adapters; public interface ICommonAdapter: ISubAdapter { Task GetRecommendedPlaylistAsync(int count); - + Task GetDailyRecommended(); + Task GetRadioSong(); } \ No newline at end of file diff --git a/NonsPlayer.Core/Contracts/Models/Music/IAlbum.cs b/NonsPlayer.Core/Contracts/Models/Music/IAlbum.cs index 8a94cae..d98e6ca 100644 --- a/NonsPlayer.Core/Contracts/Models/Music/IAlbum.cs +++ b/NonsPlayer.Core/Contracts/Models/Music/IAlbum.cs @@ -7,8 +7,8 @@ public interface IAlbum : IMusicModel { [JsonPropertyName("create_date")] public DateTime CreateDate { get; set; } [JsonPropertyName("description")] public string Description { get; set; } - [JsonPropertyName("musics")] public List Musics { get; set; } - [JsonPropertyName("artists")] public List Artists { get; set; } + [JsonPropertyName("musics")] public IMusic[] Musics { get; set; } + [JsonPropertyName("artists")] public IArtist[] Artists { get; set; } [JsonIgnore] public string ArtistsName => string.Join("/", Artists.Select(x => x.Name)); [JsonPropertyName("collection_count")] public int CollectionCount { set; get; } [JsonPropertyName("track_count")] public int TrackCount { get; set; } diff --git a/NonsPlayer.Core/Models/LocalAlbum.cs b/NonsPlayer.Core/Models/LocalAlbum.cs index cc0e779..ca8c3cf 100644 --- a/NonsPlayer.Core/Models/LocalAlbum.cs +++ b/NonsPlayer.Core/Models/LocalAlbum.cs @@ -11,8 +11,8 @@ public class LocalAlbum: IAlbum public string AvatarUrl { get; set; } public DateTime CreateDate { get; set; } public string Description { get; set; } - public List Musics { get; set; } - public List Artists { get; set; } + public IMusic[] Musics { get; set; } + public IArtist[] Artists { get; set; } public int CollectionCount { get; set; } public int TrackCount { get; set; } } \ No newline at end of file diff --git a/NonsPlayer/Components/ViewModels/RecommendedPlaylistCardViewModel.cs b/NonsPlayer/Components/ViewModels/RecommendedPlaylistCardViewModel.cs index 5414a4c..08e1e14 100644 --- a/NonsPlayer/Components/ViewModels/RecommendedPlaylistCardViewModel.cs +++ b/NonsPlayer/Components/ViewModels/RecommendedPlaylistCardViewModel.cs @@ -1,4 +1,5 @@ using System.Collections.ObjectModel; +using Windows.UI; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using CommunityToolkit.WinUI.UI.Controls; @@ -18,17 +19,22 @@ namespace NonsPlayer.Components.ViewModels; public partial class RecommendedPlaylistCardViewModel : ObservableObject { [ObservableProperty] private ImageSource cover; + [ObservableProperty] private Brush fontColor; + [ObservableProperty] private Visibility tipVisibility = Visibility.Collapsed; - public RecommendedPlaylistCardViewModel() + public async void Init(IMusic[] music) { + if (music != null) + { + var firstMusic = music[0]; + Cover = (await CacheHelper.GetImageBrushAsync(firstMusic.CacheAvatarId, + firstMusic.GetCoverUrl())).ImageSource; + TipVisibility = Visibility.Collapsed; + FontColor = App.Current.Resources["LightTextColor"] as SolidColorBrush; + return; + } - } - - public async void Init(IPlaylist playList) - { - if (!playList.IsInitialized) await playList.InitializeMusics(); - var firstMusic = playList.Musics[0]; - Cover = (await CacheHelper.GetImageBrushAsync(firstMusic.CacheAvatarId, - firstMusic.GetCoverUrl())).ImageSource; + TipVisibility = Visibility.Visible; + FontColor = App.Current.Resources["CommonTextColor"] as SolidColorBrush; } } \ No newline at end of file diff --git a/NonsPlayer/Components/Views/Home/RecentlyPlayItemCard.xaml b/NonsPlayer/Components/Views/Home/RecentlyPlayItemCard.xaml index e0fb496..8a91e75 100644 --- a/NonsPlayer/Components/Views/Home/RecentlyPlayItemCard.xaml +++ b/NonsPlayer/Components/Views/Home/RecentlyPlayItemCard.xaml @@ -6,8 +6,9 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:winUi="using:CommunityToolkit.WinUI" mc:Ignorable="d"> - + \ No newline at end of file diff --git a/NonsPlayer/Components/Views/RecommendedPlaylistCard.xaml b/NonsPlayer/Components/Views/RecommendedPlaylistCard.xaml index 44bf295..c550086 100644 --- a/NonsPlayer/Components/Views/RecommendedPlaylistCard.xaml +++ b/NonsPlayer/Components/Views/RecommendedPlaylistCard.xaml @@ -5,7 +5,9 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> - + @@ -17,6 +19,7 @@ + @@ -24,11 +27,17 @@ + + + + + - \ No newline at end of file diff --git a/NonsPlayer/Components/Views/RecommendedPlaylistCard.xaml.cs b/NonsPlayer/Components/Views/RecommendedPlaylistCard.xaml.cs index 1375907..db86d3e 100644 --- a/NonsPlayer/Components/Views/RecommendedPlaylistCard.xaml.cs +++ b/NonsPlayer/Components/Views/RecommendedPlaylistCard.xaml.cs @@ -1,5 +1,5 @@ +using System.Windows.Forms; using CommunityToolkit.Mvvm.ComponentModel; -using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Media.Animation; using NonsPlayer.Components.ViewModels; @@ -7,6 +7,7 @@ using NonsPlayer.Core.Models; using NonsPlayer.Core.Services; using NonsPlayer.Helpers; +using UserControl = Microsoft.UI.Xaml.Controls.UserControl; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -23,4 +24,9 @@ public RecommendedPlaylistCard() } public RecommendedPlaylistCardViewModel ViewModel { get; } + + public IMusic[] Music + { + set => ViewModel.Init(value); + } } \ No newline at end of file