diff --git a/DownKyi/DownKyi.csproj b/DownKyi/DownKyi.csproj index 3972b01..54d9a1d 100644 --- a/DownKyi/DownKyi.csproj +++ b/DownKyi/DownKyi.csproj @@ -87,6 +87,8 @@ + + @@ -96,6 +98,8 @@ + + @@ -104,6 +108,7 @@ + diff --git a/DownKyi/Images/NormalIcon.cs b/DownKyi/Images/NormalIcon.cs index 0eba593..d785fc1 100644 --- a/DownKyi/Images/NormalIcon.cs +++ b/DownKyi/Images/NormalIcon.cs @@ -14,6 +14,54 @@ public NormalIcon() { + Play = new VectorImage + { + Height = 16, + Width = 14.75, + Data = @"M869.03 707.93 l-465.29 281.31 q-86.66 49.32 -178.65 28.65 q-91.99 -20.66 -146.65 -103.31 q-36 -56 -36 -121.33 + l0 -562.61 q2.67 -97.32 69.33 -162.64 q66.66 -65.32 167.98 -67.99 q66.66 0 123.99 34.66 l465.29 281.31 + q83.99 53.33 105.99 143.32 q22 89.99 -30 173.98 q-29.33 46.66 -75.99 74.66 Z", + Fill = "#FF000000" + }; + + Like = new VectorImage + { + Height = 14, + Width = 16, + Data = @"M291.53 894.6 l0 -642.53 l4.66 0 l179.59 -220.4 q29.15 -29.15 69.97 -31.49 q40.81 -2.33 72.29 24.5 + q16.33 16.32 25.66 37.31 q9.33 20.99 7 45.48 l-7 144.6 l274.04 0 q25.65 0 48.39 11.08 q22.74 11.08 39.07 32.07 + q13.99 19.82 17.49 44.31 q3.5 24.49 -2.33 46.64 l-116.62 382.49 q-15.16 54.81 -57.14 88.63 q-41.98 33.81 -100.28 37.31 + l-454.79 0 ZM225.06 894.6 l-93.29 0 q-34.98 2.33 -65.3 -14 q-30.32 -16.33 -47.81 -47.81 q-17.49 -31.49 -18.66 -64.13 + l0 -385.99 q0 -36.15 17.49 -65.89 q17.49 -29.73 48.98 -46.05 q16.32 -8.17 32.65 -12.25 q16.33 -4.08 32.65 -6.41 l93.29 0 + l0 642.53 Z", + Fill = "#FF000000" + }; + + Favorite = new VectorImage + { + Height = 16, + Width = 16, + Data = @"M772.12 303.28 q-37.33 -5.83 -66.49 -28 q-29.16 -22.16 -44.32 -55.99 l-83.99 -176.13 q-22.16 -43.16 -65.91 -43.16 + q-43.74 0 -69.4 43.16 l-79.32 176.13 q-17.49 33.83 -46.07 55.99 q-28.58 22.17 -64.74 28 l-188.97 29.16 + q-45.49 9.33 -58.9 48.99 q-13.42 39.66 18.09 75.82 l142.31 146.98 q25.66 24.49 35.57 58.32 q9.91 33.83 5.25 69.99 + l-32.66 204.13 q-5.83 48.99 29.75 73.49 q35.57 24.5 79.9 3.5 l159.8 -87.48 q33.83 -19.83 71.74 -19.83 + q37.91 0 71.74 19.83 l160.97 87.48 q43.16 21 77.57 -3.5 q34.41 -24.5 32.08 -73.49 l-37.33 -204.13 + q-4.67 -36.16 5.25 -69.99 q9.91 -33.83 35.57 -58.32 l142.31 -146.98 q31.5 -36.16 18.09 -75.82 + q-13.42 -39.66 -58.91 -48.99 l-188.97 -29.16 Z", + Fill = "#FF000000" + }; + + Share = new VectorImage + { + Height = 14, + Width = 16, + Data = @"M453.23 283.64 l0 -219.44 q1.16 -26.85 18.67 -45.53 q17.51 -18.68 44.36 -18.68 q23.34 0 40.85 15.17 l441.21 375.85 + q25.68 22.18 25.68 56.61 q0 34.43 -25.68 57.78 l-441.21 375.85 q-19.84 16.34 -46.11 14 q-26.26 -2.34 -42.61 -22.18 + q-15.17 -18.67 -15.17 -42.02 l0 -201.93 q-156.41 0 -249.79 61.87 q-93.38 61.87 -178.58 183.25 q-4.67 5.84 -14.01 5.25 + q-9.34 -0.59 -10.51 -19.25 q-5.83 -241.62 87.54 -405.62 q93.38 -164 365.35 -171 Z", + Fill = "#FF000000" + }; + CloudDownload = new VectorImage { Height = 32, @@ -60,6 +108,11 @@ } + public VectorImage Play { get; private set; } + public VectorImage Like { get; private set; } + public VectorImage Favorite { get; private set; } + public VectorImage Share { get; private set; } + public VectorImage CloudDownload { get; private set; } public VectorImage Folder { get; private set; } public VectorImage Downloading { get; private set; } diff --git a/DownKyi/Languages/Default.xaml b/DownKyi/Languages/Default.xaml index c635e25..559fef5 100644 --- a/DownKyi/Languages/Default.xaml +++ b/DownKyi/Languages/Default.xaml @@ -62,6 +62,7 @@ 解析 解析视频 下载选中项 + 下载全部 正在下载 @@ -173,6 +174,10 @@ 提取音频 提取视频 + + 收藏夹 + 个内容 + 取消 请选择文件夹 diff --git a/DownKyi/Models/Favorites.cs b/DownKyi/Models/Favorites.cs new file mode 100644 index 0000000..e5098ea --- /dev/null +++ b/DownKyi/Models/Favorites.cs @@ -0,0 +1,88 @@ +using Prism.Mvvm; +using System.Windows.Media.Imaging; + +namespace DownKyi.Models +{ + public class Favorites : BindableBase + { + public string CoverUrl { get; set; } + public long UpperMid { get; set; } + + private BitmapImage cover; + public BitmapImage Cover + { + get { return cover; } + set { SetProperty(ref cover, value); } + } + + private string title; + public string Title + { + get { return title; } + set { SetProperty(ref title, value); } + } + + private string createTime; + public string CreateTime + { + get { return createTime; } + set { SetProperty(ref createTime, value); } + } + + private string playNumber; + public string PlayNumber + { + get { return playNumber; } + set { SetProperty(ref playNumber, value); } + } + + private string likeNumber; + public string LikeNumber + { + get { return likeNumber; } + set { SetProperty(ref likeNumber, value); } + } + + private string favoriteNumber; + public string FavoriteNumber + { + get { return favoriteNumber; } + set { SetProperty(ref favoriteNumber, value); } + } + + private string shareNumber; + public string ShareNumber + { + get { return shareNumber; } + set { SetProperty(ref shareNumber, value); } + } + + private string description; + public string Description + { + get { return description; } + set { SetProperty(ref description, value); } + } + + private int mediaCount; + public int MediaCount + { + get { return mediaCount; } + set { SetProperty(ref mediaCount, value); } + } + + private string upName; + public string UpName + { + get { return upName; } + set { SetProperty(ref upName, value); } + } + + private BitmapImage upHeader; + public BitmapImage UpHeader + { + get { return upHeader; } + set { SetProperty(ref upHeader, value); } + } + } +} diff --git a/DownKyi/Models/FavoritesMedia.cs b/DownKyi/Models/FavoritesMedia.cs new file mode 100644 index 0000000..666c2b5 --- /dev/null +++ b/DownKyi/Models/FavoritesMedia.cs @@ -0,0 +1,13 @@ +using Prism.Mvvm; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DownKyi.Models +{ + public class FavoritesMedia : BindableBase + { + } +} diff --git a/DownKyi/Models/VideoInfoView.cs b/DownKyi/Models/VideoInfoView.cs index 7eab89c..5eb92b3 100644 --- a/DownKyi/Models/VideoInfoView.cs +++ b/DownKyi/Models/VideoInfoView.cs @@ -8,6 +8,7 @@ namespace DownKyi.Models public class VideoInfoView : BindableBase { public string CoverUrl { get; set; } + public long UpperMid { get; set; } private BitmapImage cover; public BitmapImage Cover diff --git a/DownKyi/Services/BangumiInfoService.cs b/DownKyi/Services/BangumiInfoService.cs index 775319d..17f0d87 100644 --- a/DownKyi/Services/BangumiInfoService.cs +++ b/DownKyi/Services/BangumiInfoService.cs @@ -178,13 +178,12 @@ namespace DownKyi.Services { if (bangumiSeason == null) { return null; } - // 查询、保存封面 // 将SeasonId保存到avid字段中 // 每集封面的cid保存到cid字段,EpisodeId保存到bvid字段中 StorageCover storageCover = new StorageCover(); string coverUrl = bangumiSeason.Cover; - string cover = storageCover.GetCover(bangumiSeason.SeasonId, "", -1, coverUrl); + string cover = storageCover.GetCover(bangumiSeason.SeasonId, "bangumi", -1, coverUrl); // 获取用户头像 string upName; @@ -208,7 +207,7 @@ namespace DownKyi.Services { videoInfoView.CoverUrl = coverUrl; - videoInfoView.Cover = new BitmapImage(new Uri(cover)); + videoInfoView.Cover = cover == null ? null : new BitmapImage(new Uri(cover)); videoInfoView.Title = bangumiSeason.Title; videoInfoView.VideoZone = DictionaryResource.GetString(BangumiType.Type[bangumiSeason.Type]); @@ -227,6 +226,8 @@ namespace DownKyi.Services { StorageHeader storageHeader = new StorageHeader(); videoInfoView.UpHeader = storageHeader.GetHeaderThumbnail(header, 48, 48); + + videoInfoView.UpperMid = bangumiSeason.UpInfo.Mid; } else { diff --git a/DownKyi/Services/CheeseInfoService.cs b/DownKyi/Services/CheeseInfoService.cs index 92b7196..1a25a12 100644 --- a/DownKyi/Services/CheeseInfoService.cs +++ b/DownKyi/Services/CheeseInfoService.cs @@ -98,13 +98,12 @@ namespace DownKyi.Services { if (cheeseView == null) { return null; } - // 查询、保存封面 // 将SeasonId保存到avid字段中 // 每集封面的cid保存到cid字段,EpisodeId保存到bvid字段中 StorageCover storageCover = new StorageCover(); string coverUrl = cheeseView.Cover; - string cover = storageCover.GetCover(cheeseView.SeasonId, "", -1, coverUrl); + string cover = storageCover.GetCover(cheeseView.SeasonId, "cheese", -1, coverUrl); // 获取用户头像 string upName; @@ -127,7 +126,7 @@ namespace DownKyi.Services { videoInfoView.CoverUrl = coverUrl; - videoInfoView.Cover = new BitmapImage(new Uri(cover)); + videoInfoView.Cover = cover == null ? null : new BitmapImage(new Uri(cover)); videoInfoView.Title = cheeseView.Title; videoInfoView.VideoZone = DictionaryResource.GetString("Cheese"); @@ -147,6 +146,8 @@ namespace DownKyi.Services { StorageHeader storageHeader = new StorageHeader(); videoInfoView.UpHeader = storageHeader.GetHeaderThumbnail(header, 48, 48); + + videoInfoView.UpperMid = cheeseView.UpInfo.Mid; } else { diff --git a/DownKyi/Services/FavoritesService.cs b/DownKyi/Services/FavoritesService.cs new file mode 100644 index 0000000..cc542b7 --- /dev/null +++ b/DownKyi/Services/FavoritesService.cs @@ -0,0 +1,90 @@ +using DownKyi.Core.BiliApi.Favorites; +using DownKyi.Core.Storage; +using DownKyi.Core.Utils; +using DownKyi.Models; +using System; +using System.Collections.Generic; +using System.Windows.Media.Imaging; + +namespace DownKyi.Services +{ + public class FavoritesService : IFavoritesService + { + /// + /// 获取收藏夹元数据 + /// + /// + /// + public Favorites GetFavorites(long mediaId) + { + var favoritesMetaInfo = FavoritesInfo.GetFavoritesInfo(mediaId); + if (favoritesMetaInfo == null) { return null; } + + // 查询、保存封面 + StorageCover storageCover = new StorageCover(); + string coverUrl = favoritesMetaInfo.Cover; + string cover = storageCover.GetCover(favoritesMetaInfo.Id, "Favorites", favoritesMetaInfo.Mid, coverUrl); + + // 获取用户头像 + string upName; + string header; + if (favoritesMetaInfo.Upper != null) + { + upName = favoritesMetaInfo.Upper.Name; + StorageHeader storageHeader = new StorageHeader(); + header = storageHeader.GetHeader(favoritesMetaInfo.Upper.Mid, favoritesMetaInfo.Upper.Name, favoritesMetaInfo.Upper.Face); + } + else + { + upName = ""; + header = null; + } + + // 为Favorites赋值 + Favorites favorites = new Favorites(); + App.PropertyChangeAsync(new Action(() => + { + favorites.CoverUrl = coverUrl; + + favorites.Cover = cover == null ? null : new BitmapImage(new Uri(cover)); + favorites.Title = favoritesMetaInfo.Title; + + DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区 + DateTime dateTime = startTime.AddSeconds(favoritesMetaInfo.Ctime); + favorites.CreateTime = dateTime.ToString("yyyy-MM-dd HH:mm:ss"); + + favorites.PlayNumber = Format.FormatNumber(favoritesMetaInfo.CntInfo.Play); + favorites.LikeNumber = Format.FormatNumber(favoritesMetaInfo.CntInfo.ThumbUp); + favorites.FavoriteNumber = Format.FormatNumber(favoritesMetaInfo.CntInfo.Collect); + favorites.ShareNumber = Format.FormatNumber(favoritesMetaInfo.CntInfo.Share); + favorites.Description = favoritesMetaInfo.Intro; + favorites.MediaCount = favoritesMetaInfo.MediaCount; + + favorites.UpName = upName; + if (header != null) + { + StorageHeader storageHeader = new StorageHeader(); + favorites.UpHeader = storageHeader.GetHeaderThumbnail(header, 48, 48); + + favorites.UpperMid = favoritesMetaInfo.Upper.Mid; + } + else + { + favorites.UpHeader = null; + } + })); + + return favorites; + } + + /// + /// 获取收藏夹内容明细列表 + /// + /// + /// + public List GetFavoritesMediaList(long mediaId) + { + throw new NotImplementedException(); + } + } +} diff --git a/DownKyi/Services/IFavoritesService.cs b/DownKyi/Services/IFavoritesService.cs new file mode 100644 index 0000000..42e721b --- /dev/null +++ b/DownKyi/Services/IFavoritesService.cs @@ -0,0 +1,11 @@ +using DownKyi.Models; +using System.Collections.Generic; + +namespace DownKyi.Services +{ + public interface IFavoritesService + { + Favorites GetFavorites(long mediaId); + List GetFavoritesMediaList(long mediaId); + } +} diff --git a/DownKyi/Services/VideoInfoService.cs b/DownKyi/Services/VideoInfoService.cs index c34585d..49c6b60 100644 --- a/DownKyi/Services/VideoInfoService.cs +++ b/DownKyi/Services/VideoInfoService.cs @@ -200,7 +200,7 @@ namespace DownKyi.Services { videoInfoView.CoverUrl = coverUrl; - videoInfoView.Cover = new BitmapImage(new Uri(cover)); + videoInfoView.Cover = cover == null ? null : new BitmapImage(new Uri(cover)); videoInfoView.Title = videoView.Title; videoInfoView.VideoZone = videoZone; @@ -223,6 +223,8 @@ namespace DownKyi.Services { StorageHeader storageHeader = new StorageHeader(); videoInfoView.UpHeader = storageHeader.GetHeaderThumbnail(header, 48, 48); + + videoInfoView.UpperMid = videoView.Owner.Mid; } else { diff --git a/DownKyi/Themes/ColorBrush.xaml b/DownKyi/Themes/ColorBrush.xaml index ec39583..64dc369 100644 --- a/DownKyi/Themes/ColorBrush.xaml +++ b/DownKyi/Themes/ColorBrush.xaml @@ -39,5 +39,6 @@ + \ No newline at end of file diff --git a/DownKyi/Themes/Colors/ColorDefault.xaml b/DownKyi/Themes/Colors/ColorDefault.xaml index e3e3a26..b12aca1 100644 --- a/DownKyi/Themes/Colors/ColorDefault.xaml +++ b/DownKyi/Themes/Colors/ColorDefault.xaml @@ -39,5 +39,6 @@ white black #FF999999 + #FF757575 \ No newline at end of file diff --git a/DownKyi/Utils/NavigateToView.cs b/DownKyi/Utils/NavigateToView.cs new file mode 100644 index 0000000..5f126c0 --- /dev/null +++ b/DownKyi/Utils/NavigateToView.cs @@ -0,0 +1,52 @@ +using DownKyi.Core.Logging; +using DownKyi.Core.Settings; +using DownKyi.Core.Settings.Models; +using DownKyi.Events; +using DownKyi.ViewModels; +using Prism.Events; + +namespace DownKyi.Utils +{ + public static class NavigateToView + { + public static string Tag = "NavigateToView"; + + /// + /// 导航到用户空间, + /// 如果传入的mid与本地登录的mid一致, + /// 则进入我的用户空间。 + /// + /// + public static void NavigateToViewUserSpace(IEventAggregator eventAggregator, string parentViewName, long mid) + { + UserInfoSettings userInfo = SettingsManager.GetInstance().GetUserInfo(); + if (userInfo != null && userInfo.Mid == mid) + { + NavigationView(eventAggregator, ViewMySpaceViewModel.Tag, parentViewName, mid); + } + else + { + NavigationView(eventAggregator, ViewUserSpaceViewModel.Tag, parentViewName, mid); + } + } + + /// + /// 导航到其他页面 + /// + /// + /// + public static void NavigationView(IEventAggregator eventAggregator, string viewName, string parentViewName, object param) + { + LogManager.Debug(Tag, $"NavigationView: {viewName}, Parameter: {param}"); + + NavigationParam parameter = new NavigationParam + { + ViewName = viewName, + ParentViewName = parentViewName, + Parameter = param + }; + eventAggregator.GetEvent().Publish(parameter); + } + + } +} diff --git a/DownKyi/ViewModels/MainWindowViewModel.cs b/DownKyi/ViewModels/MainWindowViewModel.cs index 8f57848..22279ee 100644 --- a/DownKyi/ViewModels/MainWindowViewModel.cs +++ b/DownKyi/ViewModels/MainWindowViewModel.cs @@ -317,106 +317,69 @@ namespace DownKyi.ViewModels // 视频 if (ParseEntrance.IsAvId(input)) { - NavigationView(ViewVideoDetailViewModel.Tag, $"{ParseEntrance.VideoUrl}{input.ToLower()}"); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, ViewIndexViewModel.Tag, $"{ParseEntrance.VideoUrl}{input.ToLower()}"); } else if (ParseEntrance.IsAvUrl(input)) { - NavigationView(ViewVideoDetailViewModel.Tag, input); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, ViewIndexViewModel.Tag, input); } else if (ParseEntrance.IsBvId(input)) { - NavigationView(ViewVideoDetailViewModel.Tag, $"{ParseEntrance.VideoUrl}{input}"); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, ViewIndexViewModel.Tag, $"{ParseEntrance.VideoUrl}{input}"); } else if (ParseEntrance.IsBvUrl(input)) { - NavigationView(ViewVideoDetailViewModel.Tag, input); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, ViewIndexViewModel.Tag, input); } // 番剧(电影、电视剧) else if (ParseEntrance.IsBangumiSeasonId(input)) { - NavigationView(ViewVideoDetailViewModel.Tag, $"{ParseEntrance.BangumiUrl}{input.ToLower()}"); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, ViewIndexViewModel.Tag, $"{ParseEntrance.BangumiUrl}{input.ToLower()}"); } else if (ParseEntrance.IsBangumiSeasonUrl(input)) { - NavigationView(ViewVideoDetailViewModel.Tag, input); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, ViewIndexViewModel.Tag, input); } else if (ParseEntrance.IsBangumiEpisodeId(input)) { - NavigationView(ViewVideoDetailViewModel.Tag, $"{ParseEntrance.BangumiUrl}{input.ToLower()}"); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, ViewIndexViewModel.Tag, $"{ParseEntrance.BangumiUrl}{input.ToLower()}"); } else if (ParseEntrance.IsBangumiEpisodeUrl(input)) { - NavigationView(ViewVideoDetailViewModel.Tag, input); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, ViewIndexViewModel.Tag, input); } else if (ParseEntrance.IsBangumiMediaId(input)) { - NavigationView(ViewVideoDetailViewModel.Tag, $"{ParseEntrance.BangumiMediaUrl}{input.ToLower()}"); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, ViewIndexViewModel.Tag, $"{ParseEntrance.BangumiMediaUrl}{input.ToLower()}"); } else if (ParseEntrance.IsBangumiMediaUrl(input)) { - NavigationView(ViewVideoDetailViewModel.Tag, input); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, ViewIndexViewModel.Tag, input); } // 课程 else if (ParseEntrance.IsCheeseSeasonUrl(input) || ParseEntrance.IsCheeseEpisodeUrl(input)) { - NavigationView(ViewVideoDetailViewModel.Tag, input); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, ViewIndexViewModel.Tag, input); } // 用户(参数传入mid) else if (ParseEntrance.IsUserId(input)) { - NavigateToViewUserSpace(ParseEntrance.GetUserId(input)); + NavigateToView.NavigateToViewUserSpace(eventAggregator, ViewIndexViewModel.Tag, ParseEntrance.GetUserId(input)); } else if (ParseEntrance.IsUserUrl(input)) { - NavigateToViewUserSpace(ParseEntrance.GetUserId(input)); + NavigateToView.NavigateToViewUserSpace(eventAggregator, ViewIndexViewModel.Tag, ParseEntrance.GetUserId(input)); } // 收藏夹 else if (ParseEntrance.IsFavoritesId(input)) { - NavigationView(ViewPublicFavoritesViewModel.Tag, ParseEntrance.GetFavoritesId(input)); + NavigateToView.NavigationView(eventAggregator, ViewPublicFavoritesViewModel.Tag, ViewIndexViewModel.Tag, ParseEntrance.GetFavoritesId(input)); } else if (ParseEntrance.IsFavoritesUrl(input)) { - NavigationView(ViewPublicFavoritesViewModel.Tag, ParseEntrance.GetFavoritesId(input)); + NavigateToView.NavigationView(eventAggregator, ViewPublicFavoritesViewModel.Tag, ViewIndexViewModel.Tag, ParseEntrance.GetFavoritesId(input)); } } - /// - /// 导航到用户空间, - /// 如果传入的mid与本地登录的mid一致, - /// 则进入我的用户空间。 - /// - /// - private void NavigateToViewUserSpace(long mid) - { - var userInfo = SettingsManager.GetInstance().GetUserInfo(); - if (userInfo != null && userInfo.Mid == mid) - { - NavigationView(ViewMySpaceViewModel.Tag, mid); - } - else - { - NavigationView(ViewUserSpaceViewModel.Tag, mid); - } - } - - /// - /// 导航到其他页面 - /// - /// - /// - private void NavigationView(string viewName, object param) - { - LogManager.Debug("OnClipboardUpdated", $"NavigationView: {viewName}, Parameter: {param}"); - - NavigationParam parameter = new NavigationParam - { - ViewName = viewName, - ParentViewName = ViewIndexViewModel.Tag, - Parameter = param - }; - eventAggregator.GetEvent().Publish(parameter); - } - } } diff --git a/DownKyi/ViewModels/ViewIndexViewModel.cs b/DownKyi/ViewModels/ViewIndexViewModel.cs index f687d87..5cc547d 100644 --- a/DownKyi/ViewModels/ViewIndexViewModel.cs +++ b/DownKyi/ViewModels/ViewIndexViewModel.cs @@ -4,7 +4,6 @@ using DownKyi.Core.Logging; using DownKyi.Core.Settings; using DownKyi.Core.Settings.Models; using DownKyi.Core.Storage; -using DownKyi.Events; using DownKyi.Images; using DownKyi.Utils; using Prism.Commands; @@ -149,7 +148,7 @@ namespace DownKyi.ViewModels { if (UserName == null) { - NavigationView(ViewLoginViewModel.Tag, null); + NavigateToView.NavigationView(eventAggregator, ViewLoginViewModel.Tag, Tag, null); } else { @@ -157,7 +156,7 @@ namespace DownKyi.ViewModels var userInfo = SettingsManager.GetInstance().GetUserInfo(); if (userInfo != null && userInfo.Mid != -1) { - NavigationView(ViewMySpaceViewModel.Tag, userInfo.Mid); + NavigateToView.NavigationView(eventAggregator, ViewMySpaceViewModel.Tag, Tag, userInfo.Mid); } } } @@ -171,7 +170,7 @@ namespace DownKyi.ViewModels /// private void ExecuteSettingsCommand() { - NavigationView(ViewSettingsViewModel.Tag, null); + NavigateToView.NavigationView(eventAggregator, ViewSettingsViewModel.Tag, Tag, null); } // 进入下载管理页面 @@ -183,7 +182,7 @@ namespace DownKyi.ViewModels /// private void ExecuteDownloadManagerCommand() { - NavigationView(ViewDownloadManagerViewModel.Tag, null); + NavigateToView.NavigationView(eventAggregator, ViewDownloadManagerViewModel.Tag, Tag, null); } // 进入工具箱页面 @@ -195,7 +194,7 @@ namespace DownKyi.ViewModels /// private void ExecuteToolboxCommand() { - NavigationView(ViewToolboxViewModel.Tag, null); + NavigateToView.NavigationView(eventAggregator, ViewToolboxViewModel.Tag, Tag, null); } #endregion @@ -227,67 +226,67 @@ namespace DownKyi.ViewModels // 视频 if (ParseEntrance.IsAvId(InputText)) { - NavigationView(ViewVideoDetailViewModel.Tag, $"{ParseEntrance.VideoUrl}{InputText.ToLower()}"); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, Tag, $"{ParseEntrance.VideoUrl}{InputText.ToLower()}"); } else if (ParseEntrance.IsAvUrl(InputText)) { - NavigationView(ViewVideoDetailViewModel.Tag, InputText); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, Tag, InputText); } else if (ParseEntrance.IsBvId(InputText)) { - NavigationView(ViewVideoDetailViewModel.Tag, $"{ParseEntrance.VideoUrl}{InputText}"); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, Tag, $"{ParseEntrance.VideoUrl}{InputText}"); } else if (ParseEntrance.IsBvUrl(InputText)) { - NavigationView(ViewVideoDetailViewModel.Tag, InputText); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, Tag, InputText); } // 番剧(电影、电视剧) else if (ParseEntrance.IsBangumiSeasonId(InputText)) { - NavigationView(ViewVideoDetailViewModel.Tag, $"{ParseEntrance.BangumiUrl}{InputText.ToLower()}"); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, Tag, $"{ParseEntrance.BangumiUrl}{InputText.ToLower()}"); } else if (ParseEntrance.IsBangumiSeasonUrl(InputText)) { - NavigationView(ViewVideoDetailViewModel.Tag, InputText); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, Tag, InputText); } else if (ParseEntrance.IsBangumiEpisodeId(InputText)) { - NavigationView(ViewVideoDetailViewModel.Tag, $"{ParseEntrance.BangumiUrl}{InputText.ToLower()}"); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, Tag, $"{ParseEntrance.BangumiUrl}{InputText.ToLower()}"); } else if (ParseEntrance.IsBangumiEpisodeUrl(InputText)) { - NavigationView(ViewVideoDetailViewModel.Tag, InputText); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, Tag, InputText); } else if (ParseEntrance.IsBangumiMediaId(InputText)) { - NavigationView(ViewVideoDetailViewModel.Tag, $"{ParseEntrance.BangumiMediaUrl}{InputText.ToLower()}"); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, Tag, $"{ParseEntrance.BangumiMediaUrl}{InputText.ToLower()}"); } else if (ParseEntrance.IsBangumiMediaUrl(InputText)) { - NavigationView(ViewVideoDetailViewModel.Tag, InputText); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, Tag, InputText); } // 课程 else if (ParseEntrance.IsCheeseSeasonUrl(InputText) || ParseEntrance.IsCheeseEpisodeUrl(InputText)) { - NavigationView(ViewVideoDetailViewModel.Tag, InputText); + NavigateToView.NavigationView(eventAggregator, ViewVideoDetailViewModel.Tag, Tag, InputText); } // 用户(参数传入mid) else if (ParseEntrance.IsUserId(InputText)) { - NavigateToViewUserSpace(ParseEntrance.GetUserId(InputText)); + NavigateToView.NavigateToViewUserSpace(eventAggregator, Tag, ParseEntrance.GetUserId(InputText)); } else if (ParseEntrance.IsUserUrl(InputText)) { - NavigateToViewUserSpace(ParseEntrance.GetUserId(InputText)); + NavigateToView.NavigateToViewUserSpace(eventAggregator, Tag, ParseEntrance.GetUserId(InputText)); } // 收藏夹 else if (ParseEntrance.IsFavoritesId(InputText)) { - NavigationView(ViewPublicFavoritesViewModel.Tag, ParseEntrance.GetFavoritesId(InputText)); + NavigateToView.NavigationView(eventAggregator, ViewPublicFavoritesViewModel.Tag, Tag, ParseEntrance.GetFavoritesId(InputText)); } else if (ParseEntrance.IsFavoritesUrl(InputText)) { - NavigationView(ViewPublicFavoritesViewModel.Tag, ParseEntrance.GetFavoritesId(InputText)); + NavigateToView.NavigationView(eventAggregator, ViewPublicFavoritesViewModel.Tag, Tag, ParseEntrance.GetFavoritesId(InputText)); } // TODO 关键词搜索 else @@ -297,43 +296,6 @@ namespace DownKyi.ViewModels InputText = string.Empty; } - /// - /// 导航到用户空间, - /// 如果传入的mid与本地登录的mid一致, - /// 则进入我的用户空间。 - /// - /// - private void NavigateToViewUserSpace(long mid) - { - var userInfo = SettingsManager.GetInstance().GetUserInfo(); - if (userInfo != null && userInfo.Mid == mid) - { - NavigationView(ViewMySpaceViewModel.Tag, mid); - } - else - { - NavigationView(ViewUserSpaceViewModel.Tag, mid); - } - } - - /// - /// 导航到其他页面 - /// - /// - /// - private void NavigationView(string viewName, object param) - { - LogManager.Debug(Tag, $"NavigationView: {viewName}, Parameter: {param}"); - - NavigationParam parameter = new NavigationParam - { - ViewName = viewName, - ParentViewName = Tag, - Parameter = param - }; - eventAggregator.GetEvent().Publish(parameter); - } - /// /// 更新用户登录信息 /// diff --git a/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs b/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs index 20b8cc4..54240d6 100644 --- a/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs +++ b/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs @@ -1,10 +1,18 @@ -using Prism.Commands; +using DownKyi.Core.Logging; +using DownKyi.Events; +using DownKyi.Images; +using DownKyi.Models; +using DownKyi.Services; +using DownKyi.Utils; +using Prism.Commands; using Prism.Events; using Prism.Mvvm; using Prism.Regions; using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; +using System.Windows; namespace DownKyi.ViewModels { @@ -12,28 +20,234 @@ namespace DownKyi.ViewModels { public const string Tag = "PagePublicFavorites"; - // 收藏夹id - private long favoritesId; + #region 页面属性申明 + + private VectorImage arrowBack; + public VectorImage ArrowBack + { + get { return arrowBack; } + set { SetProperty(ref arrowBack, value); } + } + + private VectorImage play; + public VectorImage Play + { + get { return play; } + set { SetProperty(ref play, value); } + } + + private VectorImage like; + public VectorImage Like + { + get { return like; } + set { SetProperty(ref like, value); } + } + + private VectorImage favorite; + public VectorImage Favorite + { + get { return favorite; } + set { SetProperty(ref favorite, value); } + } + + private VectorImage share; + public VectorImage Share + { + get { return share; } + set { SetProperty(ref share, value); } + } + + private Favorites favorites; + public Favorites Favorites + { + get { return favorites; } + set { SetProperty(ref favorites, value); } + } + + private List favoritesMedia; + public List FavoritesMedia + { + get { return favoritesMedia; } + set { SetProperty(ref favoritesMedia, value); } + } + + private Visibility contentVisibility; + public Visibility ContentVisibility + { + get { return contentVisibility; } + set { SetProperty(ref contentVisibility, value); } + } + + private Visibility noDataVisibility; + public Visibility NoDataVisibility + { + get { return noDataVisibility; } + set { SetProperty(ref noDataVisibility, value); } + } + + #endregion public ViewPublicFavoritesViewModel(IEventAggregator eventAggregator) : base(eventAggregator) { + #region 属性初始化 + + ArrowBack = NavigationIcon.Instance().ArrowBack; + ArrowBack.Fill = DictionaryResource.GetColor("ColorTextDark"); + + 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 + } + + #region 命令申明 + + // 返回 + private DelegateCommand backSpaceCommand; + public DelegateCommand BackSpaceCommand => backSpaceCommand ?? (backSpaceCommand = new DelegateCommand(ExecuteBackSpace)); + + /// + /// 返回 + /// + private void ExecuteBackSpace() + { + NavigationParam parameter = new NavigationParam + { + ViewName = ParentView, + ParentViewName = null, + Parameter = null + }; + eventAggregator.GetEvent().Publish(parameter); + } + + // 复制封面事件 + private DelegateCommand copyCoverCommand; + public DelegateCommand CopyCoverCommand => copyCoverCommand ?? (copyCoverCommand = new DelegateCommand(ExecuteCopyCoverCommand)); + + /// + /// 复制封面事件 + /// + private void ExecuteCopyCoverCommand() + { + // 复制封面图片到剪贴板 + Clipboard.SetImage(Favorites.Cover); + LogManager.Info(Tag, "复制封面图片到剪贴板"); + } + + // 复制封面URL事件 + private DelegateCommand copyCoverUrlCommand; + public DelegateCommand CopyCoverUrlCommand => copyCoverUrlCommand ?? (copyCoverUrlCommand = new DelegateCommand(ExecuteCopyCoverUrlCommand)); + + /// + /// 复制封面URL事件 + /// + private void ExecuteCopyCoverUrlCommand() + { + // 复制封面url到剪贴板 + Clipboard.SetText(Favorites.CoverUrl); + LogManager.Info(Tag, "复制封面url到剪贴板"); + } + + // 前往UP主页事件 + private DelegateCommand upperCommand; + public DelegateCommand UpperCommand => upperCommand ?? (upperCommand = new DelegateCommand(ExecuteUpperCommand)); + + /// + /// 前往UP主页事件 + /// + private void ExecuteUpperCommand() + { + NavigateToView.NavigateToViewUserSpace(eventAggregator, Tag, Favorites.UpperMid); + } + + // 添加选中项到下载列表事件 + private DelegateCommand addToDownloadCommand; + public DelegateCommand AddToDownloadCommand => addToDownloadCommand ?? (addToDownloadCommand = new DelegateCommand(ExecuteAddToDownloadCommand)); + + /// + /// 添加选中项到下载列表事件 + /// + private void ExecuteAddToDownloadCommand() + { + } + + // 添加所有视频到下载列表事件 + private DelegateCommand addAllToDownloadCommand; + public DelegateCommand AddAllToDownloadCommand => addAllToDownloadCommand ?? (addAllToDownloadCommand = new DelegateCommand(ExecuteAddAllToDownloadCommand)); + + /// + /// 添加所有视频到下载列表事件 + /// + private void ExecuteAddAllToDownloadCommand() + { + } + + #endregion + + /// + /// 初始化页面元素 + /// + private void InitView() + { + LogManager.Debug(Tag, "初始化页面元素"); + + ContentVisibility = Visibility.Collapsed; + NoDataVisibility = Visibility.Collapsed; + } + + /// + /// 更新页面 + /// + private void UpdateView(IFavoritesService favoritesService, long favoritesId) + { + Favorites = favoritesService.GetFavorites(favoritesId); + if (Favorites == null) + { + LogManager.Debug(Tag, "Favorites is null."); + + ContentVisibility = Visibility.Collapsed; + NoDataVisibility = Visibility.Visible; + return; + } + else + { + ContentVisibility = Visibility.Visible; + NoDataVisibility = Visibility.Collapsed; + } + } /// /// 接收收藏夹id参数 /// /// - public override void OnNavigatedTo(NavigationContext navigationContext) + public override async void OnNavigatedTo(NavigationContext navigationContext) { base.OnNavigatedTo(navigationContext); + InitView(); + // 根据传入参数不同执行不同任务 long parameter = navigationContext.Parameters.GetValue("Parameter"); if (parameter == 0) { return; } - favoritesId = parameter; + + await Task.Run(new Action(() => + { + UpdateView(new FavoritesService(), parameter); + })); + } } } diff --git a/DownKyi/ViewModels/ViewVideoDetailViewModel.cs b/DownKyi/ViewModels/ViewVideoDetailViewModel.cs index daf3174..6084403 100644 --- a/DownKyi/ViewModels/ViewVideoDetailViewModel.cs +++ b/DownKyi/ViewModels/ViewVideoDetailViewModel.cs @@ -137,8 +137,6 @@ namespace DownKyi.ViewModels /// private void ExecuteBackSpace() { - InitView(); - NavigationParam parameter = new NavigationParam { ViewName = ParentView, @@ -242,6 +240,18 @@ namespace DownKyi.ViewModels LogManager.Info(Tag, "复制封面url到剪贴板"); } + // 前往UP主页事件 + private DelegateCommand upperCommand; + public DelegateCommand UpperCommand => upperCommand ?? (upperCommand = new DelegateCommand(ExecuteUpperCommand)); + + /// + /// 前往UP主页事件 + /// + private void ExecuteUpperCommand() + { + NavigateToView.NavigateToViewUserSpace(eventAggregator, Tag, VideoInfoView.UpperMid); + } + // 视频章节选择事件 private DelegateCommand videoSectionsCommand; public DelegateCommand VideoSectionsCommand => videoSectionsCommand ?? (videoSectionsCommand = new DelegateCommand(ExecuteVideoSectionsCommand)); @@ -614,6 +624,7 @@ namespace DownKyi.ViewModels { LoadingVisibility = Visibility.Collapsed; ContentVisibility = Visibility.Visible; + NoDataVisibility = Visibility.Collapsed; } var videoSections = videoInfoService.GetVideoSections(); diff --git a/DownKyi/Views/ViewPublicFavorites.xaml b/DownKyi/Views/ViewPublicFavorites.xaml index c06d6e9..68740bc 100644 --- a/DownKyi/Views/ViewPublicFavorites.xaml +++ b/DownKyi/Views/ViewPublicFavorites.xaml @@ -2,9 +2,296 @@ x:Class="DownKyi.Views.ViewPublicFavorites" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:i="http://schemas.microsoft.com/xaml/behaviors" xmlns:prism="http://prismlibrary.com/" prism:ViewModelLocator.AutoWireViewModel="True"> + - 公开访问的收藏夹 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +