From 77f92dd1fafea6248ecafbcdf060951bc29dcbee Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Fri, 22 Nov 2024 12:31:49 +0800 Subject: [PATCH 01/17] =?UTF-8?q?Revert=20"#903=20=E5=A4=96=E7=BD=AE?= =?UTF-8?q?=E5=AD=97=E5=B9=95=E6=95=88=E6=9E=9C=E4=B8=8D=E5=A5=BD=EF=BC=8C?= =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=B1=8F=E8=94=BD=E5=85=A5=E5=8F=A3"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 1603bb094293c341652bc830af58985c3fba2186. --- src/BiliLite.UWP/Controls/PlayerControl.xaml | 4 ++-- src/BiliLite.UWP/Controls/PlayerControl.xaml.cs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml b/src/BiliLite.UWP/Controls/PlayerControl.xaml index b123eae1..9d248bf4 100644 --- a/src/BiliLite.UWP/Controls/PlayerControl.xaml +++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml @@ -605,10 +605,10 @@ 繁体字幕转简体 - + diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs index 1bb8e454..481b8ade 100644 --- a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs @@ -605,13 +605,13 @@ private void LoadSutitleSetting() UpdateSubtitle(); }); //外置字幕大小 - //OutsideSubtitleSettingSize.Value = 3;//SettingService.GetValue(SettingConstants.Player.SUBTITLE_SIZE, 40); - //OutsideSubtitleSettingSize.ValueChanged += new RangeBaseValueChangedEventHandler((e, args) => - //{ - // if (miniWin) return; - // //SettingService.SetValue(SettingConstants.Player.SUBTITLE_SIZE, SubtitleSettingSize.Value); - // m_assSubtitleController.SetFontZoom((int)OutsideSubtitleSettingSize.Value); - //}); + OutsideSubtitleSettingSize.Value = 3;//SettingService.GetValue(SettingConstants.Player.SUBTITLE_SIZE, 40); + OutsideSubtitleSettingSize.ValueChanged += new RangeBaseValueChangedEventHandler((e, args) => + { + if (miniWin) return; + //SettingService.SetValue(SettingConstants.Player.SUBTITLE_SIZE, SubtitleSettingSize.Value); + m_assSubtitleController.SetFontZoom((int)OutsideSubtitleSettingSize.Value); + }); //字幕描边颜色 SubtitleSettingBorderColor.SelectedIndex = SettingService.GetValue(SettingConstants.Player.SUBTITLE_BORDER_COLOR, 0); SubtitleSettingBorderColor.SelectionChanged += new SelectionChangedEventHandler((e, args) => From 98cd2a9c1e33d9ca19f7c92d97e0fa50a86d8edb Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Fri, 22 Nov 2024 12:32:56 +0800 Subject: [PATCH 02/17] =?UTF-8?q?Revert=20"#903=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=8C=82=E8=BD=BD=E5=A4=96=E9=83=A8ass=E5=AD=97=E5=B9=95"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 824715676f4b8303a7ba2cc1d76a5e50baa2dc5b. --- src/BiliLite.UWP/Controls/PlayerControl.xaml | 8 --- .../Controls/PlayerControl.xaml.cs | 57 ++----------------- src/BiliLite.UWP/Modules/Player/PlayerVM.cs | 22 ------- .../Services/FrostMasterDanmakuController.cs | 6 -- 4 files changed, 4 insertions(+), 89 deletions(-) diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml b/src/BiliLite.UWP/Controls/PlayerControl.xaml index 9d248bf4..609d1bf8 100644 --- a/src/BiliLite.UWP/Controls/PlayerControl.xaml +++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml @@ -605,10 +605,6 @@ 繁体字幕转简体 - 外置字幕 - - 外置字幕大小 - @@ -633,10 +629,6 @@ - - - - diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs index 481b8ade..23b5d429 100644 --- a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs @@ -1,4 +1,4 @@ -using BiliLite.Modules; +using BiliLite.Modules; using NSDanmaku.Model; using System; using System.Collections.Generic; @@ -54,7 +54,6 @@ public sealed partial class PlayerControl : UserControl, IDisposable private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); private readonly bool m_useNsDanmaku = true; private readonly IDanmakuController m_danmakuController; - private readonly FrostMasterDanmakuController m_assSubtitleController; private readonly VideoDanmakuSettingsControlViewModel m_danmakuSettingsControlViewModel; private readonly PlayControlViewModel m_viewModel; private readonly PlayerToastService m_playerToastService; @@ -174,12 +173,9 @@ public PlayerControl() } else { - m_danmakuController = App.ServiceProvider.GetRequiredService(); + m_danmakuController = App.ServiceProvider.GetRequiredService(); m_danmakuController.Init(DanmakuCanvas); } - - m_assSubtitleController = App.ServiceProvider.GetRequiredService(); - m_assSubtitleController.Init(SubtitleCanvas); } private void Timer_focus_Tick(object sender, object e) @@ -233,7 +229,6 @@ private void PlayerControl_Unloaded(object sender, RoutedEventArgs e) private async void PlayerControl_Loaded(object sender, RoutedEventArgs e) { m_danmakuController.Clear(); - m_assSubtitleController.Clear(); BtnFoucs.Focus(FocusState.Programmatic); _systemMediaTransportControls = SystemMediaTransportControls.GetForCurrentView(); _systemMediaTransportControls.IsPlayEnabled = true; @@ -501,7 +496,7 @@ private void LoadPlayerSetting() { //音量 Player.Volume = SettingService.GetValue(SettingConstants.Player.PLAYER_VOLUME, SettingConstants.Player.DEFAULT_PLAYER_VOLUME); - + var lockPlayerVolume = SettingService.GetValue(SettingConstants.Player.LOCK_PLAYER_VOLUME, SettingConstants.Player.DEFAULT_LOCK_PLAYER_VOLUME); if (!lockPlayerVolume) { @@ -604,14 +599,6 @@ private void LoadSutitleSetting() SettingService.SetValue(SettingConstants.Player.SUBTITLE_SIZE, SubtitleSettingSize.Value); UpdateSubtitle(); }); - //外置字幕大小 - OutsideSubtitleSettingSize.Value = 3;//SettingService.GetValue(SettingConstants.Player.SUBTITLE_SIZE, 40); - OutsideSubtitleSettingSize.ValueChanged += new RangeBaseValueChangedEventHandler((e, args) => - { - if (miniWin) return; - //SettingService.SetValue(SettingConstants.Player.SUBTITLE_SIZE, SubtitleSettingSize.Value); - m_assSubtitleController.SetFontZoom((int)OutsideSubtitleSettingSize.Value); - }); //字幕描边颜色 SubtitleSettingBorderColor.SelectedIndex = SettingService.GetValue(SettingConstants.Player.SUBTITLE_BORDER_COLOR, 0); SubtitleSettingBorderColor.SelectionChanged += new SelectionChangedEventHandler((e, args) => @@ -840,7 +827,6 @@ private async void DanmuTimer_Tick(object sender, object e) return; } m_danmakuController.UpdateTime(position); - m_assSubtitleController.UpdateTime(position); var needDistinct = DanmuSettingMerge.IsOn; var level = DanmuSettingShieldLevel.Value; @@ -854,7 +840,6 @@ private async void DanmuTimer_Tick(object sender, object e) if (Player.PlayState == PlayState.Pause) { m_danmakuController.Pause(); - m_assSubtitleController.Pause(); } } @@ -1024,15 +1009,6 @@ private async void SetSubTitle(string url) { try { - if (url.EndsWith(".ass")) - { - var content = await playerHelper.GetAssFileContent(url); - m_assSubtitleController.SetFontZoom(1); - m_assSubtitleController.SetAssSubtitle(content); - - return; - } - subtitles = await playerHelper.GetSubtitle(url); if (subtitles != null) { @@ -1050,9 +1026,8 @@ private async void SetSubTitle(string url) subtitleTimer.Start(); } } - catch (Exception ex) + catch (Exception) { - _logger.Error(ex.Message, ex); Notify.ShowMessageToast("加载字幕失败了"); } @@ -1166,7 +1141,6 @@ private async Task GenerateSubtitleItem(string text) /// private void ClearSubTitle() { - m_assSubtitleController.Clear(); if (subtitles != null) { if (subtitleTimer != null) @@ -1701,7 +1675,6 @@ public void FullScreen(bool fullScreen) FullScreenEvent?.Invoke(this, fullScreen); MessageCenter.SetFullscreen(fullScreen); m_danmakuController.SetFullscreen(fullScreen); - m_assSubtitleController.SetFullscreen(fullScreen); if (fullScreen) { BottomBtnExitFull.Visibility = Visibility.Visible; @@ -2258,7 +2231,6 @@ private void BottomBtnPlay_Click(object sender, RoutedEventArgs e) { Player.Play(); m_danmakuController.Resume(); - m_assSubtitleController.Resume(); } } @@ -2320,7 +2292,6 @@ private void Player_PlayStateChanged(object sender, PlayState e) BottomBtnPlay.Visibility = Visibility.Collapsed; BottomBtnPause.Visibility = Visibility.Visible; m_danmakuController.Resume(); - m_assSubtitleController.Resume(); break; case PlayState.Pause: KeepScreenOn(false); @@ -2333,7 +2304,6 @@ private void Player_PlayStateChanged(object sender, PlayState e) BottomBtnPlay.Visibility = Visibility.Visible; BottomBtnPause.Visibility = Visibility.Collapsed; m_danmakuController.Pause(); - m_assSubtitleController.Pause(); break; case PlayState.End: KeepScreenOn(false); @@ -2367,7 +2337,6 @@ private void Player_PlayBufferStart(object sender, EventArgs e) TxtBuffering.Text = "正在缓冲..."; BufferingProgress = 0; m_danmakuController.Pause(); - m_assSubtitleController.Pause(); } private void Player_PlayBuffering(object sender, double e) @@ -2383,7 +2352,6 @@ private void Player_PlayBufferEnd(object sender, EventArgs e) GridBuffering.Visibility = Visibility.Collapsed; Buffering = false; m_danmakuController.Resume(); - m_assSubtitleController.Resume(); } private async void Player_PlayMediaEnded(object sender, EventArgs e) @@ -2396,7 +2364,6 @@ private async void Player_PlayMediaEnded(object sender, EventArgs e) return; } m_danmakuController.Pause(); - m_assSubtitleController.Pause(); InteractionChoices.Visibility = Visibility.Visible; return; } @@ -2450,7 +2417,6 @@ private async void Player_PlayMediaEnded(object sender, EventArgs e) { ClearSubTitle(); m_danmakuController.Clear(); - m_assSubtitleController.Clear(); Player.Play(); return; } @@ -2467,7 +2433,6 @@ private async void Player_PlayMediaEnded(object sender, EventArgs e) { ClearSubTitle(); m_danmakuController.Clear(); - m_assSubtitleController.Clear(); Player.Play(); return; } @@ -3014,19 +2979,5 @@ private void ViewPoint_OnTapped(object sender, TappedRoutedEventArgs e) if (!(element.DataContext is PlayerInfoViewPoint viewPoint)) return; SetPosition(viewPoint.From); } - - private async void BtnImportSubFile_OnClick(object sender, RoutedEventArgs e) - { - var path = await playerHelper.GetOutsideSubtitle(); - - if (path == null) return; - - (BottomBtnSelctSubtitle.Flyout as MenuFlyout).Items.Add(new ToggleMenuFlyoutItem() - { - Tag = path, - Name = "外置字幕" - }); - SetSubTitle(path); - } } } diff --git a/src/BiliLite.UWP/Modules/Player/PlayerVM.cs b/src/BiliLite.UWP/Modules/Player/PlayerVM.cs index da1673a7..fad2e140 100644 --- a/src/BiliLite.UWP/Modules/Player/PlayerVM.cs +++ b/src/BiliLite.UWP/Modules/Player/PlayerVM.cs @@ -13,7 +13,6 @@ using BiliLite.Services; using BiliLite.Models.Common.Video; using BiliLite.Models.Common.Video.PlayUrlInfos; -using Windows.Storage.Pickers; namespace BiliLite.Modules { @@ -273,27 +272,6 @@ public async Task GetOnline(string aid, string cid) } return ""; } - - public async Task GetOutsideSubtitle() - { - var filePicker = new FileOpenPicker(); - filePicker.FileTypeFilter.Add(".ass"); - var file = await filePicker.PickSingleFileAsync(); - if (file == null) return null; - - var fileContent = await FileIO.ReadTextAsync(file); - var tempFolder = Windows.Storage.ApplicationData.Current.TemporaryFolder; - var tempFile = await tempFolder.CreateFileAsync($"{Guid.NewGuid().ToString()}.ass", Windows.Storage.CreationCollisionOption.ReplaceExisting); - await FileIO.WriteTextAsync(tempFile, fileContent); - return tempFile.Path; - } - - public async Task GetAssFileContent(string path) - { - var jsonFile = await StorageFile.GetFileFromPathAsync(path); - var content = await FileIO.ReadTextAsync(jsonFile); - return content; - } } diff --git a/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs b/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs index d599e744..6e2eb235 100644 --- a/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs +++ b/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs @@ -196,11 +196,5 @@ public override void UpdateTime(long position) base.UpdateTime(position); m_danmakuMaster.UpdateTime((uint)position * 1000); } - - public void SetAssSubtitle(string assContent) - { - var subItems = AssParser.GetDanmakuList(assContent); - m_danmakuMaster.SetSubtitleList(subItems); - } } } From e9f739de6cf7fa5a09b0790baf40dfa10ca3d7fb Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Sun, 24 Nov 2024 14:42:39 +0800 Subject: [PATCH 03/17] =?UTF-8?q?#922=20=E4=BF=AE=E5=A4=8D=E9=83=A8?= =?UTF-8?q?=E5=88=86=E9=A2=9C=E8=89=B2=E4=B8=8E=E8=AE=BE=E7=BD=AE=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E4=B8=8D=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/App.xaml.cs | 19 +++-- src/BiliLite.UWP/BiliLite.UWP.csproj | 6 +- .../Settings/UISettingsControl.xaml.cs | 27 +++---- .../Converters/ColorSelectedConvert.cs | 10 ++- src/BiliLite.UWP/Pages/SeasonDetailPage.xaml | 4 +- src/BiliLite.UWP/Services/ThemeService.cs | 71 +++++++++++++++++++ src/BiliLite.UWP/Startup.cs | 1 + src/BiliLite.UWP/Themes/Colors.xaml | 24 +++++-- .../Season/SeasonDetailPageViewModel.cs | 19 ++++- .../Video/VideoDetailPageViewModel.cs | 6 +- 10 files changed, 148 insertions(+), 39 deletions(-) create mode 100644 src/BiliLite.UWP/Services/ThemeService.cs diff --git a/src/BiliLite.UWP/App.xaml.cs b/src/BiliLite.UWP/App.xaml.cs index 187139b9..ce6e7b5f 100644 --- a/src/BiliLite.UWP/App.xaml.cs +++ b/src/BiliLite.UWP/App.xaml.cs @@ -161,7 +161,6 @@ private async void Navigation(object arguments, bool prelaunch = false) rootFrame.NavigationFailed += OnNavigationFailed; - //主题颜色 rootFrame.RequestedTheme = (ElementTheme)SettingService.GetValue(SettingConstants.UI.THEME, 0); @@ -182,7 +181,8 @@ private async void Navigation(object arguments, bool prelaunch = false) } // 确保当前窗口处于活动状态 Window.Current.Activate(); - ExtendAcrylicIntoTitleBar(); + var themeService = ServiceProvider.GetRequiredService(); + themeService.InitTitleBar(); } } @@ -222,6 +222,16 @@ private async void InitBili() } VideoPlayHistoryHelper.LoadABPlayHistories(true); + try + { + var themeService = ServiceProvider.GetRequiredService(); + await themeService.Init(); + } + catch (Exception ex) + { + logger.Error("初始化主题错误", ex); + } + //var pluginService = ServiceProvider.GetRequiredService(); //await pluginService.Start(); } @@ -255,11 +265,6 @@ private void OnSuspending(object sender, SuspendingEventArgs e) deferral.Complete(); } - public static void ExtendAcrylicIntoTitleBar() - { - AppExtensions.HandleTitleTheme(); - } - protected override void OnActivated(IActivatedEventArgs args) { base.OnActivated(args); diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index 3bc9bf1a..84b3684f 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -281,6 +281,7 @@ + @@ -1461,10 +1462,11 @@ MSBuild:Compile Designer - + MSBuild:Compile Designer - + Always + MSBuild:Compile Designer diff --git a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs index fcb763cb..2e85ee31 100644 --- a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs @@ -7,6 +7,7 @@ using BiliLite.Models.Common; using BiliLite.Models.Common.Home; using BiliLite.Services; +using Microsoft.Extensions.DependencyInjection; using Microsoft.UI.Xaml.Controls; using Microsoft.Toolkit.Uwp.UI; @@ -16,8 +17,11 @@ namespace BiliLite.Controls.Settings { public sealed partial class UISettingsControl : UserControl { + private readonly ThemeService m_themeService; + public UISettingsControl() { + m_themeService = App.ServiceProvider.GetRequiredService(); this.InitializeComponent(); LoadUI(); } @@ -29,25 +33,10 @@ private void LoadUI() { cbTheme.SelectionChanged += new SelectionChangedEventHandler((obj, args) => { - SettingService.SetValue(SettingConstants.UI.THEME, cbTheme.SelectedIndex); - Frame rootFrame = Window.Current.Content as Frame; - switch (cbTheme.SelectedIndex) - { - case 1: - rootFrame.RequestedTheme = ElementTheme.Light; - break; - case 2: - rootFrame.RequestedTheme = ElementTheme.Dark; - break; - //case 3: - // // TODO: 切换自定义主题 - // rootFrame.Resources = Application.Current.Resources.ThemeDictionaries["Pink"] as ResourceDictionary; - // break; - default: - rootFrame.RequestedTheme = ElementTheme.Default; - break; - } - App.ExtendAcrylicIntoTitleBar(); + var themeIndex = cbTheme.SelectedIndex; + if (themeIndex > 2) + m_themeService.SetTheme(ElementTheme.Default); + m_themeService.SetTheme((ElementTheme)themeIndex); }); }); diff --git a/src/BiliLite.UWP/Converters/ColorSelectedConvert.cs b/src/BiliLite.UWP/Converters/ColorSelectedConvert.cs index e29abf5e..59ea77bc 100644 --- a/src/BiliLite.UWP/Converters/ColorSelectedConvert.cs +++ b/src/BiliLite.UWP/Converters/ColorSelectedConvert.cs @@ -2,16 +2,20 @@ using Windows.UI; using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Media; +using BiliLite.Services; +using Microsoft.Extensions.DependencyInjection; + namespace BiliLite.Converters { public class ColorSelectedConvert : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { - if (value == null) return new SolidColorBrush((Color)App.Current.Resources["TextColor"]); + var themeService = App.ServiceProvider.GetRequiredService(); + if (value == null) return new SolidColorBrush((Color)themeService.ThemeResource["TextColor"]); return value.ToString() == parameter.ToString() - ? new SolidColorBrush((Color)App.Current.Resources["SystemAccentColor"]) - : new SolidColorBrush((Color)App.Current.Resources["TextColor"]); + ? new SolidColorBrush((Color)themeService.ThemeResource["SystemAccentColor"]) + : new SolidColorBrush((Color)themeService.ThemeResource["TextColor"]); } public object ConvertBack(object value, Type targetType, object parameter, string language) diff --git a/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml b/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml index 03461d03..491ddad2 100644 --- a/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml +++ b/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml @@ -159,7 +159,9 @@ - + diff --git a/src/BiliLite.UWP/Services/ThemeService.cs b/src/BiliLite.UWP/Services/ThemeService.cs new file mode 100644 index 00000000..dff3d850 --- /dev/null +++ b/src/BiliLite.UWP/Services/ThemeService.cs @@ -0,0 +1,71 @@ +using System; +using System.Threading.Tasks; +using Windows.Storage; +using Windows.UI.Xaml.Markup; +using Windows.UI.Xaml; +using BiliLite.Extensions; +using BiliLite.Models.Common; +using Windows.UI.Xaml.Controls; + +namespace BiliLite.Services +{ + public class ThemeService + { + private ResourceDictionary m_defaultColorsResource; + private ElementTheme m_theme; + + public ThemeService() + { + m_theme = (ElementTheme)SettingService.GetValue(SettingConstants.UI.THEME, 0); + if (m_theme == ElementTheme.Default) + { + m_theme = (ElementTheme)(App.Current.RequestedTheme - 1); + } + } + + public async Task Init() + { + var colorFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Themes/Colors.xaml")); + var colorsText = await FileIO.ReadTextAsync(colorFile); + m_defaultColorsResource = (ResourceDictionary)XamlReader.Load(colorsText); + } + + public ResourceDictionary ThemeResource + { + get + { + if(m_theme==ElementTheme.Light)return m_defaultColorsResource.ThemeDictionaries["Light"] as ResourceDictionary; + return m_defaultColorsResource.ThemeDictionaries["Dark"] as ResourceDictionary; + } + } + + public void InitTitleBar() + { + AppExtensions.HandleTitleTheme(); + } + + public void SetTheme(ElementTheme theme) + { + m_theme = theme; + SettingService.SetValue(SettingConstants.UI.THEME, (int)theme); + var rootFrame = Window.Current.Content as Frame; + switch (theme) + { + case ElementTheme.Light: + rootFrame.RequestedTheme = ElementTheme.Light; + break; + case ElementTheme.Dark: + rootFrame.RequestedTheme = ElementTheme.Dark; + break; + //case 3: + // // TODO: 切换自定义主题 + // rootFrame.Resources = Application.Current.Resources.ThemeDictionaries["Pink"] as ResourceDictionary; + // break; + default: + rootFrame.RequestedTheme = ElementTheme.Default; + break; + } + InitTitleBar(); + } + } +} diff --git a/src/BiliLite.UWP/Startup.cs b/src/BiliLite.UWP/Startup.cs index 1745f0fa..97dd28e4 100644 --- a/src/BiliLite.UWP/Startup.cs +++ b/src/BiliLite.UWP/Startup.cs @@ -32,6 +32,7 @@ public void ConfigureServices(HostBuilderContext context, IServiceCollection ser services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); } } } diff --git a/src/BiliLite.UWP/Themes/Colors.xaml b/src/BiliLite.UWP/Themes/Colors.xaml index bcc590b4..59f0e68e 100644 --- a/src/BiliLite.UWP/Themes/Colors.xaml +++ b/src/BiliLite.UWP/Themes/Colors.xaml @@ -35,10 +35,16 @@ - + + @@ -101,6 +107,16 @@ x:Key="AccentTextFillColorTertiaryBrush" Opacity="0.7" Color="{ThemeResource SystemAccentColor}" /> + + diff --git a/src/BiliLite.UWP/ViewModels/Season/SeasonDetailPageViewModel.cs b/src/BiliLite.UWP/ViewModels/Season/SeasonDetailPageViewModel.cs index 4bd0df62..b5be6711 100644 --- a/src/BiliLite.UWP/ViewModels/Season/SeasonDetailPageViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Season/SeasonDetailPageViewModel.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading.Tasks; using System.Windows.Input; +using Windows.UI; using Windows.UI.Xaml; using AutoMapper; using BiliLite.Extensions; @@ -18,6 +19,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PropertyChanged; +using Windows.UI.Xaml.Media; namespace BiliLite.ViewModels.Season { @@ -30,13 +32,15 @@ public class SeasonDetailPageViewModel : BaseViewModel private readonly FollowAPI m_followApi; private readonly IMapper m_mapper; private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); + private readonly ThemeService m_themeService; #endregion #region Constructors public SeasonDetailPageViewModel() { - m_mapper = App.ServiceProvider.GetService(); + m_mapper = App.ServiceProvider.GetRequiredService(); + m_themeService = App.ServiceProvider.GetRequiredService(); m_seasonApi = new SeasonApi(); m_playerApi = new PlayerAPI(); m_followApi = new FollowAPI(); @@ -116,6 +120,19 @@ public GridLength RightInfoWidth } } + [DependsOn(nameof(PageHeight), nameof(PageWidth))] + public Brush RightInfoBackground + { + get + { + if (PageWidth < 1000) + { + return (Brush)m_themeService.ThemeResource["PlayerControlAcrylicBrush"]; + } + return new SolidColorBrush(Colors.Transparent); + } + } + [DependsOn(nameof(PageHeight), nameof(PageWidth))] public double RightInfoHeight { diff --git a/src/BiliLite.UWP/ViewModels/Video/VideoDetailPageViewModel.cs b/src/BiliLite.UWP/ViewModels/Video/VideoDetailPageViewModel.cs index 6ad9810c..39b4e1ac 100644 --- a/src/BiliLite.UWP/ViewModels/Video/VideoDetailPageViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Video/VideoDetailPageViewModel.cs @@ -39,6 +39,7 @@ public class VideoDetailPageViewModel : BaseViewModel readonly PlayerAPI PlayerAPI; readonly FollowAPI followAPI; private readonly IMapper m_mapper; + private readonly ThemeService m_themeService; #endregion @@ -46,7 +47,8 @@ public class VideoDetailPageViewModel : BaseViewModel public VideoDetailPageViewModel() { - m_mapper = App.ServiceProvider.GetService(); + m_mapper = App.ServiceProvider.GetRequiredService(); + m_themeService = App.ServiceProvider.GetRequiredService(); videoAPI = new VideoAPI(); favoriteAPI = new FavoriteApi(); PlayerAPI = new PlayerAPI(); @@ -152,7 +154,7 @@ public Brush RightInfoBackground { if (PageWidth < 1000) { - return (Brush)Application.Current.Resources["AcrylicInAppFillColorDefaultBrush"]; + return (Brush)m_themeService.ThemeResource["PlayerControlAcrylicBrush"]; } return new SolidColorBrush(Colors.Transparent); From 48c3974d549915e1a271eb7383c72b76676a3b27 Mon Sep 17 00:00:00 2001 From: ProJend <55018532+ProJend@users.noreply.github.com> Date: Wed, 27 Nov 2024 23:34:05 +0800 Subject: [PATCH 04/17] =?UTF-8?q?#285=20#209=20=E6=9B=B4=E6=96=B0=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E7=A3=81=E8=B4=B4=20(#880)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 初步实现动态磁贴 --- BiliLite.sln | 22 +++ src/BackgroundTasks/BackgroundTasks.csproj | 154 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 29 ++++ src/BackgroundTasks/TileFeedBackgroundTask.cs | 23 +++ src/BiliLite.Packages/Package.appxmanifest | 16 ++ src/BiliLite.UWP/App.xaml.cs | 14 +- src/BiliLite.UWP/BiliLite.UWP.csproj | 8 + .../Controls/Settings/UISettingsControl.xaml | 8 + .../Settings/UISettingsControl.xaml.cs | 28 ++++ .../NotificationRegisterExtensions.cs | 99 +++++++++++ .../NotificationShowExtensions.cs | 47 ++++++ .../Common/Notifications/NotificationTile.cs | 11 ++ .../Notifications/Template/TileTemplate.cs | 94 +++++++++++ .../Models/Common/SettingConstants.cs | 6 + src/BiliLite.UWP/Package.appxmanifest | 2 +- .../Services/Notification/LiveTileService.cs | 25 +++ src/BiliLite.UWP/Startup.cs | 2 + 17 files changed, 585 insertions(+), 3 deletions(-) create mode 100644 src/BackgroundTasks/BackgroundTasks.csproj create mode 100644 src/BackgroundTasks/Properties/AssemblyInfo.cs create mode 100644 src/BackgroundTasks/TileFeedBackgroundTask.cs create mode 100644 src/BiliLite.UWP/Extensions/Notifications/NotificationRegisterExtensions.cs create mode 100644 src/BiliLite.UWP/Extensions/Notifications/NotificationShowExtensions.cs create mode 100644 src/BiliLite.UWP/Models/Common/Notifications/NotificationTile.cs create mode 100644 src/BiliLite.UWP/Models/Common/Notifications/Template/TileTemplate.cs create mode 100644 src/BiliLite.UWP/Services/Notification/LiveTileService.cs diff --git a/BiliLite.sln b/BiliLite.sln index c7201e94..3ab038f3 100644 --- a/BiliLite.sln +++ b/BiliLite.sln @@ -28,6 +28,8 @@ Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "BiliLite.Packages", "src\Bi EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BiliLite.Win32Tools", "src\BiliLite.Win32Tools\BiliLite.Win32Tools.csproj", "{B44AD18B-7805-4FFB-A29E-C57D09C8D425}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackgroundTasks", "src\BackgroundTasks\BackgroundTasks.csproj", "{32288EDB-3F7F-479A-8303-7BB6705E0636}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -200,6 +202,26 @@ Global {B44AD18B-7805-4FFB-A29E-C57D09C8D425}.Release|x64.Build.0 = Release|Any CPU {B44AD18B-7805-4FFB-A29E-C57D09C8D425}.Release|x86.ActiveCfg = Release|Any CPU {B44AD18B-7805-4FFB-A29E-C57D09C8D425}.Release|x86.Build.0 = Release|Any CPU + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|Any CPU.Build.0 = Debug|Any CPU + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|ARM.ActiveCfg = Debug|ARM + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|ARM.Build.0 = Debug|ARM + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|ARM64.Build.0 = Debug|ARM64 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|x64.ActiveCfg = Debug|x64 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|x64.Build.0 = Debug|x64 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|x86.ActiveCfg = Debug|x86 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|x86.Build.0 = Debug|x86 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|Any CPU.ActiveCfg = Release|Any CPU + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|Any CPU.Build.0 = Release|Any CPU + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|ARM.ActiveCfg = Release|ARM + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|ARM.Build.0 = Release|ARM + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|ARM64.ActiveCfg = Release|ARM64 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|ARM64.Build.0 = Release|ARM64 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|x64.ActiveCfg = Release|x64 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|x64.Build.0 = Release|x64 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|x86.ActiveCfg = Release|x86 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/BackgroundTasks/BackgroundTasks.csproj b/src/BackgroundTasks/BackgroundTasks.csproj new file mode 100644 index 00000000..ecad63af --- /dev/null +++ b/src/BackgroundTasks/BackgroundTasks.csproj @@ -0,0 +1,154 @@ + + + + + latest + Debug + AnyCPU + {32288EDB-3F7F-479A-8303-7BB6705E0636} + winmdobj + Properties + BackgroundTasks + BackgroundTasks + zh-CN + UAP + 10.0.22621.0 + 10.0.19041.0 + 14 + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + false + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + prompt + 4 + + + x86 + true + bin\x86\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + false + prompt + + + x86 + bin\x86\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + false + prompt + + + ARM + true + bin\ARM\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + false + prompt + + + ARM + bin\ARM\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + false + prompt + + + ARM64 + true + bin\ARM64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + false + prompt + + + ARM64 + bin\ARM64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + false + prompt + + + x64 + true + bin\x64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + false + prompt + true + + + x64 + bin\x64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + false + prompt + + + PackageReference + + + + + + + + 6.2.14 + + + + + {8b90b3b3-844b-4610-9dcf-c9b250182ae3} + BiliLite.UWP + + + + 14.0 + + + + + + + \ No newline at end of file diff --git a/src/BackgroundTasks/Properties/AssemblyInfo.cs b/src/BackgroundTasks/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..a8a3fb81 --- /dev/null +++ b/src/BackgroundTasks/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("BackgroundTasks")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("BackgroundTasks")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/src/BackgroundTasks/TileFeedBackgroundTask.cs b/src/BackgroundTasks/TileFeedBackgroundTask.cs new file mode 100644 index 00000000..98a217a8 --- /dev/null +++ b/src/BackgroundTasks/TileFeedBackgroundTask.cs @@ -0,0 +1,23 @@ +using System.Diagnostics; +using Windows.ApplicationModel.Background; +using BiliLite.Extensions.Notifications; + +namespace BackgroundTasks +{ + public sealed class TileFeedBackgroundTask : IBackgroundTask + { + public void Run(IBackgroundTaskInstance taskInstance) + { + Debug.WriteLine("================ debug to updating tiles ================"); + + // Get a deferral, to prevent the task from closing prematurely + // while asynchronous code is still running. + var deferral = taskInstance.GetDeferral(); + + NotificationShowExtensions.Tile(); + + // Inform the system that the task is finished. + deferral.Complete(); + } + } +} \ No newline at end of file diff --git a/src/BiliLite.Packages/Package.appxmanifest b/src/BiliLite.Packages/Package.appxmanifest index 3b9a830e..717d0de8 100644 --- a/src/BiliLite.Packages/Package.appxmanifest +++ b/src/BiliLite.Packages/Package.appxmanifest @@ -61,6 +61,12 @@ + + + + + @@ -72,4 +78,14 @@ + + + + CLRHost.dll + + + + diff --git a/src/BiliLite.UWP/App.xaml.cs b/src/BiliLite.UWP/App.xaml.cs index ce6e7b5f..d240fc7b 100644 --- a/src/BiliLite.UWP/App.xaml.cs +++ b/src/BiliLite.UWP/App.xaml.cs @@ -1,8 +1,11 @@ using BiliLite.Extensions; using BiliLite.Models.Common; using BiliLite.Models.Events; +using BiliLite.Pages; using BiliLite.Services; +using BiliLite.Services.Notification; using FFmpegInteropX; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Toolkit.Uwp.Helpers; using System; @@ -14,8 +17,7 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; -using BiliLite.Pages; -using Microsoft.Extensions.DependencyInjection; +using BiliLite.Extensions.Notifications; namespace BiliLite { @@ -205,6 +207,7 @@ private async void InitBili() // await Task.Delay(200); // 防止初始屏幕闪烁 } } + //圆角 App.Current.Resources["ImageCornerRadius"] = new CornerRadius(SettingService.GetValue(SettingConstants.UI.IMAGE_CORNER_RADIUS, 0)); await AppHelper.SetRegions(); @@ -292,5 +295,12 @@ private void RegisterService() logger.Error("Start Host Error", ex); } } + + protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs args) + { + //base.OnBackgroundActivated(args); + //IBackgroundTaskInstance taskInstance = args.TaskInstance; + await NotificationShowExtensions.Tile(); + } } } \ No newline at end of file diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index 84b3684f..cd3ac582 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -262,6 +262,7 @@ + @@ -279,6 +280,10 @@ + + + + @@ -1537,6 +1542,9 @@ 6.1.1 + + 7.1.3 + 6.1.1 diff --git a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml index 67f861e6..71de8f30 100644 --- a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml +++ b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml @@ -200,6 +200,14 @@ + + + + + + + diff --git a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs index 2e85ee31..54b614a0 100644 --- a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs @@ -10,6 +10,8 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.UI.Xaml.Controls; using Microsoft.Toolkit.Uwp.UI; +using BiliLite.Extensions.Notifications; +using Windows.ApplicationModel.Background; //https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板 @@ -131,6 +133,24 @@ private void LoadUI() }; }; + //动态磁贴 + SwitchTile.IsOn = SettingService.GetValue(SettingConstants.UI.ENABLE_NOTIFICATION_TILES, false); + SwitchTile.Loaded += (sender, e) => + { + SwitchTile.Toggled += (obj, args) => + { + SettingService.SetValue(SettingConstants.UI.ENABLE_NOTIFICATION_TILES, SwitchTile.IsOn); + if (SwitchTile.IsOn) + { + RegisterBackgroundTask(); + } + else + { + // TODO: UnregisterBackgroundTask + } + }; + }; + //图片圆角半径 numImageCornerRadius.Value = SettingService.GetValue(SettingConstants.UI.IMAGE_CORNER_RADIUS, 0); ImageCornerRadiusExample.CornerRadius = new CornerRadius(numImageCornerRadius.Value); @@ -361,5 +381,13 @@ private void menuRemoveHomeItem_Click(object sender, RoutedEventArgs e) ExceptHomeNavItems(); Notify.ShowMessageToast("更改成功,重启生效"); } + + private void RegisterBackgroundTask() + { + NotificationRegisterExtensions.BackgroundTask("DisposableTileFeedBackgroundTask"); + NotificationRegisterExtensions.BackgroundTask("TileFeedBackgroundTask", new TimeTrigger(15, false)); + //NotificationRegisterExtensions.BackgroundTask("TileFeedBackgroundTask", + // "BackgroundTasks.TileFeedBackgroundTask", new TimeTrigger(15, false)); + } } } diff --git a/src/BiliLite.UWP/Extensions/Notifications/NotificationRegisterExtensions.cs b/src/BiliLite.UWP/Extensions/Notifications/NotificationRegisterExtensions.cs new file mode 100644 index 00000000..4611448b --- /dev/null +++ b/src/BiliLite.UWP/Extensions/Notifications/NotificationRegisterExtensions.cs @@ -0,0 +1,99 @@ +using System; +using Windows.ApplicationModel.Background; + +namespace BiliLite.Extensions.Notifications +{ + public class NotificationRegisterExtensions + { + /// + /// 单次执行后台任务 + /// + /// + public static async void BackgroundTask(string taskName) + { + BackgroundExecutionManager.RemoveAccess(); + var backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync(); + if (backgroundAccessStatus == BackgroundAccessStatus.AllowedSubjectToSystemPolicy || + backgroundAccessStatus == BackgroundAccessStatus.AlwaysAllowed) + { + foreach (var task in BackgroundTaskRegistration.AllTasks) + { + if (task.Value.Name == taskName) + { + task.Value.Unregister(true); + } + } + + var taskBuilder = new BackgroundTaskBuilder() + { + Name = taskName, + }; + var trigger = new ApplicationTrigger(); + taskBuilder.SetTrigger(trigger); + taskBuilder.Register(); + await trigger.RequestAsync(); + } + } + + /// + /// 注册进程内后台任务 + /// + /// + /// + public static async void BackgroundTask(string taskName, IBackgroundTrigger trigger) + { + BackgroundExecutionManager.RemoveAccess(); + var backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync(); + if (backgroundAccessStatus == BackgroundAccessStatus.AllowedSubjectToSystemPolicy || + backgroundAccessStatus == BackgroundAccessStatus.AlwaysAllowed) + { + foreach (var task in BackgroundTaskRegistration.AllTasks) + { + if (task.Value.Name == taskName) + { + task.Value.Unregister(true); + } + } + + var taskBuilder = new BackgroundTaskBuilder() + { + Name = taskName, + }; + taskBuilder.SetTrigger(trigger); + taskBuilder.Register(); + } + } + + /// + /// (不可用)注册进程外后台任务 + /// + /// + /// + /// + public static async void BackgroundTask(string taskName, string taskEntryPoint, IBackgroundTrigger trigger) + { + BackgroundExecutionManager.RemoveAccess(); + var backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync(); + if (backgroundAccessStatus == BackgroundAccessStatus.AllowedSubjectToSystemPolicy || + backgroundAccessStatus == BackgroundAccessStatus.AlwaysAllowed) + { + foreach (var task in BackgroundTaskRegistration.AllTasks) + { + if (task.Value.Name == taskName) + { + task.Value.Unregister(true); + } + } + + + var taskBuilder = new BackgroundTaskBuilder() + { + Name = taskName, + TaskEntryPoint = taskEntryPoint + }; + taskBuilder.SetTrigger(trigger); + taskBuilder.Register(); + } + } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Extensions/Notifications/NotificationShowExtensions.cs b/src/BiliLite.UWP/Extensions/Notifications/NotificationShowExtensions.cs new file mode 100644 index 00000000..d42a988a --- /dev/null +++ b/src/BiliLite.UWP/Extensions/Notifications/NotificationShowExtensions.cs @@ -0,0 +1,47 @@ +using System.Threading.Tasks; +using Windows.UI.Notifications; +using BiliLite.Models.Common.Notifications.Template; +using BiliLite.Services.Notification; +using Microsoft.Extensions.DependencyInjection; + +namespace BiliLite.Extensions.Notifications +{ + public class NotificationShowExtensions + { + public static async Task Tile() + { + // Create a tile update manager for the specified syndication feed. + var updater = TileUpdateManager.CreateTileUpdaterForApplication(); + updater.Clear(); + updater.EnableNotificationQueue(true); + + var liveTileHelper = App.ServiceProvider.GetRequiredService(); + + await liveTileHelper.RefreshTile(); + foreach (var tile in liveTileHelper.TileFurnace) + { + var content = TileTemplate.LiveTile(tile); + var notification = new TileNotification(content.GetXml()) + { + Tag = tile.Name, + }; + updater.Update(notification); + } + } + + public static void Dialog() + { + + } + + public static void MessageDialog() + { + + } + + public static void Toast() + { + + } + } +} diff --git a/src/BiliLite.UWP/Models/Common/Notifications/NotificationTile.cs b/src/BiliLite.UWP/Models/Common/Notifications/NotificationTile.cs new file mode 100644 index 00000000..d41f1401 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Notifications/NotificationTile.cs @@ -0,0 +1,11 @@ +namespace BiliLite.Models.Common.Notifications +{ + public class NotificationTile + { + public string Name { get; set; } + + public string Description { get; set; } + + public string Url { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Notifications/Template/TileTemplate.cs b/src/BiliLite.UWP/Models/Common/Notifications/Template/TileTemplate.cs new file mode 100644 index 00000000..0e6701c3 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Notifications/Template/TileTemplate.cs @@ -0,0 +1,94 @@ +using Microsoft.Toolkit.Uwp.Notifications; + +namespace BiliLite.Models.Common.Notifications.Template +{ + public class TileTemplate + { + public static TileContent LiveTile(NotificationTile notificationTile) => new TileContent() + { + // 创建静态磁贴对象并返回 + Visual = new TileVisual() + { + Branding = TileBranding.NameAndLogo, + TileMedium = new TileBinding() + { + Content = new TileBindingContentAdaptive() + { + Children = + { + new AdaptiveText() + { + Text = notificationTile.Description, + HintMaxLines = 3, + HintWrap = true, + }, + new AdaptiveText() + { + Text = notificationTile.Name, + HintStyle = AdaptiveTextStyle.CaptionSubtle, + HintAlign = AdaptiveTextAlign.Center, + }, + }, + PeekImage = new TilePeekImage() + { + Source = notificationTile.Url, + HintOverlay = 30, + }, + } + }, + TileWide = new TileBinding() + { + Content = new TileBindingContentAdaptive() + { + Children = + { + new AdaptiveText() + { + Text = notificationTile.Description, + HintStyle = AdaptiveTextStyle.Body, + HintMaxLines = 2, + HintWrap = true, + }, + new AdaptiveText() + { + Text = notificationTile.Name, + HintAlign = AdaptiveTextAlign.Center, + }, + }, + BackgroundImage = new TileBackgroundImage() + { + Source = notificationTile.Url, + }, + } + }, + TileLarge = new TileBinding() + { + Content = new TileBindingContentAdaptive() + { + Children = + { + new AdaptiveText() + { + Text = notificationTile.Description, + HintStyle = AdaptiveTextStyle.Subtitle, + HintMaxLines = 5, + HintWrap = true, + }, + new AdaptiveText() {}, + new AdaptiveText() + { + Text = notificationTile.Name, + HintStyle = AdaptiveTextStyle.Base, + HintAlign = AdaptiveTextAlign.Center, + }, + }, + BackgroundImage = new TileBackgroundImage() + { + Source = notificationTile.Url, + }, + } + } + } + }; + } +} diff --git a/src/BiliLite.UWP/Models/Common/SettingConstants.cs b/src/BiliLite.UWP/Models/Common/SettingConstants.cs index 18e3cf0b..77bcdb67 100644 --- a/src/BiliLite.UWP/Models/Common/SettingConstants.cs +++ b/src/BiliLite.UWP/Models/Common/SettingConstants.cs @@ -234,6 +234,12 @@ public class UI [SettingDefaultValue] public const double DEFAULT_TAB_ITEM_MIN_WIDTH = 192; + + /// + /// 是否启用动态磁贴 + /// + // 因为要开关时注册磁贴服务,所以不设置SettingKey + public const string ENABLE_NOTIFICATION_TILES = "EnableNotificationTiles"; } public class Account diff --git a/src/BiliLite.UWP/Package.appxmanifest b/src/BiliLite.UWP/Package.appxmanifest index 8ffbb2a4..9957f3a1 100644 --- a/src/BiliLite.UWP/Package.appxmanifest +++ b/src/BiliLite.UWP/Package.appxmanifest @@ -57,7 +57,7 @@ - + diff --git a/src/BiliLite.UWP/Services/Notification/LiveTileService.cs b/src/BiliLite.UWP/Services/Notification/LiveTileService.cs new file mode 100644 index 00000000..149ba20b --- /dev/null +++ b/src/BiliLite.UWP/Services/Notification/LiveTileService.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using BiliLite.Models.Common.Notifications; + +namespace BiliLite.Services.Notification +{ + public class LiveTileService + { + public List TileFurnace = new List(); + + public async Task RefreshTile() + { + TileFurnace.Clear(); + // TODO: 取热门/动态/推荐数据 + var sample = new NotificationTile() + { + Name = "BiliLIte", + Description = "", + Url = @"Assets/SplashScreen.png", + }; + TileFurnace.Add(sample); + } + } +} diff --git a/src/BiliLite.UWP/Startup.cs b/src/BiliLite.UWP/Startup.cs index 97dd28e4..69dc22c7 100644 --- a/src/BiliLite.UWP/Startup.cs +++ b/src/BiliLite.UWP/Startup.cs @@ -1,6 +1,7 @@ using BiliLite.Extensions; using BiliLite.Services; using BiliLite.Services.Biz; +using BiliLite.Services.Notification; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -15,6 +16,7 @@ public void ConfigureServices(HostBuilderContext context, IServiceCollection ser services.AddSingleton(); services.AddTransient(); + services.AddSingleton(); services.AddMapper(); services.AddViewModels(); services.AddControls(); From 9c104b103889eeb7654eae75e0236b4d5e169daa Mon Sep 17 00:00:00 2001 From: ProJend <55018532+ProJend@users.noreply.github.com> Date: Fri, 29 Nov 2024 14:31:01 +0800 Subject: [PATCH 05/17] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=92=E8=A1=8C?= =?UTF-8?q?=E6=A6=9C=E9=A1=B5=E9=9D=A2=E6=97=A0=E6=B3=95=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20(#927)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/Pages/RankPage.xaml.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/BiliLite.UWP/Pages/RankPage.xaml.cs b/src/BiliLite.UWP/Pages/RankPage.xaml.cs index 07ef30e1..33c5466c 100644 --- a/src/BiliLite.UWP/Pages/RankPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/RankPage.xaml.cs @@ -1,14 +1,13 @@ using BiliLite.Extensions; using BiliLite.Models.Common; -using BiliLite.Modules; +using BiliLite.Models.Common.Rank; using BiliLite.Services; +using BiliLite.ViewModels.Rank; +using Microsoft.Extensions.DependencyInjection; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Navigation; -using BiliLite.Models.Common.Rank; -using BiliLite.ViewModels.Rank; -using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -23,20 +22,21 @@ public sealed partial class RankPage : BasePage public RankPage() { m_viewModel = App.ServiceProvider.GetRequiredService(); + m_viewModel.LoadRankRegion(0); this.InitializeComponent(); Title = "排行榜"; + + NavigationCacheMode = SettingService.GetValue(SettingConstants.UI.CACHE_HOME, true) + ? NavigationCacheMode.Required + : NavigationCacheMode.Disabled; } protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); - if (e.NavigationMode == NavigationMode.New) + if (e.Parameter != null) { - var rid = 0; - if (e.Parameter != null) - { - rid = e.Parameter.ToInt32(); - } + int rid = e.Parameter.ToInt32(); m_viewModel.LoadRankRegion(rid); } } From 5cddd520f3e13ebd6c865147085cf4b891e91273 Mon Sep 17 00:00:00 2001 From: ProJend <55018532+ProJend@users.noreply.github.com> Date: Mon, 2 Dec 2024 20:07:12 +0800 Subject: [PATCH 06/17] =?UTF-8?q?=E5=88=86=E7=A6=BB=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=20(#928)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 分离主题颜色 --- src/BiliLite.UWP/App.xaml | 9 +- src/BiliLite.UWP/App.xaml.cs | 5 +- src/BiliLite.UWP/BiliLite.UWP.csproj | 19 ++- src/BiliLite.UWP/MainPage.xaml.cs | 14 +- src/BiliLite.UWP/Services/ThemeService.cs | 34 ++-- .../{Themes => Styles}/Breakpoint.xaml | 0 .../{Themes => Styles}/Converter.xaml | 0 .../{Themes => Styles}/Fonts.xaml | 0 src/BiliLite.UWP/Themes/Blue.xaml | 48 ++++++ src/BiliLite.UWP/Themes/Colors.xaml | 148 ------------------ src/BiliLite.UWP/Themes/Default.xaml | 80 ++++++++++ src/BiliLite.UWP/Themes/Pink.xaml | 48 ++++++ 12 files changed, 220 insertions(+), 185 deletions(-) rename src/BiliLite.UWP/{Themes => Styles}/Breakpoint.xaml (100%) rename src/BiliLite.UWP/{Themes => Styles}/Converter.xaml (100%) rename src/BiliLite.UWP/{Themes => Styles}/Fonts.xaml (100%) create mode 100644 src/BiliLite.UWP/Themes/Blue.xaml delete mode 100644 src/BiliLite.UWP/Themes/Colors.xaml create mode 100644 src/BiliLite.UWP/Themes/Default.xaml create mode 100644 src/BiliLite.UWP/Themes/Pink.xaml diff --git a/src/BiliLite.UWP/App.xaml b/src/BiliLite.UWP/App.xaml index aff62f40..6b7e7ee8 100644 --- a/src/BiliLite.UWP/App.xaml +++ b/src/BiliLite.UWP/App.xaml @@ -12,10 +12,11 @@ - - - - + + + + + 4 diff --git a/src/BiliLite.UWP/App.xaml.cs b/src/BiliLite.UWP/App.xaml.cs index d240fc7b..cc3a42d0 100644 --- a/src/BiliLite.UWP/App.xaml.cs +++ b/src/BiliLite.UWP/App.xaml.cs @@ -1,9 +1,9 @@ using BiliLite.Extensions; +using BiliLite.Extensions.Notifications; using BiliLite.Models.Common; using BiliLite.Models.Events; using BiliLite.Pages; using BiliLite.Services; -using BiliLite.Services.Notification; using FFmpegInteropX; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -17,7 +17,6 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; -using BiliLite.Extensions.Notifications; namespace BiliLite { @@ -228,7 +227,7 @@ private async void InitBili() try { var themeService = ServiceProvider.GetRequiredService(); - await themeService.Init(); + themeService.Init(); } catch (Exception ex) { diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index cd3ac582..9e9ef13a 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -1463,23 +1463,30 @@ Designer MSBuild:Compile - + MSBuild:Compile Designer - + MSBuild:Compile Designer - Always - - + + + MSBuild:Compile + Designer + + MSBuild:Compile Designer - + MSBuild:Compile Designer + + Designer + MSBuild:Compile + diff --git a/src/BiliLite.UWP/MainPage.xaml.cs b/src/BiliLite.UWP/MainPage.xaml.cs index ec5ae0ce..1534dd8c 100644 --- a/src/BiliLite.UWP/MainPage.xaml.cs +++ b/src/BiliLite.UWP/MainPage.xaml.cs @@ -1,4 +1,10 @@ -using BiliLite.Pages; +using BiliLite.Controls; +using BiliLite.Extensions; +using BiliLite.Models.Common; +using BiliLite.Pages; +using BiliLite.Services; +using BiliLite.ViewModels.Common; +using Microsoft.Extensions.DependencyInjection; using Microsoft.UI.Xaml.Controls; using System; using System.Linq; @@ -9,12 +15,6 @@ using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Navigation; -using BiliLite.Controls; -using BiliLite.Models.Common; -using BiliLite.Extensions; -using BiliLite.Services; -using BiliLite.ViewModels.Common; -using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x804 上介绍了“空白页”项模板 diff --git a/src/BiliLite.UWP/Services/ThemeService.cs b/src/BiliLite.UWP/Services/ThemeService.cs index dff3d850..24272bc4 100644 --- a/src/BiliLite.UWP/Services/ThemeService.cs +++ b/src/BiliLite.UWP/Services/ThemeService.cs @@ -1,10 +1,7 @@ -using System; -using System.Threading.Tasks; -using Windows.Storage; -using Windows.UI.Xaml.Markup; -using Windows.UI.Xaml; -using BiliLite.Extensions; +using BiliLite.Extensions; using BiliLite.Models.Common; +using System.Linq; +using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; namespace BiliLite.Services @@ -23,18 +20,13 @@ public ThemeService() } } - public async Task Init() - { - var colorFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Themes/Colors.xaml")); - var colorsText = await FileIO.ReadTextAsync(colorFile); - m_defaultColorsResource = (ResourceDictionary)XamlReader.Load(colorsText); - } + public void Init() => m_defaultColorsResource = Application.Current.Resources.MergedDictionaries.FirstOrDefault(x => x.Source.AbsoluteUri.Contains("Default")); public ResourceDictionary ThemeResource { get { - if(m_theme==ElementTheme.Light)return m_defaultColorsResource.ThemeDictionaries["Light"] as ResourceDictionary; + if (m_theme == ElementTheme.Light) return m_defaultColorsResource.ThemeDictionaries["Light"] as ResourceDictionary; return m_defaultColorsResource.ThemeDictionaries["Dark"] as ResourceDictionary; } } @@ -57,15 +49,23 @@ public void SetTheme(ElementTheme theme) case ElementTheme.Dark: rootFrame.RequestedTheme = ElementTheme.Dark; break; - //case 3: - // // TODO: 切换自定义主题 - // rootFrame.Resources = Application.Current.Resources.ThemeDictionaries["Pink"] as ResourceDictionary; - // break; default: rootFrame.RequestedTheme = ElementTheme.Default; break; } InitTitleBar(); } + + public void SetColor() + { + //case 3: + // // TODO: 切换自定义主题 + // rootFrame.Resources = Application.Current.Resources.ThemeDictionaries["Pink"] as ResourceDictionary; + // break; + //case 4: + // // TODO: 切换自定义主题 + // rootFrame.Resources = Application.Current.Resources.ThemeDictionaries["Blue"] as ResourceDictionary; + // break; + } } } diff --git a/src/BiliLite.UWP/Themes/Breakpoint.xaml b/src/BiliLite.UWP/Styles/Breakpoint.xaml similarity index 100% rename from src/BiliLite.UWP/Themes/Breakpoint.xaml rename to src/BiliLite.UWP/Styles/Breakpoint.xaml diff --git a/src/BiliLite.UWP/Themes/Converter.xaml b/src/BiliLite.UWP/Styles/Converter.xaml similarity index 100% rename from src/BiliLite.UWP/Themes/Converter.xaml rename to src/BiliLite.UWP/Styles/Converter.xaml diff --git a/src/BiliLite.UWP/Themes/Fonts.xaml b/src/BiliLite.UWP/Styles/Fonts.xaml similarity index 100% rename from src/BiliLite.UWP/Themes/Fonts.xaml rename to src/BiliLite.UWP/Styles/Fonts.xaml diff --git a/src/BiliLite.UWP/Themes/Blue.xaml b/src/BiliLite.UWP/Themes/Blue.xaml new file mode 100644 index 00000000..20ffad4f --- /dev/null +++ b/src/BiliLite.UWP/Themes/Blue.xaml @@ -0,0 +1,48 @@ + + + + + + + #0092D0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/BiliLite.UWP/Themes/Colors.xaml b/src/BiliLite.UWP/Themes/Colors.xaml deleted file mode 100644 index 59f0e68e..00000000 --- a/src/BiliLite.UWP/Themes/Colors.xaml +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - - - - #D14E65 - - - - - - - - - - - - - - - - - - - - - - - - - - - #D14E65 - #CC000000 - #0F000000 - #FFFFFFFF - #CC000000 - #008ac5 - #989898 - Gray - #f8f8f8 - #FF808080 - - - #FFF9F9F9 - #1A333333 - #1A333333 - #1A333333 - - - - - - - - - - - - #D14E65 - - - - - - - - - - - - - - - - - - - - - - - - - - - - #D14E65 - #CCFFFFFF - #19000000 - #FFFFFFFF - #CC000000 - #008ac5 - #989898 - Gray - #2d2d2d - #FF808080 - - - #FF282828 - #1ACFCFCF - #1ACFCFCF - #1ACFCFCF - - - - - - - - diff --git a/src/BiliLite.UWP/Themes/Default.xaml b/src/BiliLite.UWP/Themes/Default.xaml new file mode 100644 index 00000000..d12f67df --- /dev/null +++ b/src/BiliLite.UWP/Themes/Default.xaml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + #CC000000 + #0F000000 + #FFFFFFFF + #CC000000 + #008ac5 + #989898 + Gray + #f8f8f8 + #FF808080 + + + #FFF9F9F9 + #1A333333 + #1A333333 + #1A333333 + + + + + + #CCFFFFFF + #19000000 + #FFFFFFFF + #CC000000 + #008ac5 + #989898 + Gray + #2d2d2d + #FF808080 + + + #FF282828 + #1ACFCFCF + #1ACFCFCF + #1ACFCFCF + + + + + + + diff --git a/src/BiliLite.UWP/Themes/Pink.xaml b/src/BiliLite.UWP/Themes/Pink.xaml new file mode 100644 index 00000000..f6698c9d --- /dev/null +++ b/src/BiliLite.UWP/Themes/Pink.xaml @@ -0,0 +1,48 @@ + + + + + + + #D14E65 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 67ae5e7a5e25505861d63d2fbc12bc904a66f57d Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Mon, 2 Dec 2024 20:08:53 +0800 Subject: [PATCH 07/17] =?UTF-8?q?=E6=95=B4=E7=90=86=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E7=9B=B4=E6=92=AD=E9=A1=B5=E5=92=8C=E7=83=AD=E9=97=A8=E9=A1=B5?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/BiliLite.UWP.csproj | 13 +- src/BiliLite.UWP/Controls/CommentControl.xaml | 4 +- src/BiliLite.UWP/Controls/PlayerControl.xaml | 5 +- .../Dialogs/SendCommentDialog.xaml | 4 +- .../Extensions/ViewModelExtensions.cs | 26 +- .../Attributes/RegisterServiceAttributes.cs | 28 ++ .../Models/Common/Home/HotDataItemModel.cs | 56 ++++ .../Models/Common/Home/HotTopItemModel.cs | 19 ++ .../Models/Common/Home/LiveHomeAreaModel.cs | 24 ++ .../Models/Common/Home/LiveHomeBannerModel.cs | 13 + .../Common/Home/LiveHomeItemsItemModel.cs | 42 +++ .../Models/Common/Home/LiveHomeItemsModel.cs | 13 + .../Home/LiveHomeItemsModuleInfoModel.cs | 17 ++ .../Common/Home/LivePendentItemModel.cs | 20 ++ src/BiliLite.UWP/Modules/Home/HotVM.cs | 200 --------------- src/BiliLite.UWP/Modules/Home/LiveVM.cs | 242 ------------------ src/BiliLite.UWP/Pages/Home/HotPage.xaml | 23 +- src/BiliLite.UWP/Pages/Home/HotPage.xaml.cs | 23 +- src/BiliLite.UWP/Pages/Home/LivePage.xaml | 49 ++-- src/BiliLite.UWP/Pages/Home/LivePage.xaml.cs | 42 +-- .../ViewModels/Home/HotViewModel.cs | 149 +++++++++++ .../ViewModels/Home/LiveViewModel.cs | 134 ++++++++++ 22 files changed, 630 insertions(+), 516 deletions(-) create mode 100644 src/BiliLite.UWP/Models/Attributes/RegisterServiceAttributes.cs create mode 100644 src/BiliLite.UWP/Models/Common/Home/HotDataItemModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Home/HotTopItemModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Home/LiveHomeAreaModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Home/LiveHomeBannerModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsItemModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsModuleInfoModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Home/LivePendentItemModel.cs delete mode 100644 src/BiliLite.UWP/Modules/Home/HotVM.cs delete mode 100644 src/BiliLite.UWP/Modules/Home/LiveVM.cs create mode 100644 src/BiliLite.UWP/ViewModels/Home/HotViewModel.cs create mode 100644 src/BiliLite.UWP/ViewModels/Home/LiveViewModel.cs diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index cd3ac582..aae7da93 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -199,6 +199,7 @@ + @@ -272,6 +273,14 @@ + + + + + + + + MarkdownViewerPage.xaml @@ -820,10 +829,10 @@ - + - + diff --git a/src/BiliLite.UWP/Controls/CommentControl.xaml b/src/BiliLite.UWP/Controls/CommentControl.xaml index c6401b6e..403a48fd 100644 --- a/src/BiliLite.UWP/Controls/CommentControl.xaml +++ b/src/BiliLite.UWP/Controls/CommentControl.xaml @@ -49,7 +49,7 @@ - + @@ -59,7 +59,7 @@ - + diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml b/src/BiliLite.UWP/Controls/PlayerControl.xaml index 609d1bf8..a2f3fb7f 100644 --- a/src/BiliLite.UWP/Controls/PlayerControl.xaml +++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml @@ -14,6 +14,7 @@ xmlns:common="using:BiliLite.Models.Common" xmlns:player1="using:BiliLite.Models.Common.Player" xmlns:modules="using:BiliLite.Modules" + xmlns:video="using:BiliLite.Models.Common.Video" d:DesignHeight="800" d:DesignWidth="1000"> @@ -299,7 +300,7 @@ - + @@ -337,7 +338,7 @@ SelectedItem="{Binding Path=Select,Mode=OneWay}" SelectionChanged="NodeList_SelectionChanged" > - + diff --git a/src/BiliLite.UWP/Dialogs/SendCommentDialog.xaml b/src/BiliLite.UWP/Dialogs/SendCommentDialog.xaml index 897b9ef1..b4917c7e 100644 --- a/src/BiliLite.UWP/Dialogs/SendCommentDialog.xaml +++ b/src/BiliLite.UWP/Dialogs/SendCommentDialog.xaml @@ -26,7 +26,7 @@ - + @@ -36,7 +36,7 @@ - + diff --git a/src/BiliLite.UWP/Extensions/ViewModelExtensions.cs b/src/BiliLite.UWP/Extensions/ViewModelExtensions.cs index 9447e40c..b17762ef 100644 --- a/src/BiliLite.UWP/Extensions/ViewModelExtensions.cs +++ b/src/BiliLite.UWP/Extensions/ViewModelExtensions.cs @@ -1,4 +1,6 @@ -using BiliLite.ViewModels; +using System.Linq; +using BiliLite.Models.Attributes; +using BiliLite.ViewModels; using BiliLite.ViewModels.Comment; using BiliLite.ViewModels.Common; using BiliLite.ViewModels.Download; @@ -12,6 +14,7 @@ using BiliLite.ViewModels.UserDynamic; using BiliLite.ViewModels.Video; using Microsoft.Extensions.DependencyInjection; +using System.Reflection; namespace BiliLite.Extensions { @@ -55,7 +58,28 @@ public static IServiceCollection AddViewModels(this IServiceCollection services) services.AddTransient(); services.AddTransient(); services.AddTransient(); + + services.AddAttributeViewModel(); + return services; } + + private static void AddAttributeViewModel(this IServiceCollection services) + { + var types = Assembly.GetExecutingAssembly().GetTypes(); + + foreach (var type in types) + { + if (type.GetCustomAttributes(typeof(RegisterSingletonViewModelAttribute), false).Any()) + { + services.AddSingleton(type); + } + + if (type.GetCustomAttributes(typeof(RegisterTransientViewModelAttribute), false).Any()) + { + services.AddTransient(type); + } + } + } } } diff --git a/src/BiliLite.UWP/Models/Attributes/RegisterServiceAttributes.cs b/src/BiliLite.UWP/Models/Attributes/RegisterServiceAttributes.cs new file mode 100644 index 00000000..be7ebf04 --- /dev/null +++ b/src/BiliLite.UWP/Models/Attributes/RegisterServiceAttributes.cs @@ -0,0 +1,28 @@ +using System; + +namespace BiliLite.Models.Attributes +{ + [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] + public class RegisterSingletonServiceAttribute : Attribute + { + + } + + [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] + public class RegisterTransientServiceAttribute : Attribute + { + + } + + [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] + public class RegisterSingletonViewModelAttribute : Attribute + { + + } + + [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] + public class RegisterTransientViewModelAttribute : Attribute + { + + } +} diff --git a/src/BiliLite.UWP/Models/Common/Home/HotDataItemModel.cs b/src/BiliLite.UWP/Models/Common/Home/HotDataItemModel.cs new file mode 100644 index 00000000..571f3a2b --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/HotDataItemModel.cs @@ -0,0 +1,56 @@ +using BiliLite.Models.Common.Recommend; +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class HotDataItemModel + { + [JsonProperty("card_type")] + public string CardType { get; set; } + + [JsonProperty("card_goto")] + public string CardGoto { get; set; } + + public string Param { get; set; } + + public string Cover { get; set; } + + public string Title { get; set; } + + public string Idx { get; set; } + + public string Uri { get; set; } + + [JsonProperty("cover_right_text_1")] + public string CoverRightText1 { get; set; } + + [JsonProperty("right_desc_1")] + public string RightDesc1 { get; set; } + + [JsonProperty("right_desc_2")] + public string RightDesc2 { get; set; } + + [JsonProperty("cover_left_text_1")] + public string CoverLeftText1 { get; set; } + + [JsonProperty("cover_left_text_2")] + public string CoverLeftText2 { get; set; } + + [JsonProperty("cover_left_text_3")] + public string CoverLeftText3 { get; set; } + + public string TextInfo1 => string.IsNullOrEmpty(CoverRightText1) ? CoverLeftText1 : CoverRightText1; + + public string TextInfo2 => string.IsNullOrEmpty(RightDesc1) ? CoverLeftText2 : RightDesc1; + + public string TextInfo3 => string.IsNullOrEmpty(RightDesc2) ? CoverLeftText3 : RightDesc2; + + [JsonProperty("rcmd_reason_style")] + public RecommendRcmdReasonStyleModel RcmdReasonStyle { get; set; } + + [JsonProperty("top_rcmd_reason_style")] + public RecommendRcmdReasonStyleModel TopRcmdReasonStyle { get; set; } + + public RecommendRcmdReasonStyleModel RcmdReason => RcmdReasonStyle ?? TopRcmdReasonStyle; + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/HotTopItemModel.cs b/src/BiliLite.UWP/Models/Common/Home/HotTopItemModel.cs new file mode 100644 index 00000000..7cc8a7d1 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/HotTopItemModel.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class HotTopItemModel + { + [JsonProperty("entrance_id")] + public int EntranceId { get; set; } + + public string Icon { get; set; } + + [JsonProperty("module_id")] + public string ModuleId { get; set; } + + public string Uri { get; set; } + + public string Title { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/LiveHomeAreaModel.cs b/src/BiliLite.UWP/Models/Common/Home/LiveHomeAreaModel.cs new file mode 100644 index 00000000..67ae5e5c --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/LiveHomeAreaModel.cs @@ -0,0 +1,24 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class LiveHomeAreaModel + { + public int Id { get; set; } + + [JsonProperty("area_v2_id")] + public int AreaV2Id { get; set; } + + [JsonProperty("area_v2_parent_id")] + public int AreaV2ParentId { get; set; } + + [JsonProperty("tag_type")] + public int TagType { get; set; } + + public string Title { get; set; } + + public string Pic { get; set; } + + public string Link { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/LiveHomeBannerModel.cs b/src/BiliLite.UWP/Models/Common/Home/LiveHomeBannerModel.cs new file mode 100644 index 00000000..b3fdde90 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/LiveHomeBannerModel.cs @@ -0,0 +1,13 @@ +namespace BiliLite.Models.Common.Home +{ + public class LiveHomeBannerModel + { + public int Id { get; set; } + + public string Link { get; set; } + + public string Pic { get; set; } + + public string Title { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsItemModel.cs b/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsItemModel.cs new file mode 100644 index 00000000..72b84f83 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsItemModel.cs @@ -0,0 +1,42 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace BiliLite.Models.Common.Home +{ + public class LiveHomeItemsItemModel + { + [JsonProperty("area_v2_id")] + public int AreaV2Id { get; set; } + + [JsonProperty("area_v2_parent_id")] + public int AreaV2ParentId { get; set; } + + [JsonProperty("area_v2_name")] + public string AreaV2Name { get; set; } + + [JsonProperty("area_v2_parent_name")] + public string AreaV2ParentName { get; set; } + + public string Title { get; set; } + + public string Cover { get; set; } + + public int Online { get; set; } + + public string Roomid { get; set; } + + public string Uname { get; set; } + + public string Face { get; set; } + + public string Uid { get; set; } + + [JsonProperty("pendant_Info")] + public JObject PendantInfo { get; set; } + + public LivePendentItemModel Pendent => + PendantInfo.ContainsKey("2") ? JsonConvert.DeserializeObject(PendantInfo["2"].ToString()) : null; + + public bool ShowPendent => Pendent != null; + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsModel.cs b/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsModel.cs new file mode 100644 index 00000000..5f9676ee --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsModel.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class LiveHomeItemsModel + { + [JsonProperty("module_info")] + public LiveHomeItemsModuleInfoModel ModuleInfo { get; set; } + + public List List { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsModuleInfoModel.cs b/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsModuleInfoModel.cs new file mode 100644 index 00000000..83af3aa8 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsModuleInfoModel.cs @@ -0,0 +1,17 @@ +namespace BiliLite.Models.Common.Home +{ + public class LiveHomeItemsModuleInfoModel + { + public int Id { get; set; } + + public string Link { get; set; } + + public string Pic { get; set; } + + public string Title { get; set; } + + public int Type { get; set; } + + public int Sort { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/LivePendentItemModel.cs b/src/BiliLite.UWP/Models/Common/Home/LivePendentItemModel.cs new file mode 100644 index 00000000..c22c8e94 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/LivePendentItemModel.cs @@ -0,0 +1,20 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class LivePendentItemModel + { + [JsonProperty("bg_pic")] + public string BgPic { get; set; } + + [JsonProperty("bg_color")] + public string BgColor { get; set; } + + public string Text { get; set; } + + public string Name { get; set; } + + [JsonProperty("type")] + public string Type { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Modules/Home/HotVM.cs b/src/BiliLite.UWP/Modules/Home/HotVM.cs deleted file mode 100644 index ebe34bc0..00000000 --- a/src/BiliLite.UWP/Modules/Home/HotVM.cs +++ /dev/null @@ -1,200 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Collections.ObjectModel; -using Newtonsoft.Json; -using System.Windows.Input; -using BiliLite.Extensions; -using BiliLite.Models.Common.Recommend; -using BiliLite.Models.Requests.Api.Home; -using BiliLite.Pages; -using Microsoft.Extensions.DependencyInjection; - -namespace BiliLite.Modules -{ - public class HotVM : IModules - { - readonly HotAPI hotAPI; - private readonly IMainPage m_mainPage; - - public HotVM() - { - m_mainPage = App.ServiceProvider.GetRequiredService(); - hotAPI = new HotAPI(); - RefreshCommand = new RelayCommand(Refresh); - LoadMoreCommand = new RelayCommand(LoadMore); - } - public ICommand RefreshCommand { get; private set; } - public ICommand LoadMoreCommand { get; private set; } - - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - - private ObservableCollection _hotItems; - - public ObservableCollection HotItems - { - get { return _hotItems; } - set { _hotItems = value; DoPropertyChanged("HotItems"); } - } - private List _topItems; - - public List TopItems - { - get { return _topItems; } - set { _topItems = value; DoPropertyChanged("TopItems"); } - } - - public async Task GetPopular(string idx = "0", string last_param = "") - { - try - { - Loading = true; - - var results = await hotAPI.Popular(idx, last_param).Request(); - if (results.status) - { - var data = results.GetJObject(); - if (data["code"].ToInt32() == 0) - { - if (TopItems == null) - { - TopItems = JsonConvert.DeserializeObject>(data["config"]["top_items"].ToString()); - } - var items = JsonConvert.DeserializeObject>(data["data"].ToString()); - for (int i = items.Count - 1; i >= 0; i--) - { - if (items[i].CardGoto != "av") - items.Remove(items[i]); - } - if (HotItems == null) - { - HotItems = items; - } - else - { - foreach (var item in items) - { - HotItems.Add(item); - } - } - } - else - { - Notify.ShowMessageToast(data["message"].ToString()); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - public async void Refresh() - { - if (Loading) - { - return; - } - TopItems = null; - HotItems = null; - await GetPopular(); - } - public async void LoadMore() - { - // 当前不在首页,不应继续加载 - if (!(m_mainPage.CurrentPage is HomePage)) return; - if (Loading) - { - return; - } - if (HotItems == null || HotItems.Count == 0) - { - return; - } - var last = HotItems.LastOrDefault(); - await GetPopular(last.Idx, last.Param); - } - } - public class HotTopItemModel - { - [JsonProperty("entrance_id")] - public int EntranceId { get; set; } - - public string Icon { get; set; } - - [JsonProperty("module_id")] - public string ModuleId { get; set; } - - public string Uri { get; set; } - - public string Title { get; set; } - } - - public class HotDataItemModel - { - [JsonProperty("card_type")] - public string CardType { get; set; } - - [JsonProperty("card_goto")] - public string CardGoto { get; set; } - - public string Param { get; set; } - - public string Cover { get; set; } - - public string Title { get; set; } - - public string Idx { get; set; } - - public string Uri { get; set; } - - [JsonProperty("cover_right_text_1")] - public string CoverRightText1 { get; set; } - - [JsonProperty("right_desc_1")] - public string RightDesc1 { get; set; } - - [JsonProperty("right_desc_2")] - public string RightDesc2 { get; set; } - - [JsonProperty("cover_left_text_1")] - public string CoverLeftText1 { get; set; } - - [JsonProperty("cover_left_text_2")] - public string CoverLeftText2 { get; set; } - - [JsonProperty("cover_left_text_3")] - public string CoverLeftText3 { get; set; } - - public string TextInfo1 => string.IsNullOrEmpty(CoverRightText1) ? CoverLeftText1 : CoverRightText1; - - public string TextInfo2 => string.IsNullOrEmpty(RightDesc1) ? CoverLeftText2 : RightDesc1; - - public string TextInfo3 => string.IsNullOrEmpty(RightDesc2) ? CoverLeftText3 : RightDesc2; - - [JsonProperty("rcmd_reason_style")] - public RecommendRcmdReasonStyleModel RcmdReasonStyle { get; set; } - - [JsonProperty("top_rcmd_reason_style")] - public RecommendRcmdReasonStyleModel TopRcmdReasonStyle { get; set; } - - public RecommendRcmdReasonStyleModel RcmdReason => RcmdReasonStyle ?? TopRcmdReasonStyle; - } -} diff --git a/src/BiliLite.UWP/Modules/Home/LiveVM.cs b/src/BiliLite.UWP/Modules/Home/LiveVM.cs deleted file mode 100644 index 011a3e19..00000000 --- a/src/BiliLite.UWP/Modules/Home/LiveVM.cs +++ /dev/null @@ -1,242 +0,0 @@ -using BiliLite.Models; -using BiliLite.Models.Requests.Api.Home; -using BiliLite.Modules.Live.LiveCenter; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Windows.ApplicationModel.Appointments; -using Windows.UI.Xaml.Media.Imaging; -using BiliLite.Extensions; - -namespace BiliLite.Modules -{ - public class LiveVM : IModules - { - readonly LiveAPI liveAPI; - public readonly LiveAttentionVM liveAttentionVM; - public LiveVM() - { - liveAPI = new LiveAPI(); - liveAttentionVM = new LiveAttentionVM(); - } - private bool _showFollows = false; - public bool ShowFollows - { - get { return _showFollows; } - set { _showFollows = value; DoPropertyChanged("ShowFollows"); } - } - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - private bool _loadingFollow = true; - public bool LoadingFollow - { - get { return _loadingFollow; } - set { _loadingFollow = value; DoPropertyChanged("LoadingFollow"); } - } - - private ObservableCollection _banners; - - public ObservableCollection Banners - { - get { return _banners; } - set { _banners = value; DoPropertyChanged("Banners"); } - } - - private ObservableCollection _areas; - - public ObservableCollection Areas - { - get { return _areas; } - set { _areas = value; DoPropertyChanged("Areas"); } - } - - //private ObservableCollection _Follow; - - //public ObservableCollection Follow - //{ - // get { return _Follow; } - // set { _Follow = value; DoPropertyChanged("Follow"); } - //} - - private List _items; - public List Items - { - get { return _items; } - set { _items = value; DoPropertyChanged("Items"); } - } - - public async Task GetLiveHome() - { - try - { - Loading = true; - var api = liveAPI.LiveHome(); - - var results = await api.Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - if (data.data["banner"].Any()) - { - Banners = await data.data["banner"][0]["list"].ToString().DeserializeJson>(); - } - - if (data.data["area_entrance_v2"].Any()) - { - Areas = await data.data["area_entrance_v2"][0]["list"].ToString().DeserializeJson>(); - } - await GetLiveHomeItems(); - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - public async Task GetLiveHomeItems() - { - try - { - Loading = true; - var api = liveAPI.LiveHomeItems(); - var results = await api.Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - var items = await data.data["room_list"].ToString().DeserializeJson>(); - - Items = items.Where(x => x.list != null && x.list.Count > 0).ToList(); - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - - - } - public class LiveHomeItemsModel - { - public LiveHomeItemsModuleInfoModel module_info { get; set; } - public List list { get; set; } - } - public class LiveHomeItemsModuleInfoModel - { - public int id { get; set; } - public string link { get; set; } - public string pic { get; set; } - public string title { get; set; } - public int type { get; set; } - public int sort { get; set; } - } - public class LiveHomeItemsItemModel - { - public int area_v2_id { get; set; } - public int area_v2_parent_id { get; set; } - public string area_v2_name { get; set; } - public string area_v2_parent_name { get; set; } - public string title { get; set; } - public string cover { get; set; } - - public int online { get; set; } - public string roomid { get; set; } - public string uname { get; set; } - public string face { get; set; } - public string uid { get; set; } - - public JObject pendant_Info { get; set; } - public LivePendentItemModel pendent - { - get - { - if (pendant_Info.ContainsKey("2")) - { - return JsonConvert.DeserializeObject(pendant_Info["2"].ToString()); - } - else - { - return null; - } - } - } - public bool show_pendent - { - get - { - return pendent != null; - } - } - } - public class LiveHomeBannerModel - { - public int id { get; set; } - public string link { get; set; } - public string pic { get; set; } - public string title { get; set; } - } - public class LiveHomeAreaModel - { - public int id { get; set; } - public int area_v2_id { get; set; } - public int area_v2_parent_id { get; set; } - public int tag_type { get; set; } - public string title { get; set; } - public string pic { get; set; } - public string link { get; set; } - } - - public class LivePendentItemModel - { - public string bg_pic { get; set; } - public string bg_color { get; set; } - public string text { get; set; } - public string name { get; set; } - public string @type { get; set; } - } - -} diff --git a/src/BiliLite.UWP/Pages/Home/HotPage.xaml b/src/BiliLite.UWP/Pages/Home/HotPage.xaml index 12ce322b..5c0069a3 100644 --- a/src/BiliLite.UWP/Pages/Home/HotPage.xaml +++ b/src/BiliLite.UWP/Pages/Home/HotPage.xaml @@ -10,8 +10,9 @@ xmlns:controls="using:BiliLite.Controls" xmlns:covert="using:BiliLite.Converters" xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls" - xmlns:winui="using:Microsoft.UI.Xaml.Controls" - Background="Transparent"> + xmlns:winui="using:Microsoft.UI.Xaml.Controls" + xmlns:home="using:BiliLite.Models.Common.Home" + Background="Transparent"> @@ -23,12 +24,12 @@ OneRowModeEnabled="False" Padding="8" StretchContentForSingleRow="False" - ItemsSource="{x:Bind Path=hotVM.HotItems,Mode=OneWay}" + ItemsSource="{x:Bind Path=m_viewModel.HotItems,Mode=OneWay}" ItemHeight="100" DesiredWidth="560" LoadMoreBottomOffset="0" - LoadMoreCommand="{x:Bind Path=hotVM.LoadMoreCommand}" + LoadMoreCommand="{x:Bind Path=m_viewModel.LoadMoreCommand}" CanLoadMore="True" - Loading="{x:Bind Path=hotVM.Loading,Mode=OneWay}" + Loading="{x:Bind Path=m_viewModel.Loading,Mode=OneWay}" SelectionMode="None" IsItemClickEnabled="True"> - + 关注的直播 @@ -66,7 +67,7 @@ MoveOffset="600" AlwayShowButton="False" ItemClick="FollowLive_ItemClick" - ItemsSource="{x:Bind Path=liveVM.liveAttentionVM.Follow,Mode=OneWay}" + ItemsSource="{x:Bind Path=m_viewModel.LiveAttentionVm.Follow,Mode=OneWay}" SelectionMode="None" Margin="-4 0 0 0" ScrollViewer.HorizontalScrollMode="Enabled" @@ -127,17 +128,17 @@ - + - + - + 查看更多 @@ -146,7 +147,7 @@ MoveOffset="600" AlwayShowButton="False" ItemClick="LiveItems_ItemClick" - ItemsSource="{x:Bind Path=list,Mode=OneWay}" + ItemsSource="{x:Bind Path=List,Mode=OneWay}" SelectionMode="None" Margin="-4 0 0 0" ScrollViewer.HorizontalScrollMode="Enabled" @@ -168,7 +169,7 @@ - + @@ -177,7 +178,7 @@ - + @@ -186,22 +187,22 @@ - + - + - - - + + + - - + + @@ -217,7 +218,7 @@ - + diff --git a/src/BiliLite.UWP/Pages/Home/LivePage.xaml.cs b/src/BiliLite.UWP/Pages/Home/LivePage.xaml.cs index 1cbc0d20..423a9750 100644 --- a/src/BiliLite.UWP/Pages/Home/LivePage.xaml.cs +++ b/src/BiliLite.UWP/Pages/Home/LivePage.xaml.cs @@ -1,6 +1,5 @@ using BiliLite.Extensions; using BiliLite.Models.Common; -using BiliLite.Modules; using BiliLite.Modules.Live.LiveCenter; using BiliLite.Pages.Live; using BiliLite.Services; @@ -10,6 +9,9 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; +using BiliLite.Models.Common.Home; +using BiliLite.ViewModels.Home; +using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -20,11 +22,11 @@ namespace BiliLite.Pages.Home /// public sealed partial class LivePage : Page,IRefreshablePage { - private Modules.LiveVM liveVM; + private LiveViewModel m_viewModel; public LivePage() { this.InitializeComponent(); - liveVM = new Modules.LiveVM(); + m_viewModel = App.ServiceProvider.GetRequiredService(); if (SettingService.GetValue(SettingConstants.UI.CACHE_HOME, true)) { this.NavigationCacheMode = NavigationCacheMode.Enabled; @@ -35,21 +37,21 @@ public LivePage() } } - protected async override void OnNavigatedTo(NavigationEventArgs e) + protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); - if (e.NavigationMode == NavigationMode.New && liveVM.Banners == null) + if (e.NavigationMode == NavigationMode.New && m_viewModel.Banners == null) { await LoadData(); } } private async Task LoadData() { - await liveVM.GetLiveHome(); + await m_viewModel.GetLiveHome(); if (SettingService.Account.Logined) { - liveVM.ShowFollows = true; - await liveVM.liveAttentionVM.GetFollows(); + m_viewModel.ShowFollows = true; + await m_viewModel.LiveAttentionVm.GetFollows(); } } @@ -65,7 +67,7 @@ private async void btnRefresh_Click(object sender, RoutedEventArgs e) private async void BannerItem_Click(object sender, RoutedEventArgs e) { - var result = await MessageCenter.HandelUrl(((sender as HyperlinkButton).DataContext as LiveHomeBannerModel).link); + var result = await MessageCenter.HandelUrl(((sender as HyperlinkButton).DataContext as LiveHomeBannerModel).Link); if (!result) { Notify.ShowMessageToast("不支持打开的链接"); @@ -96,15 +98,15 @@ private void LiveItems_ItemClick(object sender, ItemClickEventArgs e) { icon = Symbol.Video, page = typeof(LiveDetailPage), - title = data.uname + "的直播间", - parameters = data.roomid + title = data.Uname + "的直播间", + parameters = data.Roomid }); } private void loadMore_Click(object sender, RoutedEventArgs e) { var data = (sender as HyperlinkButton).DataContext as LiveHomeItemsModel; - if (data.module_info.title == "推荐直播") + if (data.ModuleInfo.Title == "推荐直播") { MessageCenter.NavigateToPage(this, new NavigationInfo() { @@ -113,18 +115,18 @@ private void loadMore_Click(object sender, RoutedEventArgs e) title = "全部直播" }); } - if (!string.IsNullOrEmpty(data.module_info.link)) + if (!string.IsNullOrEmpty(data.ModuleInfo.Link)) { try { - var match = Regex.Match(data.module_info.link, @"parentAreaId=(\d+)&areaId=(\d+)"); + var match = Regex.Match(data.ModuleInfo.Link, @"parentAreaId=(\d+)&areaId=(\d+)"); if (match.Groups.Count == 3) { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.Document, page = typeof(LiveAreaDetailPage), - title = data.module_info.title, + title = data.ModuleInfo.Title, parameters = new LiveAreaPar() { parent_id = match.Groups[1].Value.ToInt32(), @@ -146,13 +148,13 @@ private void loadMore_Click(object sender, RoutedEventArgs e) private void GridView_ItemClick(object sender, ItemClickEventArgs e) { var area = e.ClickedItem as LiveHomeAreaModel; - if (area.id == 0) + if (area.Id == 0) { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.Document, page = typeof(LiveAreaPage), - title = area.title + title = area.Title }); return; } @@ -160,11 +162,11 @@ private void GridView_ItemClick(object sender, ItemClickEventArgs e) { icon = Symbol.Document, page = typeof(LiveAreaDetailPage), - title = area.title, + title = area.Title, parameters = new LiveAreaPar() { - parent_id = area.area_v2_parent_id, - area_id = area.area_v2_id + parent_id = area.AreaV2ParentId, + area_id = area.AreaV2Id } }); } diff --git a/src/BiliLite.UWP/ViewModels/Home/HotViewModel.cs b/src/BiliLite.UWP/ViewModels/Home/HotViewModel.cs new file mode 100644 index 00000000..89f8fe74 --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Home/HotViewModel.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Input; +using BiliLite.Extensions; +using BiliLite.Models.Attributes; +using BiliLite.Models.Common.Home; +using BiliLite.Models.Exceptions; +using BiliLite.Models.Requests.Api.Home; +using BiliLite.Modules; +using BiliLite.Pages; +using BiliLite.Services; +using BiliLite.ViewModels.Common; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace BiliLite.ViewModels.Home +{ + [RegisterTransientViewModel] + public class HotViewModel : BaseViewModel + { + #region Fields + + private readonly HotAPI m_hotApi; + private readonly IMainPage m_mainPage; + private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); + + #endregion + + #region Constructors + + public HotViewModel(IMainPage mainPage) + { + m_mainPage = mainPage; + m_hotApi = new HotAPI(); + RefreshCommand = new RelayCommand(Refresh); + LoadMoreCommand = new RelayCommand(LoadMore); + } + + #endregion + + #region Properties + + public bool Loading { get; set; } = true; + + public ObservableCollection HotItems { get; set; } + + public List TopItems { get; set; } + + public ICommand RefreshCommand { get; private set; } + + public ICommand LoadMoreCommand { get; private set; } + + #endregion + + #region Private Methods + + private void GetPopularCore(JObject data) + { + TopItems ??= JsonConvert.DeserializeObject>(data["config"]["top_items"] + .ToString()); + + var items = + JsonConvert.DeserializeObject>(data["data"] + .ToString()); + for (var i = items.Count - 1; i >= 0; i--) + { + if (items[i].CardGoto != "av") + items.Remove(items[i]); + } + + if (HotItems == null) + { + HotItems = items; + } + else + { + foreach (var item in items) + { + HotItems.Add(item); + } + } + } + + #endregion + + #region Public Methods + + public async Task GetPopular(string idx = "0", string lastParam = "") + { + try + { + Loading = true; + + var results = await m_hotApi.Popular(idx, lastParam).Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = results.GetJObject(); + if (data["code"].ToInt32() != 0) throw new CustomizedErrorException(data["message"].ToString()); + GetPopularCore(data); + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error("获取热门数据失败", ex); + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + finally + { + Loading = false; + } + } + + public async void Refresh() + { + if (Loading) + { + return; + } + TopItems = null; + HotItems = null; + await GetPopular(); + } + + public async void LoadMore() + { + // 当前不在首页,不应继续加载 + if (!(m_mainPage.CurrentPage is HomePage)) return; + if (Loading) + { + return; + } + if (HotItems == null || HotItems.Count == 0) + { + return; + } + var last = HotItems.LastOrDefault(); + await GetPopular(last.Idx, last.Param); + } + + #endregion + + } +} diff --git a/src/BiliLite.UWP/ViewModels/Home/LiveViewModel.cs b/src/BiliLite.UWP/ViewModels/Home/LiveViewModel.cs new file mode 100644 index 00000000..5f5b5523 --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Home/LiveViewModel.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using BiliLite.Extensions; +using BiliLite.Models; +using BiliLite.Models.Attributes; +using BiliLite.Models.Common.Home; +using BiliLite.Models.Exceptions; +using BiliLite.Models.Requests.Api.Home; +using BiliLite.Modules.Live.LiveCenter; +using BiliLite.Services; +using BiliLite.ViewModels.Common; +using Newtonsoft.Json.Linq; + +namespace BiliLite.ViewModels.Home +{ + [RegisterTransientViewModel] + public class LiveViewModel : BaseViewModel + { + #region Fields + + private readonly LiveAPI m_liveApi; + private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); + + #endregion + + #region Constructors + + public LiveViewModel() + { + m_liveApi = new LiveAPI(); + LiveAttentionVm = new LiveAttentionVM(); + } + + #endregion + + #region Properties + + public LiveAttentionVM LiveAttentionVm { get; private set; } + + public bool ShowFollows { get; set; } + + public bool Loading { get; set; } + + public bool LoadingFollow { get; set; } = true; + + public ObservableCollection Banners { get; set; } + + public ObservableCollection Areas { get; set; } + + //public ObservableCollection Follow { get; set; } + + public List Items { get; set; } + + #endregion + + #region Public Methods + + public async Task GetLiveHome() + { + try + { + Loading = true; + var api = m_liveApi.LiveHome(); + + var results = await api.Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = await results.GetJson>(); + if (!data.success) throw new CustomizedErrorException(data.message); + if (data.data["banner"].Any()) + { + Banners = await data.data["banner"][0]["list"].ToString() + .DeserializeJson>(); + } + + if (data.data["area_entrance_v2"].Any()) + { + Areas = await data.data["area_entrance_v2"][0]["list"].ToString() + .DeserializeJson>(); + } + + await GetLiveHomeItems(); + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + finally + { + Loading = false; + } + } + + public async Task GetLiveHomeItems() + { + try + { + Loading = true; + var api = m_liveApi.LiveHomeItems(); + var results = await api.Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = await results.GetJson>(); + if (!data.success) throw new CustomizedErrorException(data.message); + var items = await data.data["room_list"].ToString().DeserializeJson>(); + + Items = items.Where(x => x.List != null && x.List.Count > 0).ToList(); + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + finally + { + Loading = false; + } + } + + #endregion + } +} From 118ffb5f8754aef510ab96ebc85746f533c6ffc2 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Tue, 3 Dec 2024 22:12:08 +0800 Subject: [PATCH 08/17] =?UTF-8?q?=E6=95=B4=E7=90=86=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=94=BE=E6=98=A0=E5=8E=85=E5=92=8C=E5=88=86=E5=8C=BA=E9=A1=B5?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/BiliLite.UWP.csproj | 23 +- .../Dialogs/SendDynamicDialog.xaml | 4 +- .../Dialogs/SendDynamicV2Dialog.xaml | 4 +- .../Extensions/MapperExtensions.cs | 3 +- .../Common/Home/CinemaHomeBannerModel.cs | 11 + .../Common/Home/CinemaHomeFallItemModel.cs | 17 + .../Models/Common/Home/CinemaHomeFallModel.cs | 15 + .../Models/Common/Home/CinemaHomeHotItem.cs | 37 ++ .../Models/Common/Home/CinemaHomeModel.cs | 33 ++ .../Models/Common/Home/CinemaHomeStatModel.cs | 16 + .../Models/Common/Home/RegionChildrenItem.cs | 22 + .../Models/Common/Home/RegionItem.cs | 28 ++ .../Common/Region/RegionChildOrderModel.cs | 15 + .../Region/RegionHomeBannerItemModel.cs | 13 + .../Common/Region/RegionTagItemModel.cs | 17 + .../Common/Region/RegionVideoItemModel.cs | 25 + src/BiliLite.UWP/Modules/Home/RegionVM.cs | 78 --- src/BiliLite.UWP/Modules/RegionDetailVM.cs | 447 ------------------ src/BiliLite.UWP/Pages/Home/MoviePage.xaml | 56 +-- src/BiliLite.UWP/Pages/Home/MoviePage.xaml.cs | 30 +- src/BiliLite.UWP/Pages/Home/RegionsPage.xaml | 12 +- .../Pages/Home/RegionsPage.xaml.cs | 58 +-- src/BiliLite.UWP/Pages/RegionDetailPage.xaml | 35 +- .../Pages/RegionDetailPage.xaml.cs | 37 +- src/BiliLite.UWP/Services/AppHelper.cs | 15 +- .../Home/CinemaHomeFallViewModel.cs | 21 + .../ViewModels/Home/CinemaHomeViewModel.cs | 34 ++ .../Home/CinemaViewModel.cs} | 282 ++++------- .../ViewModels/Home/RegionViewModel.cs | 66 +++ .../ViewModels/Region/IRegionViewModel.cs | 17 + .../Region/RegionDetailChildViewModel.cs | 257 ++++++++++ .../Region/RegionDetailHomeViewModel.cs | 149 ++++++ .../Region/RegionDetailViewModel.cs | 41 ++ .../ViewModels/Search/SearchVideoViewModel.cs | 4 +- 34 files changed, 1066 insertions(+), 856 deletions(-) create mode 100644 src/BiliLite.UWP/Models/Common/Home/CinemaHomeBannerModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Home/CinemaHomeFallItemModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Home/CinemaHomeFallModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Home/CinemaHomeHotItem.cs create mode 100644 src/BiliLite.UWP/Models/Common/Home/CinemaHomeModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Home/CinemaHomeStatModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Home/RegionChildrenItem.cs create mode 100644 src/BiliLite.UWP/Models/Common/Home/RegionItem.cs create mode 100644 src/BiliLite.UWP/Models/Common/Region/RegionChildOrderModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Region/RegionHomeBannerItemModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Region/RegionTagItemModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Region/RegionVideoItemModel.cs delete mode 100644 src/BiliLite.UWP/Modules/Home/RegionVM.cs delete mode 100644 src/BiliLite.UWP/Modules/RegionDetailVM.cs create mode 100644 src/BiliLite.UWP/ViewModels/Home/CinemaHomeFallViewModel.cs create mode 100644 src/BiliLite.UWP/ViewModels/Home/CinemaHomeViewModel.cs rename src/BiliLite.UWP/{Modules/Home/CinemaVM.cs => ViewModels/Home/CinemaViewModel.cs} (51%) create mode 100644 src/BiliLite.UWP/ViewModels/Home/RegionViewModel.cs create mode 100644 src/BiliLite.UWP/ViewModels/Region/IRegionViewModel.cs create mode 100644 src/BiliLite.UWP/ViewModels/Region/RegionDetailChildViewModel.cs create mode 100644 src/BiliLite.UWP/ViewModels/Region/RegionDetailHomeViewModel.cs create mode 100644 src/BiliLite.UWP/ViewModels/Region/RegionDetailViewModel.cs diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index 1a86e3c6..13c5a859 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -281,6 +281,23 @@ + + + + + + + + + + + + + + + + + MarkdownViewerPage.xaml @@ -805,7 +822,7 @@ - + @@ -819,14 +836,14 @@ - + - + diff --git a/src/BiliLite.UWP/Dialogs/SendDynamicDialog.xaml b/src/BiliLite.UWP/Dialogs/SendDynamicDialog.xaml index afb35b13..6d5146b3 100644 --- a/src/BiliLite.UWP/Dialogs/SendDynamicDialog.xaml +++ b/src/BiliLite.UWP/Dialogs/SendDynamicDialog.xaml @@ -18,7 +18,7 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/src/BiliLite.UWP/Dialogs/SendDynamicV2Dialog.xaml b/src/BiliLite.UWP/Dialogs/SendDynamicV2Dialog.xaml index ab138b78..b167e30f 100644 --- a/src/BiliLite.UWP/Dialogs/SendDynamicV2Dialog.xaml +++ b/src/BiliLite.UWP/Dialogs/SendDynamicV2Dialog.xaml @@ -18,7 +18,7 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/src/BiliLite.UWP/Extensions/MapperExtensions.cs b/src/BiliLite.UWP/Extensions/MapperExtensions.cs index 8c7df82f..c1bf1344 100644 --- a/src/BiliLite.UWP/Extensions/MapperExtensions.cs +++ b/src/BiliLite.UWP/Extensions/MapperExtensions.cs @@ -15,7 +15,6 @@ using BiliLite.Models.Common.Season; using BiliLite.Models.Common.Settings; using BiliLite.Models.Common.User; -using BiliLite.Models.Common.User.UserDetails; using BiliLite.Models.Common.UserDynamic; using BiliLite.Models.Common.Video; using BiliLite.Models.Common.Video.Detail; @@ -77,6 +76,8 @@ public static IServiceCollection AddMapper(this IServiceCollection services) expression.CreateMap(); expression.CreateMap(); expression.CreateMap(); + expression.CreateMap(); + expression.CreateMap(); expression.CreateMap() .ForMember(dest => dest.Author, opt => opt.MapFrom(src => diff --git a/src/BiliLite.UWP/Models/Common/Home/CinemaHomeBannerModel.cs b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeBannerModel.cs new file mode 100644 index 00000000..08693151 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeBannerModel.cs @@ -0,0 +1,11 @@ +namespace BiliLite.Models.Common.Home +{ + public class CinemaHomeBannerModel + { + public string Title { get; set; } + + public string Img { get; set; } + + public string Url { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/CinemaHomeFallItemModel.cs b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeFallItemModel.cs new file mode 100644 index 00000000..2fefc331 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeFallItemModel.cs @@ -0,0 +1,17 @@ +namespace BiliLite.Models.Common.Home +{ + public class CinemaHomeFallItemModel + { + public string Cover { get; set; } + + public string Desc { get; set; } + + public string Title { get; set; } + + public string Link { get; set; } + + public long Cursor { get; set; } + + public int Wid { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/CinemaHomeFallModel.cs b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeFallModel.cs new file mode 100644 index 00000000..f4121687 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeFallModel.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace BiliLite.Models.Common.Home +{ + public class CinemaHomeFallModel + { + public int Wid { get; set; } + + public string Title { get; set; } + + public bool ShowMore { get; set; } = true; + + public List Items { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/CinemaHomeHotItem.cs b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeHotItem.cs new file mode 100644 index 00000000..53ce4a3a --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeHotItem.cs @@ -0,0 +1,37 @@ +using BiliLite.Models.Common.Anime; +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class CinemaHomeHotItem : ISeasonItem + { + public string Hat { get; set; } + + public string Cover { get; set; } + + public string Badge { get; set; } + + [JsonProperty("badge_type")] + public int BadgeType { get; set; } + + public bool ShowBadge => !string.IsNullOrEmpty(Badge); + + public string Desc { get; set; } + + public string Title { get; set; } + + public string Link { get; set; } + + [JsonProperty("season_id")] + public int SeasonId { get; set; } + + [JsonProperty("season_type")] + public int SeasonType { get; set; } + + public string Type { get; set; } + + public int Wid { get; set; } + + public CinemaHomeStatModel Stat { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/CinemaHomeModel.cs b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeModel.cs new file mode 100644 index 00000000..c53e9132 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeModel.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; + +namespace BiliLite.Models.Common.Home +{ + public class CinemaHomeModel + { + public List Banners { get; set; } + + public List Falls { get; set; } + + public List Update { get; set; } + + /// + /// 记录片 87 + /// + public List Documentary { get; set; } + + /// + /// 电影 88 + /// + public List Movie { get; set; } + + /// + /// 电视剧 89 + /// + public List Tv { get; set; } + + /// + /// 综艺 173 + /// + public List Variety { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/CinemaHomeStatModel.cs b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeStatModel.cs new file mode 100644 index 00000000..921b4b8f --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeStatModel.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class CinemaHomeStatModel + { + public long View { get; set; } + + [JsonProperty("follow_view")] + public string FollowView { get; set; } + + public long Follow { get; set; } + + public long Danmaku { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/RegionChildrenItem.cs b/src/BiliLite.UWP/Models/Common/Home/RegionChildrenItem.cs new file mode 100644 index 00000000..05384f2d --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/RegionChildrenItem.cs @@ -0,0 +1,22 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class RegionChildrenItem + { + public int Tid { get; set; } + + public int Reid { get; set; } + + public string Name { get; set; } + + public string Logo { get; set; } + + public int Type { get; set; } + + [JsonProperty("_goto")] + public string Goto { get; set; } + + public string Param { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/RegionItem.cs b/src/BiliLite.UWP/Models/Common/Home/RegionItem.cs new file mode 100644 index 00000000..f315274b --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/RegionItem.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class RegionItem + { + public int Tid { get; set; } + + public int Reid { get; set; } + + public string Name { get; set; } + + public string Logo { get; set; } + + public string Uri { get; set; } + + public int Type { get; set; } + + [JsonProperty("is_bangumi")] + public int IsBangumi { get; set; } + + [JsonProperty("_goto")] + public string Goto { get; set; } + + public List Children { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Region/RegionChildOrderModel.cs b/src/BiliLite.UWP/Models/Common/Region/RegionChildOrderModel.cs new file mode 100644 index 00000000..3fb80164 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Region/RegionChildOrderModel.cs @@ -0,0 +1,15 @@ +namespace BiliLite.Models.Common.Region +{ + public class RegionChildOrderModel + { + public RegionChildOrderModel(string name, string order) + { + this.Name = name; + this.Order = order; + } + + public string Name { get; set; } + + public string Order { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Region/RegionHomeBannerItemModel.cs b/src/BiliLite.UWP/Models/Common/Region/RegionHomeBannerItemModel.cs new file mode 100644 index 00000000..0605777d --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Region/RegionHomeBannerItemModel.cs @@ -0,0 +1,13 @@ +namespace BiliLite.Models.Common.Region +{ + public class RegionHomeBannerItemModel + { + public int Id { get; set; } + + public string Title { get; set; } + + public string Image { get; set; } + + public string Uri { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Region/RegionTagItemModel.cs b/src/BiliLite.UWP/Models/Common/Region/RegionTagItemModel.cs new file mode 100644 index 00000000..0e1e5b25 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Region/RegionTagItemModel.cs @@ -0,0 +1,17 @@ +namespace BiliLite.Models.Common.Region +{ + public class RegionTagItemModel + { + public int Tid { get; set; } + + public int Rid { get; set; } + + public int Reid { get; set; } + + public string Tname { get; set; } + + public string Rname { get; set; } + + public string Rename { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Region/RegionVideoItemModel.cs b/src/BiliLite.UWP/Models/Common/Region/RegionVideoItemModel.cs new file mode 100644 index 00000000..5779e88b --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Region/RegionVideoItemModel.cs @@ -0,0 +1,25 @@ +namespace BiliLite.Models.Common.Region +{ + public class RegionVideoItemModel + { + public int Id { get; set; } + + public string Title { get; set; } + + public string Cover { get; set; } + + public string Param { get; set; } + + public string Name { get; set; } + + public int Play { get; set; } + + public int Danmaku { get; set; } + + public string Rname { get; set; } + + public int Duration { get; set; } + + public int Rid { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Modules/Home/RegionVM.cs b/src/BiliLite.UWP/Modules/Home/RegionVM.cs deleted file mode 100644 index 0fa5a5b6..00000000 --- a/src/BiliLite.UWP/Modules/Home/RegionVM.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using BiliLite.Models.Requests.Api; -using BiliLite.Services; -using BiliLite.Extensions; - -namespace BiliLite.Modules.Home -{ - public class RegionVM : IModules - { - readonly RegionAPI regionAPI; - public RegionVM() - { - regionAPI = new RegionAPI(); - } - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - private List _Regions; - public List Regions - { - get { return _Regions; } - set { _Regions = value; DoPropertyChanged("Regions"); } - } - public async Task GetRegions() - { - try - { - Loading = true; - if (AppHelper.Regions == null || AppHelper.Regions.Count == 0) - { - await AppHelper.SetRegions(); - } - Regions = AppHelper.Regions; - } - catch (Exception ex) - { - Regions = await AppHelper.GetDefaultRegions(); - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - - } - - public class RegionItem - { - public int tid { get; set; } - public int reid { get; set; } - public string name { get; set; } - public string logo { get; set; } - public string uri { get; set; } - public int type { get; set; } - public int is_bangumi { get; set; } - public string _goto { get; set; } - public List children { get; set; } - } - public class RegionChildrenItem - { - public int tid { get; set; } - public int reid { get; set; } - public string name { get; set; } - public string logo { get; set; } - public int type { get; set; } - - public string _goto { get; set; } - public string param { get; set; } - } -} diff --git a/src/BiliLite.UWP/Modules/RegionDetailVM.cs b/src/BiliLite.UWP/Modules/RegionDetailVM.cs deleted file mode 100644 index a67bfd95..00000000 --- a/src/BiliLite.UWP/Modules/RegionDetailVM.cs +++ /dev/null @@ -1,447 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Collections.ObjectModel; -using BiliLite.Modules.Home; -using System.Windows.Input; -using BiliLite.Extensions; -using BiliLite.Models; -using Newtonsoft.Json; -using BiliLite.Models.Requests.Api; -using BiliLite.Services; -using BiliLite.ViewModels.Rank; - -namespace BiliLite.Modules -{ - public class RegionDetailVM : IModules - { - public RegionDetailVM() - { - - } - private ObservableCollection _Regions; - public ObservableCollection Regions - { - get { return _Regions; } - set { _Regions = value; DoPropertyChanged("Regions"); } - } - private IRegionVM _SelectRegion; - public IRegionVM SelectRegion - { - get { return _SelectRegion; } - set { _SelectRegion = value; DoPropertyChanged("SelectRegion"); } - } - - public void InitRegion(int id, int tid) - { - var ls = new ObservableCollection(); - var region = AppHelper.Regions.FirstOrDefault(x => x.tid == id); - ls.Add(new RegionDetailHomeVM(region)); - Regions = ls; - foreach (var item in region.children) - { - ls.Add(new RegionDetailChildVM(item)); - } - if (tid == 0) - { - SelectRegion = Regions[0]; - } - else - { - SelectRegion = Regions.FirstOrDefault(x => x.ID == tid); - } - } - - } - public interface IRegionVM - { - ICommand RefreshCommand { get; set; } - ICommand LoadMoreCommand { get; set; } - int ID { get; set; } - string RegionName { get; set; } - bool Loading { get; set; } - } - public class RegionDetailHomeVM : IModules, IRegionVM - { - public int ID { get; set; } - public string RegionName { get; set; } = "推荐"; - - public ICommand RefreshCommand { get; set; } - public ICommand LoadMoreCommand { get; set; } - private bool _loading = false; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - - private List _Banners; - - public List Banners - { - get { return _Banners; } - set { _Banners = value; DoPropertyChanged("Banners"); } - } - - private ObservableCollection _regionVideos; - - public ObservableCollection Videos - { - get { return _regionVideos; } - set { _regionVideos = value; DoPropertyChanged("Videos"); } - } - - - private RegionItem _region; - RegionAPI regionAPI; - public RegionDetailHomeVM(RegionItem regionItem) - { - regionAPI = new RegionAPI(); - _region = regionItem; - ID = regionItem.tid; - //RegionName = regionItem.name; - RefreshCommand = new RelayCommand(Refresh); - LoadMoreCommand = new RelayCommand(LoadMore); - } - private string next_id = ""; - public async Task LoadHome() - { - try - { - Loading = true; - var api = regionAPI.RegionDynamic(ID); - if (next_id != "") - { - api = regionAPI.RegionDynamic(ID, next_id); - } - var results = await api.Request(); - - if (results.status) - { - var data = results.GetJObject(); - if (data["code"].ToInt32() == 0) - { - var ls = JsonConvert.DeserializeObject>(data["data"]["new"].ToString()); - if (next_id == "") - { - var recommend = JsonConvert.DeserializeObject>(data["data"]["recommend"]?.ToString() ?? "[]"); - foreach (var item in recommend) - { - ls.Insert(0, item); - } - Banners = JsonConvert.DeserializeObject>(data["data"]["banner"]["top"].ToString()); - Videos = ls; - } - else - { - foreach (var item in ls) - { - Videos.Add(item); - } - } - - next_id = data["data"]["cbottom"].ToString(); - } - else - { - Notify.ShowMessageToast(data["message"].ToString()); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError>>(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - public async void Refresh() - { - next_id = ""; - await LoadHome(); - } - public async void LoadMore() - { - await LoadHome(); - } - } - public class RegionDetailChildVM : IModules, IRegionVM - { - public string RegionName { get; set; } - public int ID { get; set; } - private bool _loading = false; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - public ICommand RefreshCommand { get; set; } - public ICommand LoadMoreCommand { get; set; } - private RegionChildrenItem _region; - RegionAPI regionAPI; - public RegionDetailChildVM(RegionChildrenItem regionItem) - { - regionAPI = new RegionAPI(); - Orders = new List() { - //new RegionChildOrderModel("默认排序",""), - new RegionChildOrderModel("最新视频","senddate"), - new RegionChildOrderModel("最多播放","view"), - new RegionChildOrderModel("评论最多","reply"), - new RegionChildOrderModel("弹幕最多","danmaku"), - new RegionChildOrderModel("最多收藏","favorite") - }; - SelectOrder = Orders[0]; - _region = regionItem; - ID = regionItem.tid; - RegionName = regionItem.name; - RefreshCommand = new RelayCommand(Refresh); - LoadMoreCommand = new RelayCommand(LoadMore); - } - public List Orders { get; set; } - - private RegionChildOrderModel _SelectOrder; - - public RegionChildOrderModel SelectOrder - { - get { return _SelectOrder; } - set - { - if (value != null) - { - _SelectOrder = value; - } - } - } - - private RegionTagItemModel _SelectTag; - - public RegionTagItemModel SelectTag - { - get { return _SelectTag; } - set - { - if (value != null) - { - _SelectTag = value; - } - - } - } - - - private List _tag; - public List Tasgs - { - get { return _tag; } - set { _tag = value; DoPropertyChanged("Tasgs"); } - } - - private ObservableCollection _regionVideos; - public ObservableCollection Videos - { - get { return _regionVideos; } - set { _regionVideos = value; DoPropertyChanged("Videos"); } - } - public string next_id = ""; - - public async Task LoadHome() - { - try - { - Loading = true; - var api = regionAPI.RegionChildDynamic(ID, (SelectTag == null) ? 0 : SelectTag.tid); - if (next_id != "") - { - api = regionAPI.RegionChildDynamic(ID, next_id, (SelectTag == null) ? 0 : SelectTag.tid); - } - - var results = await api.Request(); - if (results.status) - { - var data = results.GetJObject(); - if (data["code"].ToInt32() == 0) - { - var ls = JsonConvert.DeserializeObject>(data["data"]["new"].ToString()); - if (next_id == "") - { - var tags = JsonConvert.DeserializeObject>(data["data"]["top_tag"]?.ToString() ?? "[]"); - tags.Insert(0, new RegionTagItemModel() - { - tid = 0, - tname = "全部标签" - }); - if (Tasgs == null || Tasgs.Count == 0) - { - Tasgs = tags; - SelectTag = Tasgs[0]; - } - - Videos = ls; - } - else - { - foreach (var item in ls) - { - Videos.Add(item); - } - } - next_id = data["data"]["cbottom"]?.ToString() ?? ""; - } - else - { - Notify.ShowMessageToast(data["message"].ToString()); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError>>(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - public int page = 1; - public async Task LoadList() - { - try - { - Loading = true; - var api = regionAPI.RegionChildList(ID, SelectOrder.order, page, SelectTag.tid); - var results = await api.Request(); - if (results.status) - { - var data = results.GetJObject(); - if (data["code"].ToInt32() == 0) - { - var ls = JsonConvert.DeserializeObject>(data["data"].ToString()); - if (page == 1) - { - Videos = ls; - } - else - { - foreach (var item in ls) - { - Videos.Add(item); - } - } - page++; - } - else - { - Notify.ShowMessageToast(data["message"].ToString()); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError>>(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - public async void Refresh() - { - if (Loading) - { - return; - } - if (SelectOrder == null || SelectOrder.order == "") - { - next_id = ""; - await LoadHome(); - } - else - { - page = 1; - await LoadList(); - } - - } - public async void LoadMore() - { - if (Loading) - { - return; - } - if (SelectOrder == null || SelectOrder.order == "") - { - await LoadHome(); - } - else - { - await LoadList(); - } - } - - } - - - public class RegionHomeBannerItemModel - { - public int id { get; set; } - public string title { get; set; } - public string image { get; set; } - public string uri { get; set; } - } - public class RegionChildOrderModel - { - public RegionChildOrderModel(string name, string order) - { - this.name = name; - this.order = order; - } - public string name { get; set; } - public string order { get; set; } - } - public class RegionTagItemModel - { - public int tid { get; set; } - public int rid { get; set; } - public int reid { get; set; } - public string tname { get; set; } - public string rname { get; set; } - public string rename { get; set; } - } - public class RegionVideoItemModel - { - public int id { get; set; } - public string title { get; set; } - public string cover { get; set; } - public string param { get; set; } - public string name { get; set; } - public int play { get; set; } - public int danmaku { get; set; } - public string rname { get; set; } - public int duration { get; set; } - - public int Rid { get; set; } - } -} diff --git a/src/BiliLite.UWP/Pages/Home/MoviePage.xaml b/src/BiliLite.UWP/Pages/Home/MoviePage.xaml index cfd90810..1c20fc2c 100644 --- a/src/BiliLite.UWP/Pages/Home/MoviePage.xaml +++ b/src/BiliLite.UWP/Pages/Home/MoviePage.xaml @@ -12,9 +12,11 @@ xmlns:winui="using:Microsoft.UI.Xaml.Controls" xmlns:fa="using:FontAwesome5" xmlns:models="using:BiliLite.Models" + xmlns:home="using:BiliLite.ViewModels.Home" + xmlns:homeModel="using:BiliLite.Models.Common.Home" Background="Transparent"> - + @@ -32,7 +34,7 @@ - + @@ -44,7 +46,7 @@ - + @@ -62,7 +64,7 @@ - + @@ -84,19 +86,19 @@ - + - + - + - + @@ -112,7 +114,7 @@ - + 我的追剧 @@ -122,8 +124,8 @@ - + @@ -218,7 +220,7 @@ - + @@ -247,7 +249,7 @@ + MoveOffset="600" AlwayShowButton="False" SelectionMode="None" ItemClick="{x:Bind Path=m_viewModel.SeasonItemClick}" ItemsSource="{x:Bind Path=m_viewModel.HomeData.Documentary,Mode=OneWay}" ScrollViewer.VerticalScrollMode="Disabled" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollMode="Disabled" ItemTemplate="{StaticResource HotAnimeItem}" IsItemClickEnabled="True"> - + - - + + @@ -29,6 +29,6 @@ - + diff --git a/src/BiliLite.UWP/Pages/Home/RegionsPage.xaml.cs b/src/BiliLite.UWP/Pages/Home/RegionsPage.xaml.cs index 8c200728..23b96da0 100644 --- a/src/BiliLite.UWP/Pages/Home/RegionsPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/Home/RegionsPage.xaml.cs @@ -1,21 +1,10 @@ using BiliLite.Models.Common; -using BiliLite.Modules; -using BiliLite.Modules.Home; using BiliLite.Services; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; +using BiliLite.Models.Common.Home; +using BiliLite.ViewModels.Home; +using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -26,11 +15,12 @@ namespace BiliLite.Pages.Home /// public sealed partial class RegionsPage : Page { - RegionVM channelVM; + private readonly RegionViewModel m_viewModel; + public RegionsPage() { + m_viewModel = App.ServiceProvider.GetRequiredService(); this.InitializeComponent(); - channelVM = new RegionVM(); if (SettingService.GetValue(SettingConstants.UI.CACHE_HOME, true)) { this.NavigationCacheMode = NavigationCacheMode.Enabled; @@ -41,12 +31,12 @@ public RegionsPage() } } - protected async override void OnNavigatedTo(NavigationEventArgs e) + protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); - if (e.NavigationMode == NavigationMode.New && channelVM.Regions == null) + if (e.NavigationMode == NavigationMode.New && m_viewModel.Regions == null) { - await channelVM.GetRegions(); + await m_viewModel.GetRegions(); } } @@ -54,74 +44,74 @@ protected async override void OnNavigatedTo(NavigationEventArgs e) private void GridView_ItemClick(object sender, ItemClickEventArgs e) { var item = e.ClickedItem as RegionItem; - if (item.uri.Contains("http")) + if (item.Uri.Contains("http")) { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.World, page = typeof(WebPage), - title = item.name, - parameters = item.uri + title = item.Name, + parameters = item.Uri }); return; } - if (item.children != null) + if (item.Children != null) { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.Document, page = typeof(Pages.RegionDetailPage), - title = item.name, + title = item.Name, parameters = new OpenRegionInfo() { - id = item.tid + id = item.Tid } }); return; } - if (item.name == "番剧") + if (item.Name == "番剧") { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.Home, page = typeof(Pages.Home.AnimePage), - title = item.name, + title = item.Name, parameters = AnimeType.Bangumi }); return; } - if (item.name == "国创") + if (item.Name == "国创") { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.Home, page = typeof(Pages.Home.AnimePage), - title = item.name, + title = item.Name, parameters = AnimeType.Bangumi }); return; } - if (item.name == "放映厅") + if (item.Name == "放映厅") { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.Home, page = typeof(Pages.Home.MoviePage), - title = item.name + title = item.Name }); return; } - if (item.name == "直播") + if (item.Name == "直播") { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.Home, page = typeof(Pages.Home.LivePage), - title = item.name + title = item.Name }); return; } - if (item.name == "全区排行榜") + if (item.Name == "全区排行榜") { MessageCenter.NavigateToPage(this, new NavigationInfo() { diff --git a/src/BiliLite.UWP/Pages/RegionDetailPage.xaml b/src/BiliLite.UWP/Pages/RegionDetailPage.xaml index 90dcc1e2..688f3086 100644 --- a/src/BiliLite.UWP/Pages/RegionDetailPage.xaml +++ b/src/BiliLite.UWP/Pages/RegionDetailPage.xaml @@ -8,16 +8,17 @@ mc:Ignorable="d" xmlns:controls="using:BiliLite.Controls" xmlns:convert="using:BiliLite.Converters" - xmlns:modules="using:BiliLite.Modules" xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls" xmlns:winui="using:Microsoft.UI.Xaml.Controls" - xmlns:fa="using:FontAwesome5" + xmlns:fa="using:FontAwesome5" + xmlns:region="using:BiliLite.ViewModels.Region" + xmlns:model="using:BiliLite.Models.Common.Region" Background="Transparent"> - + - + - + @@ -62,7 +63,7 @@ - + @@ -75,13 +76,13 @@ - + - - 播放: 弹幕: - · + + 播放: 弹幕: + · @@ -102,7 +103,7 @@ - + - + @@ -135,13 +136,13 @@ - + - - 播放: 弹幕: - · + + 播放: 弹幕: + · @@ -166,7 +167,7 @@ - + diff --git a/src/BiliLite.UWP/Pages/RegionDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/RegionDetailPage.xaml.cs index e963f6c7..f9ebc288 100644 --- a/src/BiliLite.UWP/Pages/RegionDetailPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/RegionDetailPage.xaml.cs @@ -1,11 +1,12 @@ using BiliLite.Models.Common; -using BiliLite.Modules; using BiliLite.Pages.Bangumi; using BiliLite.Services; using System.Threading.Tasks; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; +using BiliLite.Models.Common.Region; +using BiliLite.ViewModels.Region; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -16,18 +17,18 @@ namespace BiliLite.Pages /// public sealed partial class RegionDetailPage : BasePage, IRefreshablePage { - RegionDetailVM regionDetailVM; + RegionDetailViewModel m_viewModel; OpenRegionInfo regionInfo; public RegionDetailPage() { this.InitializeComponent(); Title = "分区详情"; - regionDetailVM = new RegionDetailVM(); + m_viewModel = new RegionDetailViewModel(); } protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); - if (e.NavigationMode == NavigationMode.New||regionDetailVM.Regions==null) + if (e.NavigationMode == NavigationMode.New||m_viewModel.Regions==null) { if (e.Parameter!=null) { @@ -37,7 +38,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) { regionInfo = new OpenRegionInfo(); } - regionDetailVM.InitRegion(regionInfo.id, regionInfo.tid); + m_viewModel.InitRegion(regionInfo.id, regionInfo.tid); } } @@ -47,10 +48,10 @@ private async void pivot_SelectionChanged(object sender, SelectionChangedEventAr { return; } - if(pivot.SelectedItem is RegionDetailHomeVM) + if(pivot.SelectedItem is RegionDetailHomeViewModel) { GridOrder.Visibility = Visibility.Collapsed; - var data = pivot.SelectedItem as RegionDetailHomeVM; + var data = pivot.SelectedItem as RegionDetailHomeViewModel; if (!data.Loading&&data.Banners==null) { await data.LoadHome(); @@ -58,7 +59,7 @@ private async void pivot_SelectionChanged(object sender, SelectionChangedEventAr } else { - var data = pivot.SelectedItem as RegionDetailChildVM; + var data = pivot.SelectedItem as RegionDetailChildViewModel; if (!data.Loading && data.Tasgs == null) { await data.LoadHome(); @@ -110,7 +111,7 @@ private void cbTags_SelectionChanged(object sender, SelectionChangedEventArgs e { return; } - (pivot.SelectedItem as RegionDetailChildVM).Refresh(); + (pivot.SelectedItem as RegionDetailChildViewModel).Refresh(); } @@ -120,7 +121,7 @@ private void cbOrder_SelectionChanged(object sender, SelectionChangedEventArgs e { return; } - (pivot.SelectedItem as RegionDetailChildVM).Refresh(); + (pivot.SelectedItem as RegionDetailChildViewModel).Refresh(); } private void AdaptiveGridView_ItemClick(object sender, ItemClickEventArgs e) @@ -134,8 +135,8 @@ private void AdaptiveGridView_ItemClick(object sender, ItemClickEventArgs e) { icon = Symbol.Play, page = typeof(SeasonDetailPage), - parameters = data.param, - title = data.title + parameters = data.Param, + title = data.Title }); return; } @@ -143,21 +144,21 @@ private void AdaptiveGridView_ItemClick(object sender, ItemClickEventArgs e) MessageCenter.NavigateToPage(this,new NavigationInfo() { icon= Symbol.Play, page=typeof(VideoDetailPage), - parameters=data.param, - title=data.title + parameters=data.Param, + title=data.Title }); } private async void BtnOpenBanner_Click(object sender, RoutedEventArgs e) { - await MessageCenter.HandelUrl(((sender as HyperlinkButton).DataContext as RegionHomeBannerItemModel).uri); + await MessageCenter.HandelUrl(((sender as HyperlinkButton).DataContext as RegionHomeBannerItemModel).Uri); } private void AddToWatchLater_Click(object sender, RoutedEventArgs e) { var data = (sender as MenuFlyoutItem).DataContext as RegionVideoItemModel; - Modules.User.WatchLaterVM.Instance.AddToWatchlater(data.param); + Modules.User.WatchLaterVM.Instance.AddToWatchlater(data.Param); } public async Task Refresh() @@ -166,7 +167,7 @@ public async Task Refresh() { return; } - (pivot.SelectedItem as RegionDetailChildVM).Refresh(); + (pivot.SelectedItem as RegionDetailChildViewModel).Refresh(); } } public class RegionDataTemplateSelector : DataTemplateSelector @@ -177,7 +178,7 @@ public class RegionDataTemplateSelector : DataTemplateSelector protected override DataTemplate SelectTemplateCore(object item, DependencyObject container) { - if (item is RegionDetailHomeVM) + if (item is RegionDetailHomeViewModel) { return HomeTemplate; } diff --git a/src/BiliLite.UWP/Services/AppHelper.cs b/src/BiliLite.UWP/Services/AppHelper.cs index 300bdaea..034b62ac 100644 --- a/src/BiliLite.UWP/Services/AppHelper.cs +++ b/src/BiliLite.UWP/Services/AppHelper.cs @@ -7,6 +7,7 @@ using Windows.Storage; using BiliLite.Extensions; using BiliLite.Models.Common; +using BiliLite.Models.Common.Home; namespace BiliLite.Services { @@ -14,21 +15,21 @@ public static class AppHelper { private static readonly ILogger logger = GlobalLogger.FromCurrentType(); - public static List Regions { get; set; } + public static List Regions { get; set; } private static RegionAPI regionAPI = new RegionAPI(); - public static async Task> GetDefaultRegions() + public static async Task> GetDefaultRegions() { try { var str = await FileIO.ReadTextAsync( await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Text/regions.json"))); - return JsonConvert.DeserializeObject>(str); + return JsonConvert.DeserializeObject>(str); } catch (Exception ex) { logger.Log("读取默认分区失败!" + ex.Message, LogType.Error, ex); - return new List(); + return new List(); } } @@ -42,11 +43,11 @@ public static async Task SetRegions() var data = results.GetJObject(); if (data["code"].ToInt32() == 0) { - var ls = JsonConvert.DeserializeObject>(data["data"].ToString() + var ls = JsonConvert.DeserializeObject>(data["data"].ToString() .Replace("goto", "_goto")); foreach (var item in ls.Where(x => - string.IsNullOrEmpty(x.uri) || x.name == "会员购" || x.name == "漫画" || - x.name == "游戏中心" || x.name == "话题中心" || x.name == "音频" || x.name == "原创排行榜") + string.IsNullOrEmpty(x.Uri) || x.Name == "会员购" || x.Name == "漫画" || + x.Name == "游戏中心" || x.Name == "话题中心" || x.Name == "音频" || x.Name == "原创排行榜") .ToList()) { ls.Remove(item); diff --git a/src/BiliLite.UWP/ViewModels/Home/CinemaHomeFallViewModel.cs b/src/BiliLite.UWP/ViewModels/Home/CinemaHomeFallViewModel.cs new file mode 100644 index 00000000..08ed688c --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Home/CinemaHomeFallViewModel.cs @@ -0,0 +1,21 @@ +using System.Collections.ObjectModel; +using BiliLite.Models.Common.Home; +using BiliLite.ViewModels.Common; +using PropertyChanged; + +namespace BiliLite.ViewModels.Home +{ + public class CinemaHomeFallViewModel : BaseViewModel + { + [DoNotNotify] + public int Wid { get; set; } + + [DoNotNotify] + public string Title { get; set; } + + public bool ShowMore { get; set; } = true; + + [DoNotNotify] + public ObservableCollection Items { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/ViewModels/Home/CinemaHomeViewModel.cs b/src/BiliLite.UWP/ViewModels/Home/CinemaHomeViewModel.cs new file mode 100644 index 00000000..5a4dd288 --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Home/CinemaHomeViewModel.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using BiliLite.Models.Common.Home; + +namespace BiliLite.ViewModels.Home +{ + public class CinemaHomeViewModel + { + public List Banners { get; set; } + + public List Falls { get; set; } + + public List Update { get; set; } + + /// + /// 记录片 87 + /// + public List Documentary { get; set; } + + /// + /// 电影 88 + /// + public List Movie { get; set; } + + /// + /// 电视剧 89 + /// + public List Tv { get; set; } + + /// + /// 综艺 173 + /// + public List Variety { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Modules/Home/CinemaVM.cs b/src/BiliLite.UWP/ViewModels/Home/CinemaViewModel.cs similarity index 51% rename from src/BiliLite.UWP/Modules/Home/CinemaVM.cs rename to src/BiliLite.UWP/ViewModels/Home/CinemaViewModel.cs index 87c80217..e0997250 100644 --- a/src/BiliLite.UWP/Modules/Home/CinemaVM.cs +++ b/src/BiliLite.UWP/ViewModels/Home/CinemaViewModel.cs @@ -1,31 +1,47 @@ -using BiliLite.Models; -using BiliLite.Models.Requests.Api.Home; -using BiliLite.Models.Requests.Api.User; -using BiliLite.Pages.Bangumi; -using BiliLite.Pages.User; -using Newtonsoft.Json.Linq; -using System; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; using Windows.UI.Xaml.Controls; +using AutoMapper; using BiliLite.Extensions; -using BiliLite.Services; +using BiliLite.Models; +using BiliLite.Models.Attributes; using BiliLite.Models.Common; using BiliLite.Models.Common.Anime; -using Newtonsoft.Json; +using BiliLite.Models.Common.Home; +using BiliLite.Models.Exceptions; +using BiliLite.Models.Requests.Api.Home; +using BiliLite.Models.Requests.Api.User; +using BiliLite.Modules; +using BiliLite.Pages.Bangumi; +using BiliLite.Pages.User; +using BiliLite.Services; +using BiliLite.ViewModels.Common; +using Newtonsoft.Json.Linq; -namespace BiliLite.Modules +namespace BiliLite.ViewModels.Home { - public class CinemaVM : IModules + [RegisterTransientViewModel] + public class CinemaViewModel : BaseViewModel { - readonly FollowAPI followAPI; - readonly CinemaAPI cinemaAPI; - public CinemaVM() + #region Fields + + private readonly FollowAPI m_followApi; + private readonly CinemaAPI m_cinemaApi; + private readonly IMapper m_mapper; + private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); + + #endregion + + #region Constructors + + public CinemaViewModel(IMapper mapper) { - cinemaAPI = new CinemaAPI(); - followAPI = new FollowAPI(); + m_mapper = mapper; + m_cinemaApi = new CinemaAPI(); + m_followApi = new FollowAPI(); Entrances = new List() { new PageEntranceModel(){ Logo="ms-appx:///Assets/Icon/榜单.png", @@ -102,43 +118,26 @@ public CinemaVM() }; } + #endregion + #region Properties - private bool _showFollows = false; - public bool ShowFollows - { - get { return _showFollows; } - set { _showFollows = value; DoPropertyChanged("ShowFollows"); } - } + public bool ShowFollows { get; set; } - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - private bool _loadingFollow = true; - public bool LoadingFollow - { - get { return _loadingFollow; } - set { _loadingFollow = value; DoPropertyChanged("LoadingFollow"); } - } - private ObservableCollection _follows; + public bool Loading { get; set; } = true; - public ObservableCollection Follows - { - get { return _follows; } - set { _follows = value; DoPropertyChanged("Follows"); } - } + public bool LoadingFollow { get; set; } = true; - private CinemaHomeModel _homeData; - public CinemaHomeModel HomeData - { - get { return _homeData; } - set { _homeData = value; DoPropertyChanged("HomeData"); } - } + public ObservableCollection Follows { get; set; } + + public CinemaHomeViewModel HomeData { get; set; } public List Entrances { get; set; } + + #endregion + + #region Public Methods + public async void SeasonItemClick(object sender, ItemClickEventArgs e) { var seasonId = e.ClickedItem.GetType().GetProperty(nameof(ISeasonItem.SeasonId)).GetValue(e.ClickedItem, null); @@ -160,6 +159,7 @@ public async void SeasonItemClick(object sender, ItemClickEventArgs e) if (!result) Notify.ShowMessageToast("无法打开此链接"); } } + public void LinkItemClick(object sender, ItemClickEventArgs e) { var weblink = e.ClickedItem.GetType().GetProperty("link").GetValue(e.ClickedItem, null); @@ -178,30 +178,22 @@ public async Task GetCinemaHome() try { Loading = true; - var api = cinemaAPI.CinemaHome(); + var api = m_cinemaApi.CinemaHome(); var results = await api.Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - HomeData = data.data; - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } + if (!results.status) throw new CustomizedErrorException(results.message); + var data = await results.GetJson>(); + if (!data.success) throw new CustomizedErrorException(data.message); + HomeData = m_mapper.Map(data.data); + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); } catch (Exception ex) { - var handel = HandelError(ex); + var handel = HandelError(ex); Notify.ShowMessageToast(handel.message); } finally @@ -215,28 +207,21 @@ public async Task GetFollows() try { LoadingFollow = true; - var results = await followAPI.MyFollowCinema().Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - Follows = await data.result["follow_list"].ToString().DeserializeJson>(); - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } + var results = await m_followApi.MyFollowCinema().Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = await results.GetJson>(); + if (!data.success) throw new CustomizedErrorException(data.message); + Follows = await data.result["follow_list"].ToString() + .DeserializeJson>(); + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); } catch (Exception ex) { - var handel = HandelError(ex); + var handel = HandelError(ex); Notify.ShowMessageToast(handel.message); } finally @@ -245,27 +230,24 @@ public async Task GetFollows() } } - - public async Task GetFallMore(CinemaHomeFallModel AnimeFallModel) + public async Task GetFallMore(CinemaHomeFallViewModel animeFallViewModel) { try { - AnimeFallModel.ShowMore = false; - var results = await cinemaAPI.CinemaFallMore(AnimeFallModel.wid, AnimeFallModel.items.LastOrDefault().cursor).Request(); - if (results.status) - { - var data = await results.GetJson>(); - foreach (var item in data) - { - AnimeFallModel.items.Add(item); - } - - } - else + animeFallViewModel.ShowMore = false; + var results = await m_cinemaApi.CinemaFallMore(animeFallViewModel.Wid, animeFallViewModel.Items.LastOrDefault().Cursor).Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = await results.GetJson>(); + foreach (var item in data) { - Notify.ShowMessageToast(results.message); + animeFallViewModel.Items.Add(item); } } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } catch (Exception ex) { var handel = HandelError>(ex); @@ -273,108 +255,10 @@ public async Task GetFallMore(CinemaHomeFallModel AnimeFallModel) } finally { - AnimeFallModel.ShowMore = true; - } - } - - - } - - - public class CinemaHomeModel - { - public List banners { get; set; } - public List falls { get; set; } - public List update { get; set; } - /// - /// 记录片 87 - /// - public List documentary { get; set; } - /// - /// 电影 88 - /// - public List movie { get; set; } - /// - /// 电视剧 89 - /// - public List tv { get; set; } - /// - /// 综艺 173 - /// - public List variety { get; set; } - } - public class CinemaHomeFallModel : IModules - { - public int wid { get; set; } - public string title { get; set; } - - private bool _showMore = true; - public bool ShowMore - { - get { return _showMore; } - set { _showMore = value; DoPropertyChanged("ShowMore"); DoPropertyChanged("ShowLoading"); } - } - - public ObservableCollection items { get; set; } - } - public class CinemaHomeFallItemModel - { - public string cover { get; set; } - public string desc { get; set; } - public string title { get; set; } - public string link { get; set; } - public long cursor { get; set; } - public int wid { get; set; } - } - public class CinemaHomeBannerModel - { - public string title { get; set; } - public string img { get; set; } - public string url { get; set; } - } - - public class CinemaHomeHotItem : ISeasonItem - { - public string Hat { get; set; } - - public string Cover { get; set; } - - public string Badge { get; set; } - - [JsonProperty("badge_type")] - public int BadgeType { get; set; } - - public bool ShowBadge - { - get - { - return !string.IsNullOrEmpty(Badge); + animeFallViewModel.ShowMore = true; } } - public string Desc { get; set; } - - public string Title { get; set; } - - public string Link { get; set; } - - [JsonProperty("season_id")] - public int SeasonId { get; set; } - - [JsonProperty("season_type")] - public int SeasonType { get; set; } - - public string Type { get; set; } - - public int Wid { get; set; } - - public CinemaHomeStatModel Stat { get; set; } - } - public class CinemaHomeStatModel - { - public long view { get; set; } - public string follow_view { get; set; } - public long follow { get; set; } - public long danmaku { get; set; } + #endregion } } diff --git a/src/BiliLite.UWP/ViewModels/Home/RegionViewModel.cs b/src/BiliLite.UWP/ViewModels/Home/RegionViewModel.cs new file mode 100644 index 00000000..2cf84e6c --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Home/RegionViewModel.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using BiliLite.Extensions; +using BiliLite.Models.Attributes; +using BiliLite.Models.Common.Home; +using BiliLite.Models.Requests.Api; +using BiliLite.Services; +using BiliLite.ViewModels.Common; + +namespace BiliLite.ViewModels.Home +{ + [RegisterTransientViewModel] + public class RegionViewModel : BaseViewModel + { + #region Fields + + private readonly RegionAPI m_regionApi; + + #endregion + + #region Constructors + + public RegionViewModel() + { + m_regionApi = new RegionAPI(); + } + + #endregion + + #region Properties + + public bool Loading { get; set; } = true; + + public List Regions { get; set; } + + #endregion + + #region Public Methods + + public async Task GetRegions() + { + try + { + Loading = true; + if (AppHelper.Regions == null || AppHelper.Regions.Count == 0) + { + await AppHelper.SetRegions(); + } + Regions = AppHelper.Regions; + } + catch (Exception ex) + { + Regions = await AppHelper.GetDefaultRegions(); + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + finally + { + Loading = false; + } + } + + #endregion + } +} diff --git a/src/BiliLite.UWP/ViewModels/Region/IRegionViewModel.cs b/src/BiliLite.UWP/ViewModels/Region/IRegionViewModel.cs new file mode 100644 index 00000000..c634d596 --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Region/IRegionViewModel.cs @@ -0,0 +1,17 @@ +using System.Windows.Input; + +namespace BiliLite.ViewModels.Region +{ + public interface IRegionViewModel + { + ICommand RefreshCommand { get; set; } + + ICommand LoadMoreCommand { get; set; } + + int ID { get; set; } + + string RegionName { get; set; } + + bool Loading { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/ViewModels/Region/RegionDetailChildViewModel.cs b/src/BiliLite.UWP/ViewModels/Region/RegionDetailChildViewModel.cs new file mode 100644 index 00000000..4885142b --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Region/RegionDetailChildViewModel.cs @@ -0,0 +1,257 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Threading.Tasks; +using System.Windows.Input; +using BiliLite.Extensions; +using BiliLite.Models; +using BiliLite.Models.Common.Home; +using BiliLite.Models.Common.Region; +using BiliLite.Models.Requests.Api; +using BiliLite.Modules; +using BiliLite.ViewModels.Common; +using BiliLite.ViewModels.Rank; +using Newtonsoft.Json; +using PropertyChanged; + +namespace BiliLite.ViewModels.Region +{ + public class RegionDetailChildViewModel : BaseViewModel, IRegionViewModel + { + #region Fields + + private RegionChildrenItem m_region; + private readonly RegionAPI m_regionApi; + private RegionChildOrderModel m_selectOrder; + private RegionTagItemModel m_selectTag; + private string m_nextId = ""; + private int m_page = 1; + + #endregion + + #region Constructors + + public RegionDetailChildViewModel(RegionChildrenItem regionItem) + { + m_regionApi = new RegionAPI(); + Orders = new List() { + //new RegionChildOrderModel("默认排序",""), + new RegionChildOrderModel("最新视频","senddate"), + new RegionChildOrderModel("最多播放","view"), + new RegionChildOrderModel("评论最多","reply"), + new RegionChildOrderModel("弹幕最多","danmaku"), + new RegionChildOrderModel("最多收藏","favorite") + }; + SelectOrder = Orders[0]; + m_region = regionItem; + ID = regionItem.Tid; + RegionName = regionItem.Name; + RefreshCommand = new RelayCommand(Refresh); + LoadMoreCommand = new RelayCommand(LoadMore); + } + + #endregion + + #region Properties + + [DoNotNotify] + public ICommand RefreshCommand { get; set; } + + [DoNotNotify] + public ICommand LoadMoreCommand { get; set; } + + [DoNotNotify] + public string RegionName { get; set; } + + [DoNotNotify] + public int ID { get; set; } + + public bool Loading { get; set; } + + public List Orders { get; set; } + + [DoNotNotify] + public RegionChildOrderModel SelectOrder + { + get => m_selectOrder; + set + { + if (value != null) + { + m_selectOrder = value; + } + } + } + + [DoNotNotify] + public RegionTagItemModel SelectTag + { + get => m_selectTag; + set + { + if (value != null) + { + m_selectTag = value; + } + + } + } + + public List Tasgs { get; set; } + + public ObservableCollection Videos { get; set; } + + #endregion + + #region Public Methods + + public async Task LoadHome() + { + try + { + Loading = true; + var api = m_regionApi.RegionChildDynamic(ID, (SelectTag == null) ? 0 : SelectTag.Tid); + if (m_nextId != "") + { + api = m_regionApi.RegionChildDynamic(ID, m_nextId, (SelectTag == null) ? 0 : SelectTag.Tid); + } + + var results = await api.Request(); + if (results.status) + { + var data = results.GetJObject(); + if (data["code"].ToInt32() == 0) + { + var ls = JsonConvert.DeserializeObject>(data["data"]["new"].ToString()); + if (m_nextId == "") + { + var tags = JsonConvert.DeserializeObject>(data["data"]["top_tag"]?.ToString() ?? "[]"); + tags.Insert(0, new RegionTagItemModel() + { + Tid = 0, + Tname = "全部标签" + }); + if (Tasgs == null || Tasgs.Count == 0) + { + Tasgs = tags; + SelectTag = Tasgs[0]; + } + + Videos = ls; + } + else + { + foreach (var item in ls) + { + Videos.Add(item); + } + } + m_nextId = data["data"]["cbottom"]?.ToString() ?? ""; + } + else + { + Notify.ShowMessageToast(data["message"].ToString()); + } + } + else + { + Notify.ShowMessageToast(results.message); + + } + } + catch (Exception ex) + { + var handel = HandelError>>(ex); + Notify.ShowMessageToast(handel.message); + } + finally + { + Loading = false; + } + } + + public async Task LoadList() + { + try + { + Loading = true; + var api = m_regionApi.RegionChildList(ID, SelectOrder.Order, m_page, SelectTag.Tid); + var results = await api.Request(); + if (results.status) + { + var data = results.GetJObject(); + if (data["code"].ToInt32() == 0) + { + var ls = JsonConvert.DeserializeObject>(data["data"].ToString()); + if (m_page == 1) + { + Videos = ls; + } + else + { + foreach (var item in ls) + { + Videos.Add(item); + } + } + m_page++; + } + else + { + Notify.ShowMessageToast(data["message"].ToString()); + } + } + else + { + Notify.ShowMessageToast(results.message); + + } + } + catch (Exception ex) + { + var handel = HandelError>>(ex); + Notify.ShowMessageToast(handel.message); + } + finally + { + Loading = false; + } + } + + public async void Refresh() + { + if (Loading) + { + return; + } + if (SelectOrder == null || SelectOrder.Order == "") + { + m_nextId = ""; + await LoadHome(); + } + else + { + m_page = 1; + await LoadList(); + } + + } + public async void LoadMore() + { + if (Loading) + { + return; + } + if (SelectOrder == null || SelectOrder.Order == "") + { + await LoadHome(); + } + else + { + await LoadList(); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/ViewModels/Region/RegionDetailHomeViewModel.cs b/src/BiliLite.UWP/ViewModels/Region/RegionDetailHomeViewModel.cs new file mode 100644 index 00000000..11646501 --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Region/RegionDetailHomeViewModel.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Threading.Tasks; +using System.Windows.Input; +using BiliLite.Extensions; +using BiliLite.Models; +using BiliLite.Models.Common.Home; +using BiliLite.Models.Common.Region; +using BiliLite.Models.Exceptions; +using BiliLite.Models.Requests.Api; +using BiliLite.Modules; +using BiliLite.Services; +using BiliLite.ViewModels.Common; +using BiliLite.ViewModels.Rank; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PropertyChanged; + +namespace BiliLite.ViewModels.Region +{ + public class RegionDetailHomeViewModel : BaseViewModel, IRegionViewModel + { + #region Fields + + private readonly RegionAPI m_regionApi; + private RegionItem m_region; + private string m_nextId = ""; + private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); + + #endregion + + #region Constructors + + public RegionDetailHomeViewModel(RegionItem regionItem) + { + m_regionApi = new RegionAPI(); + m_region = regionItem; + ID = regionItem.Tid; + //RegionName = regionItem.name; + RefreshCommand = new RelayCommand(Refresh); + LoadMoreCommand = new RelayCommand(LoadMore); + } + + #endregion + + #region Properties + + [DoNotNotify] + public ICommand RefreshCommand { get; set; } + + [DoNotNotify] + public ICommand LoadMoreCommand { get; set; } + + [DoNotNotify] + public int ID { get; set; } + + [DoNotNotify] + public string RegionName { get; set; } = "推荐"; + + public bool Loading { get; set; } + + public List Banners { get; set; } + + public ObservableCollection Videos { get; set; } + + #endregion + + #region Private Methods + + private void LoadHomeCore(JObject data) + { + if (data["code"].ToInt32() != 0) throw new CustomizedErrorException(data["message"].ToString()); + var ls = JsonConvert.DeserializeObject>( + data["data"]["new"].ToString()); + if (m_nextId == "") + { + var recommend = + JsonConvert.DeserializeObject>( + data["data"]["recommend"]?.ToString() ?? "[]"); + foreach (var item in recommend) + { + ls.Insert(0, item); + } + + Banners = JsonConvert.DeserializeObject>( + data["data"]["banner"]["top"].ToString()); + Videos = ls; + } + else + { + foreach (var item in ls) + { + Videos.Add(item); + } + } + + m_nextId = data["data"]["cbottom"].ToString(); + } + + #endregion + + #region Public Methods + + public async Task LoadHome() + { + try + { + Loading = true; + var api = m_regionApi.RegionDynamic(ID); + if (m_nextId != "") + { + api = m_regionApi.RegionDynamic(ID, m_nextId); + } + var results = await api.Request(); + + if (!results.status) throw new CustomizedErrorException(results.message); + var data = results.GetJObject(); + LoadHomeCore(data); + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } + catch (Exception ex) + { + var handel = HandelError>>(ex); + Notify.ShowMessageToast(handel.message); + } + finally + { + Loading = false; + } + } + + public async void Refresh() + { + m_nextId = ""; + await LoadHome(); + } + public async void LoadMore() + { + await LoadHome(); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/ViewModels/Region/RegionDetailViewModel.cs b/src/BiliLite.UWP/ViewModels/Region/RegionDetailViewModel.cs new file mode 100644 index 00000000..3596fb70 --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Region/RegionDetailViewModel.cs @@ -0,0 +1,41 @@ +using System.Collections.ObjectModel; +using System.Linq; +using BiliLite.Models.Attributes; +using BiliLite.Services; +using BiliLite.ViewModels.Common; + +namespace BiliLite.ViewModels.Region +{ + [RegisterTransientViewModel] + public class RegionDetailViewModel : BaseViewModel + { + public RegionDetailViewModel() + { + + } + + public ObservableCollection Regions { get; set; } + + public IRegionViewModel SelectRegion { get; set; } + + public void InitRegion(int id, int tid) + { + var ls = new ObservableCollection(); + var region = AppHelper.Regions.FirstOrDefault(x => x.Tid == id); + ls.Add(new RegionDetailHomeViewModel(region)); + Regions = ls; + foreach (var item in region.Children) + { + ls.Add(new RegionDetailChildViewModel(item)); + } + if (tid == 0) + { + SelectRegion = Regions[0]; + } + else + { + SelectRegion = Regions.FirstOrDefault(x => x.ID == tid); + } + } + } +} diff --git a/src/BiliLite.UWP/ViewModels/Search/SearchVideoViewModel.cs b/src/BiliLite.UWP/ViewModels/Search/SearchVideoViewModel.cs index b7dfda72..a60fb0bb 100644 --- a/src/BiliLite.UWP/ViewModels/Search/SearchVideoViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Search/SearchVideoViewModel.cs @@ -48,9 +48,9 @@ public SearchVideoViewModel() RegionFilters = new List() { new SearchFilterItem("全部分区","0"), }; - foreach (var item in AppHelper.Regions.Where(x => x.children != null && x.children.Count != 0)) + foreach (var item in AppHelper.Regions.Where(x => x.Children != null && x.Children.Count != 0)) { - RegionFilters.Add(new SearchFilterItem(item.name, item.tid.ToString())); + RegionFilters.Add(new SearchFilterItem(item.Name, item.Tid.ToString())); } SelectRegion = RegionFilters[0]; } From e134fb7d3049fc37f493c070523f17584bdb9fba Mon Sep 17 00:00:00 2001 From: ProJend <55018532+ProJend@users.noreply.github.com> Date: Thu, 5 Dec 2024 20:43:00 +0800 Subject: [PATCH 09/17] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E8=87=B3C#=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E7=89=88=E6=9C=AC=20(#931)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.JSBridge/BiliLite.JSBridge.csproj | 1 + src/BiliLite.UWP/BiliLite.UWP.csproj | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/BiliLite.JSBridge/BiliLite.JSBridge.csproj b/src/BiliLite.JSBridge/BiliLite.JSBridge.csproj index f815d6fb..c11e0309 100644 --- a/src/BiliLite.JSBridge/BiliLite.JSBridge.csproj +++ b/src/BiliLite.JSBridge/BiliLite.JSBridge.csproj @@ -2,6 +2,7 @@ + latest Debug AnyCPU {809C7636-0AF1-4695-9230-22F74D7B1327} diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index 13c5a859..cb97f8f9 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -10,7 +10,7 @@ BiliLite BiliLite zh-cn - 8.0 + latest UAP 10.0.19041.0 10.0.18362.0 From fe19152a4b7feee0eef15c5f036674da15a3716f Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Sat, 7 Dec 2024 22:01:59 +0800 Subject: [PATCH 10/17] =?UTF-8?q?#933=20=E6=95=B4=E7=90=86=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=B8=9A=E5=8A=A1=E4=BB=A3=E7=A0=81=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=95=AA=E5=89=A7=E7=82=B9=E8=AF=84=E7=9B=B8=E5=85=B3?= =?UTF-8?q?api=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/BiliLite.UWP.csproj | 37 +- .../Dialogs/CopyOrMoveFavVideoDialog.xaml.cs | 4 +- .../Dialogs/SendReviewDialog.xaml.cs | 12 +- .../Extensions/MapperExtensions.cs | 6 +- .../Common/Anime/AnimeTimelineItemModel.cs | 22 + .../Models/Common/Anime/AnimeTimelineModel.cs | 19 + .../Models/Common/Anime/AnimeTypeItem.cs | 8 + src/BiliLite.UWP/Models/Common/Enumerates.cs | 10 + .../Common/Favorites/FavoriteDetailModel.cs | 11 + .../Common/Favorites/FavoriteInfoModel.cs | 32 ++ .../Favorites/FavoriteInfoVideoItemModel.cs | 17 + .../FavoriteInfoVideoItemStatModel.cs | 16 + .../FavoriteInfoVideoItemUpperModel.cs | 10 + .../Common/Other/FindMoreEntranceModel.cs | 14 + .../SeasonIndexConditionFilterItemModel.cs | 8 + .../Season/SeasonIndexConditionFilterModel.cs | 14 + .../Common/Season/SeasonIndexParameter.cs | 16 + .../Season/SeasonIndexResultItemModel.cs | 41 ++ .../Season/SeasonIndexResultItemOrderModel.cs | 40 ++ .../Common/Season/SeasonRankItemModel.cs | 35 ++ .../Common/Season/SeasonRankItemNewEPModel.cs | 11 + .../Common/Season/SeasonRankItemStatModel.cs | 10 + .../SeasonShortReviewItemAuthorModel.cs | 12 + .../Season/SeasonShortReviewItemModel.cs | 28 ++ .../Season/SeasonShortReviewItemStatModel.cs | 19 + .../Season/SeasonShortReviewItemVIPModel.cs | 8 + .../Models/Requests/Api/SeasonApi.cs | 17 +- .../Modules/Detail/FavoriteDetailVM.cs | 434 ------------------ src/BiliLite.UWP/Modules/Other/FindMoreVM.cs | 66 --- .../Modules/Season/AnimeTimelineVM.cs | 149 ------ .../Modules/Season/SeasonIndexVM.cs | 340 -------------- .../Modules/Season/SeasonRankVM.cs | 153 ------ .../Modules/Season/SeasonReviewVM.cs | 297 ------------ .../Pages/Bangumi/AnimeIndexPage.xaml | 47 +- .../Pages/Bangumi/AnimeIndexPage.xaml.cs | 26 +- .../Pages/Bangumi/SeasonRankPage.xaml | 33 +- .../Pages/Bangumi/SeasonRankPage.xaml.cs | 19 +- .../Pages/Bangumi/TimelinePage.xaml | 20 +- .../Pages/Bangumi/TimelinePage.xaml.cs | 17 +- src/BiliLite.UWP/Pages/Home/AnimePage.xaml.cs | 4 +- src/BiliLite.UWP/Pages/Home/MoviePage.xaml.cs | 10 +- .../Pages/Other/FindMorePage.xaml | 17 +- .../Pages/Other/FindMorePage.xaml.cs | 34 +- src/BiliLite.UWP/Pages/SeasonDetailPage.xaml | 46 +- .../Pages/SeasonDetailPage.xaml.cs | 35 +- .../Pages/User/FavoriteDetailPage.xaml | 54 +-- .../Pages/User/FavoriteDetailPage.xaml.cs | 68 +-- .../Favourites/FavoriteDetailViewModel.cs | 364 +++++++++++++++ .../ViewModels/Home/AnimePageViewModel.cs | 5 +- .../ViewModels/Home/CinemaViewModel.cs | 9 +- .../ViewModels/Other/FindMoreViewModel.cs | 55 +++ .../Season/AnimeTimelineViewModel.cs | 107 +++++ .../Season/SeasonDetailPageViewModel.cs | 2 + .../ViewModels/Season/SeasonIndexViewModel.cs | 244 ++++++++++ .../Season/SeasonRankDataViewModel.cs | 17 + .../ViewModels/Season/SeasonRankViewModel.cs | 116 +++++ .../Season/SeasonReviewViewModel.cs | 239 ++++++++++ .../SeasonShortReviewItemStatViewModel.cs | 21 + .../Season/SeasonShortReviewItemViewModel.cs | 27 ++ 59 files changed, 1877 insertions(+), 1675 deletions(-) create mode 100644 src/BiliLite.UWP/Models/Common/Anime/AnimeTimelineItemModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Anime/AnimeTimelineModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Anime/AnimeTypeItem.cs create mode 100644 src/BiliLite.UWP/Models/Common/Favorites/FavoriteDetailModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemStatModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemUpperModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Other/FindMoreEntranceModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Season/SeasonIndexConditionFilterItemModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Season/SeasonIndexConditionFilterModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Season/SeasonIndexParameter.cs create mode 100644 src/BiliLite.UWP/Models/Common/Season/SeasonIndexResultItemModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Season/SeasonIndexResultItemOrderModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Season/SeasonRankItemModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Season/SeasonRankItemNewEPModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Season/SeasonRankItemStatModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemAuthorModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemStatModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemVIPModel.cs delete mode 100644 src/BiliLite.UWP/Modules/Detail/FavoriteDetailVM.cs delete mode 100644 src/BiliLite.UWP/Modules/Other/FindMoreVM.cs delete mode 100644 src/BiliLite.UWP/Modules/Season/AnimeTimelineVM.cs delete mode 100644 src/BiliLite.UWP/Modules/Season/SeasonIndexVM.cs delete mode 100644 src/BiliLite.UWP/Modules/Season/SeasonRankVM.cs delete mode 100644 src/BiliLite.UWP/Modules/Season/SeasonReviewVM.cs create mode 100644 src/BiliLite.UWP/ViewModels/Favourites/FavoriteDetailViewModel.cs create mode 100644 src/BiliLite.UWP/ViewModels/Other/FindMoreViewModel.cs create mode 100644 src/BiliLite.UWP/ViewModels/Season/AnimeTimelineViewModel.cs create mode 100644 src/BiliLite.UWP/ViewModels/Season/SeasonIndexViewModel.cs create mode 100644 src/BiliLite.UWP/ViewModels/Season/SeasonRankDataViewModel.cs create mode 100644 src/BiliLite.UWP/ViewModels/Season/SeasonRankViewModel.cs create mode 100644 src/BiliLite.UWP/ViewModels/Season/SeasonReviewViewModel.cs create mode 100644 src/BiliLite.UWP/ViewModels/Season/SeasonShortReviewItemStatViewModel.cs create mode 100644 src/BiliLite.UWP/ViewModels/Season/SeasonShortReviewItemViewModel.cs diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index cb97f8f9..755fd1b5 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -286,6 +286,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -820,7 +844,7 @@ - + @@ -831,17 +855,17 @@ - + - - + + - + @@ -861,7 +885,7 @@ - + @@ -1654,6 +1678,7 @@ + diff --git a/src/BiliLite.UWP/Dialogs/CopyOrMoveFavVideoDialog.xaml.cs b/src/BiliLite.UWP/Dialogs/CopyOrMoveFavVideoDialog.xaml.cs index 11142ba1..b5848179 100644 --- a/src/BiliLite.UWP/Dialogs/CopyOrMoveFavVideoDialog.xaml.cs +++ b/src/BiliLite.UWP/Dialogs/CopyOrMoveFavVideoDialog.xaml.cs @@ -1,6 +1,5 @@ using BiliLite.Models; using BiliLite.Models.Requests.Api.User; -using BiliLite.Modules; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; @@ -8,6 +7,7 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using BiliLite.Extensions; +using BiliLite.Models.Common.Favorites; using BiliLite.Models.Responses; using BiliLite.ViewModels.User; @@ -44,7 +44,7 @@ private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, Conten List ids = new List(); foreach (var videoItem in selectItems) { - ids.Add(videoItem.id); + ids.Add(videoItem.Id); } if (isMove) { diff --git a/src/BiliLite.UWP/Dialogs/SendReviewDialog.xaml.cs b/src/BiliLite.UWP/Dialogs/SendReviewDialog.xaml.cs index 198d36fa..7192c3e8 100644 --- a/src/BiliLite.UWP/Dialogs/SendReviewDialog.xaml.cs +++ b/src/BiliLite.UWP/Dialogs/SendReviewDialog.xaml.cs @@ -1,7 +1,8 @@ using BiliLite.Extensions; -using BiliLite.Modules.Season; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; +using BiliLite.ViewModels.Season; +using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“内容对话框”项模板 @@ -9,12 +10,13 @@ namespace BiliLite.Dialogs { public sealed partial class SendReviewDialog : ContentDialog { - SeasonReviewVM seasonReviewVM; + private readonly SeasonReviewViewModel m_viewModel; + public SendReviewDialog(int mediaId) { + m_viewModel = App.ServiceProvider.GetRequiredService(); + m_viewModel.MediaID = mediaId; this.InitializeComponent(); - seasonReviewVM = new SeasonReviewVM(); - seasonReviewVM.MediaID = mediaId; } private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) @@ -25,7 +27,7 @@ private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, Conten return; } int score = (int)rating.Value * 2; - var result = await seasonReviewVM.SendShortReview(txtBoxContent.Text, checkShare.IsChecked.Value, score); + var result = await m_viewModel.SendShortReview(txtBoxContent.Text, checkShare.IsChecked.Value, score); if (result) { this.Hide(); diff --git a/src/BiliLite.UWP/Extensions/MapperExtensions.cs b/src/BiliLite.UWP/Extensions/MapperExtensions.cs index c1bf1344..a5561384 100644 --- a/src/BiliLite.UWP/Extensions/MapperExtensions.cs +++ b/src/BiliLite.UWP/Extensions/MapperExtensions.cs @@ -75,9 +75,11 @@ public static IServiceCollection AddMapper(this IServiceCollection services) expression.CreateMap(); expression.CreateMap(); expression.CreateMap(); - expression.CreateMap(); - expression.CreateMap(); + expression.CreateMap(); + expression.CreateMap(); expression.CreateMap(); + expression.CreateMap(); + expression.CreateMap(); expression.CreateMap() .ForMember(dest => dest.Author, opt => opt.MapFrom(src => diff --git a/src/BiliLite.UWP/Models/Common/Anime/AnimeTimelineItemModel.cs b/src/BiliLite.UWP/Models/Common/Anime/AnimeTimelineItemModel.cs new file mode 100644 index 00000000..5e529b6f --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Anime/AnimeTimelineItemModel.cs @@ -0,0 +1,22 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Anime; + +public class AnimeTimelineItemModel : ISeasonItem +{ + [JsonProperty("season_id")] + public int SeasonId { get; set; } + + public string Cover { get; set; } + + [JsonProperty("square_cover")] + public string SquareCover { get; set; } + + [JsonProperty("pub_index")] + public string PubIndex { get; set; } + + [JsonProperty("pub_time")] + public string PubTime { get; set; } + + public string Title { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Anime/AnimeTimelineModel.cs b/src/BiliLite.UWP/Models/Common/Anime/AnimeTimelineModel.cs new file mode 100644 index 00000000..0a38117c --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Anime/AnimeTimelineModel.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Anime; + +public class AnimeTimelineModel +{ + public string Week { get; set; } + + [JsonProperty("day_week")] + public int DayWeek { get; set; } + + public string Date { get; set; } + + [JsonProperty("is_today")] + public bool IsToday { get; set; } + + public List Seasons { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Anime/AnimeTypeItem.cs b/src/BiliLite.UWP/Models/Common/Anime/AnimeTypeItem.cs new file mode 100644 index 00000000..bac2153a --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Anime/AnimeTypeItem.cs @@ -0,0 +1,8 @@ +namespace BiliLite.Models.Common.Anime; + +public class AnimeTypeItem +{ + public string Name { get; set; } + + public AnimeType AnimeType { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Enumerates.cs b/src/BiliLite.UWP/Models/Common/Enumerates.cs index 3030c7f0..31112504 100644 --- a/src/BiliLite.UWP/Models/Common/Enumerates.cs +++ b/src/BiliLite.UWP/Models/Common/Enumerates.cs @@ -561,4 +561,14 @@ public enum SearchType /// Topic = 7 } + + public enum IndexSeasonType + { + Anime = 1, + Movie = 2, + Documentary = 3, + Guochuang = 4, + TV = 5, + Variety = 7 + } } \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Favorites/FavoriteDetailModel.cs b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteDetailModel.cs new file mode 100644 index 00000000..a45d0d2f --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteDetailModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using BiliLite.Modules; + +namespace BiliLite.Models.Common.Favorites; + +public class FavoriteDetailModel +{ + public FavoriteInfoModel Info { get; set; } + + public List Medias { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoModel.cs b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoModel.cs new file mode 100644 index 00000000..41560755 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoModel.cs @@ -0,0 +1,32 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Favorites; + +public class FavoriteInfoModel +{ + public string Cover { get; set; } + + public int Attr { get; set; } + + public bool Privacy => Attr == 2; + + public string Fid { get; set; } + + public string Id { get; set; } + + [JsonProperty("like_state")] + public int LikeState { get; set; } + + [JsonProperty("fav_state")] + public int FavState { get; set; } + + public string Mid { get; set; } + + public string Title { get; set; } + public int Type { get; set; } + + [JsonProperty("media_count")] + public int MediaCount { get; set; } + + public FavoriteInfoVideoItemUpperModel Upper { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemModel.cs b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemModel.cs new file mode 100644 index 00000000..74848d7f --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemModel.cs @@ -0,0 +1,17 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Favorites; + +public class FavoriteInfoVideoItemModel +{ + public string Id { get; set; } + + public string Cover { get; set; } + + public string Title { get; set; } + + public FavoriteInfoVideoItemUpperModel Upper { get; set; } + + [JsonProperty("cnt_info")] + public FavoriteInfoVideoItemStatModel CntInfo { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemStatModel.cs b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemStatModel.cs new file mode 100644 index 00000000..c9853d2b --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemStatModel.cs @@ -0,0 +1,16 @@ +namespace BiliLite.Models.Common.Favorites; + +public class FavoriteInfoVideoItemStatModel +{ + public int Coin { get; set; } + + public int Collect { get; set; } + + public int Danmaku { get; set; } + + public int Play { get; set; } + + public int Reply { get; set; } + + public int Share { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemUpperModel.cs b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemUpperModel.cs new file mode 100644 index 00000000..964a214e --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemUpperModel.cs @@ -0,0 +1,10 @@ +namespace BiliLite.Models.Common.Favorites; + +public class FavoriteInfoVideoItemUpperModel +{ + public string Face { get; set; } + + public string Name { get; set; } + + public string Mid { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Other/FindMoreEntranceModel.cs b/src/BiliLite.UWP/Models/Common/Other/FindMoreEntranceModel.cs new file mode 100644 index 00000000..58601629 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Other/FindMoreEntranceModel.cs @@ -0,0 +1,14 @@ +namespace BiliLite.Models.Common.Other; + +public class FindMoreEntranceModel +{ + public string Name { get; set; } + + public string Desc { get; set; } + + public int Type { get; set; } + + public string Link { get; set; } + + public string Pic { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonIndexConditionFilterItemModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexConditionFilterItemModel.cs new file mode 100644 index 00000000..48a78251 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexConditionFilterItemModel.cs @@ -0,0 +1,8 @@ +namespace BiliLite.Models.Common.Season; + +public class SeasonIndexConditionFilterItemModel +{ + public string Keyword { get; set; } + + public string Name { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonIndexConditionFilterModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexConditionFilterModel.cs new file mode 100644 index 00000000..768df227 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexConditionFilterModel.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + +namespace BiliLite.Models.Common.Season; + +public class SeasonIndexConditionFilterModel +{ + public string Field { get; set; } + + public string Name { get; set; } + + public SeasonIndexConditionFilterItemModel Current { get; set; } + + public List Values { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonIndexParameter.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexParameter.cs new file mode 100644 index 00000000..56794385 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexParameter.cs @@ -0,0 +1,16 @@ +namespace BiliLite.Models.Common.Season; + +public class SeasonIndexParameter +{ + public IndexSeasonType Type { get; set; } = IndexSeasonType.Anime; + + public string Area { get; set; } = "-1"; + + public string Style { get; set; } = "-1"; + + public string Year { get; set; } = "-1"; + + public string Month { get; set; } = "-1"; + + public string Order { get; set; } = "3"; +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonIndexResultItemModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexResultItemModel.cs new file mode 100644 index 00000000..7767441f --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexResultItemModel.cs @@ -0,0 +1,41 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Season; + +public class SeasonIndexResultItemModel +{ + [JsonProperty("season_id")] + public int SeasonId { get; set; } + + public string Title { get; set; } + + public string Badge { get; set; } + + [JsonProperty("badge_type")] + public int BadgeType { get; set; } + + public bool ShowBadge => !string.IsNullOrEmpty(Badge); + + public string Cover { get; set; } + + [JsonProperty("index_show")] + public string IndexShow { get; set; } + + [JsonProperty("is_finish")] + public int IsFinish { get; set; } + + public string Link { get; set; } + + [JsonProperty("media_id")] + public int MediaId { get; set; } + + public string Order { get; set; } + + [JsonProperty("order_type")] + public string OrderType { get; set; } + + public bool ShowScore => + OrderType == "score"; + + //public SeasonIndexResultItemOrderModel order { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonIndexResultItemOrderModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexResultItemOrderModel.cs new file mode 100644 index 00000000..620c2e8b --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexResultItemOrderModel.cs @@ -0,0 +1,40 @@ +using BiliLite.Extensions; +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Season; + +public class SeasonIndexResultItemOrderModel +{ + public string Follow { get; set; } + + public string Play { get; set; } + + public string Score { get; set; } + + [JsonProperty("pub_date")] + public long PubDate { get; set; } + + [JsonProperty("pub_real_time")] + public long PubRealTime { get; set; } + + [JsonProperty("renewal_time")] + public long RenewalTime { get; set; } + + public string Type { get; set; } + + public string BottomText + { + get + { + if (Type == "follow") + { + return Follow; + } + else + { + return RenewalTime.HandelTimestamp() + "更新"; + } + } + } + public bool ShowScore => Type == "score"; +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemModel.cs new file mode 100644 index 00000000..743ca8db --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemModel.cs @@ -0,0 +1,35 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Season; + +public class SeasonRankItemModel +{ + public int Rank { get; set; } + + public string Badge { get; set; } + + public string Desc { get; set; } + + [JsonProperty("season_id")] + public string SeasonId { get; set; } + + public string Title { get; set; } + + public string Url { get; set; } + + public string Cover { get; set; } + + [JsonProperty("badge_type")] + public int BadgeType { get; set; } + + public int Pts { get; set; } + + public bool ShowBadge => !string.IsNullOrEmpty(Badge); + + public bool ShowDanmaku => Stat != null && Stat.Danmaku != 0; + + public SeasonRankItemStatModel Stat { get; set; } + + [JsonProperty("new_ep")] + public SeasonRankItemNewEPModel NewEp { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemNewEPModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemNewEPModel.cs new file mode 100644 index 00000000..7b60849b --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemNewEPModel.cs @@ -0,0 +1,11 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Season; + +public class SeasonRankItemNewEPModel +{ + public string Cover { get; set; } + + [JsonProperty("index_show")] + public string IndexShow { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemStatModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemStatModel.cs new file mode 100644 index 00000000..5910d83f --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemStatModel.cs @@ -0,0 +1,10 @@ +namespace BiliLite.Models.Common.Season; + +public class SeasonRankItemStatModel +{ + public long Danmaku { get; set; } + + public long Follow { get; set; } + + public long View { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemAuthorModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemAuthorModel.cs new file mode 100644 index 00000000..5e8e51c4 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemAuthorModel.cs @@ -0,0 +1,12 @@ +namespace BiliLite.Models.Common.Season; + +public class SeasonShortReviewItemAuthorModel +{ + public string Avatar { get; set; } + + public string Uname { get; set; } + + public long Mid { get; set; } + + public SeasonShortReviewItemVIPModel Vip { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemModel.cs new file mode 100644 index 00000000..cac1a1f4 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemModel.cs @@ -0,0 +1,28 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Season; + +public class SeasonShortReviewItemModel +{ + public long Ctime { get; set; } + + public long Mid { get; set; } + + [JsonProperty("review_id")] + public int ReviewId { get; set; } + + public string Content { get; set; } + + public string Progress { get; set; } + + public int Score { get; set; } + + /// + /// 评分,转为5分制 + /// + public int Score5 => Score / 2; + + public SeasonShortReviewItemAuthorModel Author { get; set; } + + public SeasonShortReviewItemStatModel Stat { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemStatModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemStatModel.cs new file mode 100644 index 00000000..be611771 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemStatModel.cs @@ -0,0 +1,19 @@ +namespace BiliLite.Models.Common.Season; + +public class SeasonShortReviewItemStatModel +{ + /// + /// 是否已经点踩👎 + /// + public int Disliked { get; set; } + + /// + /// 是否已经点赞👍 + /// + public int Liked { get; set; } + + /// + /// 点赞数量 + /// + public int Likes { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemVIPModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemVIPModel.cs new file mode 100644 index 00000000..ece8d570 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemVIPModel.cs @@ -0,0 +1,8 @@ +namespace BiliLite.Models.Common.Season; + +public class SeasonShortReviewItemVIPModel +{ + public int VipType { get; set; } + + public int VipStatus { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs b/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs index 809d6314..f6215493 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs @@ -1,11 +1,19 @@ using BiliLite.Services; using System; using BiliLite.Models.Common; +using Microsoft.Extensions.DependencyInjection; namespace BiliLite.Models.Requests.Api { public class SeasonApi : BaseApi { + private readonly CookieService m_cookieService; + + public SeasonApi() + { + m_cookieService = App.ServiceProvider.GetRequiredService(); + } + /// /// 用season_id / ep_id 取番剧信息 /// @@ -63,11 +71,12 @@ public ApiModel ShortReview(int media_id, string next = "", int sort = 0) /// public ApiModel LikeReview(int media_id, int review_id, ReviewType review_type = ReviewType.Short) { + var csrf = m_cookieService.GetCSRFToken(); var api = new ApiModel() { method = HttpMethods.Post, - baseUrl = $"https://bangumi.bilibili.com/review/api/like", - body = $"{ApiHelper.MustParameter(AppKey, true)}&media_id={media_id}&review_id={review_id}&review_type={(int)review_type}" + baseUrl = $"https://api.bilibili.com/pgc/review/action/like", + body = $"{ApiHelper.MustParameter(AppKey, true)}&media_id={media_id}&review_id={review_id}&review_type={(int)review_type}", }; api.body += ApiHelper.GetSign(api.body, AppKey); return api; @@ -82,7 +91,7 @@ public ApiModel DislikeReview(int media_id, int review_id, ReviewType review_typ var api = new ApiModel() { method = HttpMethods.Post, - baseUrl = $"https://bangumi.bilibili.com/review/api/dislike", + baseUrl = $"https://api.bilibili.com/pgc/review/action/dislike", body = $"{ApiHelper.MustParameter(AppKey, true)}&media_id={media_id}&review_id={review_id}&review_type={(int)review_type}" }; api.body += ApiHelper.GetSign(api.body, AppKey); @@ -101,7 +110,7 @@ public ApiModel SendShortReview(int media_id, string content, bool share_feed, i var api = new ApiModel() { method = HttpMethods.Post, - baseUrl = $"https://bangumi.bilibili.com/review/api/short/post", + baseUrl = $"https://api.bilibili.com/pgc/review/action/short/post", body = $"{ApiHelper.MustParameter(AppKey, true)}&media_id={media_id}&content={Uri.EscapeDataString(content)}&share_feed={(share_feed ? 1 : 0)}&score={score}" }; api.body += ApiHelper.GetSign(api.body, AppKey); diff --git a/src/BiliLite.UWP/Modules/Detail/FavoriteDetailVM.cs b/src/BiliLite.UWP/Modules/Detail/FavoriteDetailVM.cs deleted file mode 100644 index 46b77088..00000000 --- a/src/BiliLite.UWP/Modules/Detail/FavoriteDetailVM.cs +++ /dev/null @@ -1,434 +0,0 @@ -using BiliLite.Models; -using BiliLite.Models.Requests.Api.User; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Input; -using Windows.UI.Xaml.Controls; -using BiliLite.Extensions; -using BiliLite.Services; - -namespace BiliLite.Modules -{ - public class FavoriteDetailVM : IModules - { - readonly FavoriteApi favoriteApi; - public int Page { get; set; } = 1; - public string Keyword { get; set; } = ""; - public string Id { get; set; } - public int Type { get; set; } - public FavoriteDetailVM() - { - favoriteApi = new FavoriteApi(); - RefreshCommand = new RelayCommand(Refresh); - LoadMoreCommand = new RelayCommand(LoadMore); - CollectCommand = new RelayCommand(DoCollect); - CancelCollectCommand = new RelayCommand(DoCancelCollect); - SelectCommand = new RelayCommand(SetSelectMode); - } - private bool _loading = false; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - private FavoriteInfoModel _FavoriteInfo; - public FavoriteInfoModel FavoriteInfo - { - get { return _FavoriteInfo; } - set { _FavoriteInfo = value; DoPropertyChanged("FavoriteInfo"); } - } - private ObservableCollection _videos; - public ObservableCollection Videos - { - get { return _videos; } - set { _videos = value; DoPropertyChanged("Videos"); } - } - - private ListViewSelectionMode _selectionMode = ListViewSelectionMode.None; - public ListViewSelectionMode SelectionMode - { - get { return _selectionMode; } - set { _selectionMode = value; DoPropertyChanged("SelectionMode"); } - } - - private bool _IsItemClickEnabled = true; - public bool IsItemClickEnabled - { - get { return _IsItemClickEnabled; } - set { _IsItemClickEnabled = value; DoPropertyChanged("IsItemClickEnabled"); } - } - public ICommand CollectCommand { get; private set; } - public ICommand CancelCollectCommand { get; private set; } - public ICommand RefreshCommand { get; private set; } - public ICommand LoadMoreCommand { get; private set; } - public ICommand SelectCommand { get; private set; } - private bool _Nothing = false; - public bool Nothing - { - get { return _Nothing; } - set { _Nothing = value; DoPropertyChanged("Nothing"); } - } - - private bool _ShowLoadMore = false; - public bool ShowLoadMore - { - get { return _ShowLoadMore; } - set { _ShowLoadMore = value; DoPropertyChanged("ShowLoadMore"); } - } - private bool _isSelf = false; - public bool IsSelf - { - get { return _isSelf; } - set { _isSelf = value; DoPropertyChanged("IsSelf"); } - } - - private bool _showCollect = false; - public bool ShowCollect - { - get { return _showCollect; } - set { _showCollect = value; DoPropertyChanged("ShowCollect"); } - } - private bool _showCancelCollect = false; - public bool ShowCancelCollect - { - get { return _showCancelCollect; } - set { _showCancelCollect = value; DoPropertyChanged("ShowCancelCollect"); } - } - public async Task LoadFavoriteInfo() - { - try - { - ShowLoadMore = false; - Loading = true; - Nothing = false; - var api = favoriteApi.FavoriteInfo(Id, Keyword, Page); - if (Type == 21) - { - api = favoriteApi.FavoriteSeasonInfo(Id, Keyword, Page); - } - var results = await api.Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - if (Page == 1) - { - FavoriteInfo = data.data.info; - IsSelf = FavoriteInfo.mid == SettingService.Account.UserID.ToString(); - if (!IsSelf) - { - ShowCollect = FavoriteInfo.fav_state != 1; - ShowCancelCollect = !ShowCollect; - } - - if (data.data.medias == null || data.data.medias.Count == 0) - { - Nothing = true; - return; - } - Videos = data.data.medias; - - } - else - { - if (data.data.medias != null) - { - foreach (var item in data.data.medias) - { - Videos.Add(item); - } - } - } - if (Videos.Count != FavoriteInfo.media_count) - { - ShowLoadMore = true; - Page++; - } - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - public async Task Delete(List items) - { - try - { - if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) - { - Notify.ShowMessageToast("请先登录后再操作"); - return; - } - var results = await favoriteApi.Delete(Id, items.Select(x => x.id).ToList()).Request(); - if (results.status) - { - var data = await results.GetData(); - if (data.success) - { - foreach (var item in items) - { - Videos.Remove(item); - } - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - - } - public async Task Clean() - { - try - { - if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) - { - Notify.ShowMessageToast("请先登录后再操作"); - return; - } - var results = await favoriteApi.Clean(Id).Request(); - if (results.status) - { - var data = await results.GetData(); - if (data.success) - { - Refresh(); - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - - } - public async void Refresh() - { - if (Loading) - { - return; - } - Page = 1; - FavoriteInfo = null; - Videos = null; - await LoadFavoriteInfo(); - } - - public async Task Sort(string sourceId,string targetId) - { - var result= await favoriteApi.SortResource(Id, sourceId, targetId).Request(); - if (!result.status) - { - Notify.ShowMessageToast("排序失败" + result.message); - return; - } - - var data = await result.GetData(); - if (data.success) - { - Notify.ShowMessageToast("排序成功"); - return; - } - Notify.ShowMessageToast("排序失败" + data.message); - } - - public async void LoadMore() - { - if (Loading) - { - return; - } - if (Videos == null || Videos.Count == 0) - { - return; - } - await LoadFavoriteInfo(); - } - public async void Search(string keyword) - { - if (Loading) - { - return; - } - Keyword = keyword; - Page = 1; - FavoriteInfo = null; - Videos = null; - await LoadFavoriteInfo(); - } - private void SetSelectMode(object data) - { - if (data == null) - { - IsItemClickEnabled = true; - SelectionMode = ListViewSelectionMode.None; - } - else - { - IsItemClickEnabled = false; - SelectionMode = ListViewSelectionMode.Multiple; - } - } - public async void DoCollect() - { - if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) - { - Notify.ShowMessageToast("请先登录后再操作"); - return; - } - try - { - var results = await favoriteApi.CollectFavorite(FavoriteInfo.id).Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - ShowCancelCollect = true; - ShowCollect = false; - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - - - } - public async void DoCancelCollect() - { - if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) - { - Notify.ShowMessageToast("请先登录后再操作"); - return; - } - try - { - var results = await favoriteApi.CacnelCollectFavorite(FavoriteInfo.id).Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - ShowCancelCollect = false; - ShowCollect = true; - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - - - } - } - public class FavoriteDetailModel - { - public FavoriteInfoModel info { get; set; } - public ObservableCollection medias { get; set; } - } - - public class FavoriteInfoModel - { - public string cover { get; set; } - public int attr { get; set; } - public bool privacy - { - get - { - return attr == 2; - } - } - public string fid { get; set; } - public string id { get; set; } - public int like_state { get; set; } - public int fav_state { get; set; } - public string mid { get; set; } - public string title { get; set; } - public int type { get; set; } - public int media_count { get; set; } - public FavoriteInfoVideoItemUpperModel upper { get; set; } - } - - public class FavoriteInfoVideoItemModel - { - public string id { get; set; } - public string cover { get; set; } - public string title { get; set; } - public FavoriteInfoVideoItemUpperModel upper { get; set; } - public FavoriteInfoVideoItemStatModel cnt_info { get; set; } - } - public class FavoriteInfoVideoItemUpperModel - { - public string face { get; set; } - public string name { get; set; } - public string mid { get; set; } - } - public class FavoriteInfoVideoItemStatModel - { - public int coin { get; set; } - public int collect { get; set; } - public int danmaku { get; set; } - public int play { get; set; } - public int reply { get; set; } - public int share { get; set; } - } -} diff --git a/src/BiliLite.UWP/Modules/Other/FindMoreVM.cs b/src/BiliLite.UWP/Modules/Other/FindMoreVM.cs deleted file mode 100644 index 87a1c744..00000000 --- a/src/BiliLite.UWP/Modules/Other/FindMoreVM.cs +++ /dev/null @@ -1,66 +0,0 @@ -using BiliLite.Models.Requests.Api; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using BiliLite.Extensions; - -namespace BiliLite.Modules.Other -{ - public class FindMoreVM : IModules - { - readonly GitApi gitApi; - public FindMoreVM() - { - gitApi = new GitApi(); - } - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - private List _Items; - public List Items - { - get { return _Items; } - set { _Items = value; DoPropertyChanged("Items"); } - } - public async void LoadEntrance() - { - try - { - Loading = true; - var results = await gitApi.FindMoreEntrance().Request(); - if (results.status) - { - var data = await results.GetJson>(); - await Task.Delay(2000); - Items = data; - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError (ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - } - public class FindMoreEntranceModel - { - public string name { get; set; } - public string desc { get; set; } - public int type { get; set; } - public string link { get; set; } - public string pic { get; set; } - } -} diff --git a/src/BiliLite.UWP/Modules/Season/AnimeTimelineVM.cs b/src/BiliLite.UWP/Modules/Season/AnimeTimelineVM.cs deleted file mode 100644 index 5722e908..00000000 --- a/src/BiliLite.UWP/Modules/Season/AnimeTimelineVM.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using BiliLite.Models; -using BiliLite.Extensions; -using BiliLite.Models.Common; -using BiliLite.Models.Common.Anime; -using BiliLite.Models.Requests.Api.Home; -using Newtonsoft.Json; - -namespace BiliLite.Modules -{ - public class AnimeTimelineVM : IModules - { - readonly AnimeAPI animeApi; - public AnimeType animeType { get; set; } - public AnimeTimelineVM(AnimeType type) - { - animeApi = new AnimeAPI(); - AnimeTypeItems = new List() - { - new AnimeTypeItem() - { - Name="番剧", - AnimeType= AnimeType.Bangumi - }, - new AnimeTypeItem() - { - Name="国创", - AnimeType= AnimeType.GuoChuang - } - }; - SelectAnimeType = AnimeTypeItems.FirstOrDefault(x => x.AnimeType == type); - animeType = type; - - } - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - - private List _animeTypeItems; - - public List AnimeTypeItems - { - get { return _animeTypeItems; } - set { _animeTypeItems = value; DoPropertyChanged("AnimeTypeItems"); } - } - - - private AnimeTypeItem _selectAnimeType; - - public AnimeTypeItem SelectAnimeType - { - get { return _selectAnimeType; } - set { _selectAnimeType = value; DoPropertyChanged("SelectAnimeType"); } - } - - - private AnimeTimelineModel _today; - - public AnimeTimelineModel Today - { - get { return _today; } - set { _today = value; DoPropertyChanged("Today"); } - } - - private List _timelines; - - public List Timelines - { - get { return _timelines; } - set { _timelines = value; DoPropertyChanged("Timelines"); } - } - - public async Task GetTimeline() - { - try - { - Loading = true; - var api = animeApi.Timeline((int)animeType); - - var results = await api.Request(); - if (results.status) - { - var data = await results.GetJson>>(); - if (data.success) - { - Timelines = data.data; - Today = data.data.FirstOrDefault(x => x.is_today); - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - } - public class AnimeTypeItem - { - public string Name { get; set; } - public AnimeType AnimeType { get; set; } - } - public class AnimeTimelineModel - { - public string week { get; set; } - public int day_week { get; set; } - public string date { get; set; } - public bool is_today { get; set; } - public List seasons { get; set; } - } - public class AnimeTimelineItemModel : ISeasonItem - { - [JsonProperty("season_id")] - public int SeasonId { get; set; } - - public string Cover { get; set; } - - [JsonProperty("square_cover")] - public string SquareCover { get; set; } - - [JsonProperty("pub_index")] - public string PubIndex { get; set; } - - [JsonProperty("pub_time")] - public string PubTime { get; set; } - - public string Title { get; set; } - } -} diff --git a/src/BiliLite.UWP/Modules/Season/SeasonIndexVM.cs b/src/BiliLite.UWP/Modules/Season/SeasonIndexVM.cs deleted file mode 100644 index 5bc34fa5..00000000 --- a/src/BiliLite.UWP/Modules/Season/SeasonIndexVM.cs +++ /dev/null @@ -1,340 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Collections.ObjectModel; -using Newtonsoft.Json; -using System.Windows.Input; -using BiliLite.Extensions; -using BiliLite.Models.Requests.Api; - -namespace BiliLite.Modules -{ - public enum IndexSeasonType - { - Anime = 1, - Movie = 2, - Documentary = 3, - Guochuang = 4, - TV = 5, - Variety = 7 - } - public class SeasonIndexParameter - { - public IndexSeasonType type { get; set; } = IndexSeasonType.Anime; - public string area { get; set; } = "-1"; - public string style { get; set; } = "-1"; - public string year { get; set; } = "-1"; - public string month { get; set; } = "-1"; - public string order { get; set; } = "3"; - } - public class SeasonIndexVM : IModules - { - readonly SeasonIndexAPI seasonIndexAPI; - public SeasonIndexVM() - { - seasonIndexAPI = new SeasonIndexAPI(); - RefreshCommand = new RelayCommand(Refresh); - LoadMoreCommand = new RelayCommand(LoadMore); - } - public SeasonIndexParameter Parameter { get; set; } - - public ICommand RefreshCommand { get; private set; } - public ICommand LoadMoreCommand { get; private set; } - - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - - - private bool CanLoadMore = true; - - - private bool _Conditionsloading = true; - public bool ConditionsLoading - { - get { return _Conditionsloading; } - set { _Conditionsloading = value; DoPropertyChanged("ConditionsLoading"); } - } - - private ObservableCollection _Conditions; - public ObservableCollection Conditions - { - get { return _Conditions; } - set { _Conditions = value; DoPropertyChanged("Conditions"); } - } - - private ObservableCollection _result; - public ObservableCollection Result - { - get { return _result; } - set { _result = value; DoPropertyChanged("Result"); } - } - - private int _page = 1; - public int Page - { - get { return _page; } - set { _page = value; } - } - - public async Task LoadConditions() - { - try - { - ConditionsLoading = true; - var results = await seasonIndexAPI.Condition((int)Parameter.type).Request(); - if (results.status) - { - var data = results.GetJObject(); - if (data["code"].ToInt32() == 0) - { - var items = JsonConvert.DeserializeObject>(data["data"]["filter"].ToString()); - foreach (var item in items) - { - if (item.field == "style_id") - { - item.current = item.values.FirstOrDefault(x => x.keyword == Parameter.style); - } - else if (item.field == "area") - { - item.current = item.values.FirstOrDefault(x => x.keyword == Parameter.area); - } - else if (item.field == "pub_date") - { - item.current = item.values.FirstOrDefault(x => x.keyword == Parameter.year); - } - else if (item.field == "season_month") - { - item.current = item.values.FirstOrDefault(x => x.keyword == Parameter.month); - } - else - { - item.current = item.values.FirstOrDefault(); - } - } - var orders = new List(); - - foreach (var item in data["data"]["order"]) - { - orders.Add(new SeasonIndexConditionFilterItemModel() - { - keyword = item["field"].ToString(), - name = item["name"].ToString() - }); - } - - items.Insert(0, new SeasonIndexConditionFilterModel() - { - name = "排序", - values = orders, - field = "order", - current = orders.FirstOrDefault(x => x.name == Parameter.order) ?? orders[0], - }); - Conditions = items; - } - else - { - Notify.ShowMessageToast(data["message"].ToString()); - } - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - ConditionsLoading = false; - } - } - - public async Task LoadResult() - { - try - { - if (Loading) return; - - if (Page == 1) - { - CanLoadMore = true; - Result = null; - } - else - { - if (!CanLoadMore) - { - Loading = false; - return; - } - } - Loading = true; - var con = ""; - foreach (var item in Conditions) - { - con += $"&{item.field}={Uri.EscapeDataString(item.current.keyword)}"; - } - con += $"&sort=0"; - var results = await seasonIndexAPI.Result(Page, (int)Parameter.type, con).Request(); - if (results.status) - { - var data = results.GetJObject(); - if (data["code"].ToInt32() == 0) - { - var items = JsonConvert.DeserializeObject>(data["data"]["list"]?.ToString() ?? "[]"); - if (items != null && items.Count != 0) - { - if (Page == 1) - { - Result = items; - } - else - { - foreach (var item in items) - { - Result.Add(item); - } - } - Page++; - } - else - { - - CanLoadMore = false; - Notify.ShowMessageToast("加载完了"); - } - } - else - { - Notify.ShowMessageToast(data["message"].ToString()); - } - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - public async void Refresh() - { - if (Loading) - { - return; - } - Page = 1; - if (Conditions == null) - { - await LoadConditions(); - } - if (Conditions != null) - { - await LoadResult(); - } - } - public async void LoadMore() - { - if (Loading) - { - return; - } - if (Conditions == null || Conditions.Count == 0 || Result == null || Result.Count == 0) - { - return; - } - await LoadResult(); - } - - } - - public class SeasonIndexConditionFilterModel : IModules - { - public string field { get; set; } - public string name { get; set; } - - private SeasonIndexConditionFilterItemModel _current; - public SeasonIndexConditionFilterItemModel current - { - get { return _current; } - set { _current = value; } - } - public List values { get; set; } - } - public class SeasonIndexConditionFilterItemModel - { - public string keyword { get; set; } - public string name { get; set; } - - } - - public class SeasonIndexResultItemModel - { - public int season_id { get; set; } - public string title { get; set; } - public string badge { get; set; } - public int badge_type { get; set; } - public bool show_badge - { - get - { - return !string.IsNullOrEmpty(badge); - } - } - public string cover { get; set; } - public string index_show { get; set; } - public int is_finish { get; set; } - public string link { get; set; } - public int media_id { get; set; } - public string order { get; set; } - public string order_type { get; set; } - public bool show_score - { - get - { - return order_type == "score"; - } - } - - //public SeasonIndexResultItemOrderModel order { get; set; } - } - public class SeasonIndexResultItemOrderModel - { - public string follow { get; set; } - public string play { get; set; } - public string score { get; set; } - public long pub_date { get; set; } - public long pub_real_time { get; set; } - public long renewal_time { get; set; } - public string type { get; set; } - public string bottom_text - { - get - { - if (type == "follow") - { - return follow; - } - else - { - return renewal_time.HandelTimestamp() + "更新"; - } - } - } - public bool show_score - { - get - { - return type == "score"; - } - } - } -} diff --git a/src/BiliLite.UWP/Modules/Season/SeasonRankVM.cs b/src/BiliLite.UWP/Modules/Season/SeasonRankVM.cs deleted file mode 100644 index 461deb40..00000000 --- a/src/BiliLite.UWP/Modules/Season/SeasonRankVM.cs +++ /dev/null @@ -1,153 +0,0 @@ -using BiliLite.Models; -using BiliLite.Models.Requests.Api; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using BiliLite.Extensions; - -namespace BiliLite.Modules.Season -{ - public class SeasonRankVM : IModules - { - readonly RankAPI rankAPI; - public SeasonRankVM() - { - rankAPI = new RankAPI(); - } - - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - private SeasonRankModel _current; - - public SeasonRankModel Current - { - get { return _current; } - set { _current = value; DoPropertyChanged("Current"); } - } - private List _RegionItems; - public List RegionItems - { - get { return _RegionItems; } - set { _RegionItems = value; DoPropertyChanged("RegionItems"); } - } - - public void LoadRankRegion(int type = 1) - { - RegionItems = new List() - { - new SeasonRankModel() - { - name="热门番剧", - type=1 - }, - new SeasonRankModel() - { - name="热门国创", - type=4 - }, - new SeasonRankModel() - { - name="热门电影", - type=2 - }, - new SeasonRankModel() - { - name="热门纪录片", - type=3 - }, - new SeasonRankModel() - { - name="热门电视剧", - type=5 - }, - new SeasonRankModel() - { - name="热门综艺", - type=7 - }, - }; - Current = RegionItems.FirstOrDefault(x => x.type.Equals(type)); - } - - public async Task LoadRankDetail(SeasonRankModel region) - { - try - { - Loading = true; - var results = await rankAPI.SeasonRank(region.type).Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - var result = await data.data["list"].ToString().DeserializeJson>(); - region.Items = result; - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - } - public class SeasonRankModel : IModules - { - public string name { get; set; } - public int type { get; set; } - - private List _Items; - public List Items - { - get { return _Items; } - set { _Items = value; DoPropertyChanged("Items"); } - } - } - public class SeasonRankItemModel - { - public int rank { get; set; } - public string badge { get; set; } - public string desc { get; set; } - public string season_id { get; set; } - public string title { get; set; } - public string url { get; set; } - public string cover { get; set; } - public int badge_type { get; set; } - public int pts { get; set; } - public bool show_badge { get { return !string.IsNullOrEmpty(badge); } } - public bool show_danmaku { get { return stat != null && stat.danmaku != 0; } } - public SeasonRankItemStatModel stat { get; set; } - public SeasonRankItemNewEPModel new_ep { get; set; } - } - public class SeasonRankItemStatModel - { - public long danmaku { get; set; } - public long follow { get; set; } - public long view { get; set; } - } - public class SeasonRankItemNewEPModel - { - public string cover { get; set; } - public string index_show { get; set; } - } -} diff --git a/src/BiliLite.UWP/Modules/Season/SeasonReviewVM.cs b/src/BiliLite.UWP/Modules/Season/SeasonReviewVM.cs deleted file mode 100644 index 84a4ed10..00000000 --- a/src/BiliLite.UWP/Modules/Season/SeasonReviewVM.cs +++ /dev/null @@ -1,297 +0,0 @@ -using BiliLite.Models; -using BiliLite.Models.Requests.Api; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Threading.Tasks; -using System.Windows.Input; -using BiliLite.Extensions; -using BiliLite.Services; - -namespace BiliLite.Modules.Season -{ - public class SeasonReviewVM : IModules - { - readonly SeasonApi seasonApi; - - public SeasonReviewVM() - { - - Items = new ObservableCollection(); - seasonApi = new SeasonApi(); - RefreshCommand = new RelayCommand(Refresh); - LoadMoreCommand = new RelayCommand(LoadMore); - } - public ObservableCollection Items { get; set; } - public int MediaID { get; set; } - public ICommand RefreshCommand { get; private set; } - public ICommand LoadMoreCommand { get; private set; } - private bool _loading = false; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - - private bool _CanLoadMore = false; - public bool CanLoadMore - { - get { return _CanLoadMore; } - set { _CanLoadMore = value; DoPropertyChanged("CanLoadMore"); } - } - - public string Next { get; set; } = ""; - public async Task GetItems() - { - try - { - if (MediaID == 0) { return; } - Loading = true; - CanLoadMore = false; - var results = await seasonApi.ShortReview(MediaID, Next).Request(); - if (results.status) - { - var data = results.GetJObject(); - if (data["code"].ToInt32() == 0) - { - var items = JsonConvert.DeserializeObject>(data["data"]["list"].ToString()); - if (items != null) - { - foreach (var item in items) - { - Items.Add(item); - } - //Items = new IncrementalLoadingCollection(new LiveRecommendItemSource(items, SortType), 30); - if (Items.Count < data["data"]["total"].ToInt32()) - { - Next = data["data"]["next"].ToString(); - CanLoadMore = true; - } - } - } - else - { - Notify.ShowMessageToast(data["message"].ToString()); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - public async void Refresh() - { - if (Loading) - { - return; - } - Items.Clear(); - Next = ""; - await GetItems(); - } - public async void LoadMore() - { - if (Loading) - { - return; - } - await GetItems(); - } - - public async void Like(SeasonShortReviewItemModel item) - { - if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) - { - Notify.ShowMessageToast("请先登录后再操作"); - return; - } - try - { - var api = seasonApi.LikeReview(MediaID, item.review_id, ReviewType.Short); - var results = await api.Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - item.stat.liked = data.result["status"].ToInt32(); - if (item.stat.liked == 1) - { - item.stat.likes += 1; - } - else - { - item.stat.likes -= 1; - } - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - - } - - public async void Dislike(SeasonShortReviewItemModel item) - { - if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) - { - Notify.ShowMessageToast("请先登录后再操作"); - return; - } - try - { - var api = seasonApi.DislikeReview(MediaID, item.review_id, ReviewType.Short); - var results = await api.Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - item.stat.disliked = data.result["status"].ToInt32(); - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - - } - - public async Task SendShortReview(string content, bool share, int score) - { - if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) - { - Notify.ShowMessageToast("请先登录后再操作"); - return false; - } - try - { - var api = seasonApi.SendShortReview(MediaID, content, share, score); - var results = await api.Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - Notify.ShowMessageToast("发表成功"); - return true; - } - else - { - Notify.ShowMessageToast(data.message); - return false; - } - } - else - { - Notify.ShowMessageToast(results.message); - return false; - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - return false; - } - - } - } - - - public class SeasonShortReviewItemModel - { - public long ctime { get; set; } - public long mid { get; set; } - public int review_id { get; set; } - public string content { get; set; } - public string progress { get; set; } - public int score { get; set; } - /// - /// 评分,转为5分制 - /// - public int score_5 { get { return score / 2; } } - public SeasonShortReviewItemAuthorModel author { get; set; } - public SeasonShortReviewItemStatModel stat { get; set; } - } - public class SeasonShortReviewItemAuthorModel - { - public string avatar { get; set; } - public string uname { get; set; } - public long mid { get; set; } - public SeasonShortReviewItemVIPModel vip { get; set; } - } - public class SeasonShortReviewItemVIPModel - { - public int vipType { get; set; } - public int vipStatus { get; set; } - } - public class SeasonShortReviewItemStatModel : IModules - { - private int _disliked; - /// - /// 是否已经点踩👎 - /// - public int disliked - { - get { return _disliked; } - set { _disliked = value; DoPropertyChanged("disliked"); } - } - - private int _liked; - /// - /// 是否已经点赞👍 - /// - public int liked - { - get { return _liked; } - set { _liked = value; DoPropertyChanged("liked"); } - } - - private int _likes; - /// - /// 点赞数量 - /// - public int likes - { - get { return _likes; } - set { _likes = value; DoPropertyChanged("likes"); } - } - - } -} diff --git a/src/BiliLite.UWP/Pages/Bangumi/AnimeIndexPage.xaml b/src/BiliLite.UWP/Pages/Bangumi/AnimeIndexPage.xaml index 1786c526..a67f2f91 100644 --- a/src/BiliLite.UWP/Pages/Bangumi/AnimeIndexPage.xaml +++ b/src/BiliLite.UWP/Pages/Bangumi/AnimeIndexPage.xaml @@ -7,30 +7,33 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" - xmlns:model="using:BiliLite.Modules" xmlns:controls="using:BiliLite.Controls" xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls" xmlns:winui="using:Microsoft.UI.Xaml.Controls" - xmlns:fa="using:FontAwesome5" - Background="Transparent"> - + xmlns:fa="using:FontAwesome5" + xmlns:season="using:BiliLite.Models.Common.Season" + Background="Transparent"> - + - + - - + + + @@ -39,10 +42,10 @@ - + @@ -60,7 +63,7 @@ - + @@ -69,17 +72,17 @@ - - + + - - + + - - + + @@ -92,14 +95,14 @@ - + 加载更多 - + - + diff --git a/src/BiliLite.UWP/Pages/Bangumi/AnimeIndexPage.xaml.cs b/src/BiliLite.UWP/Pages/Bangumi/AnimeIndexPage.xaml.cs index fc413e7d..ddf55da8 100644 --- a/src/BiliLite.UWP/Pages/Bangumi/AnimeIndexPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/Bangumi/AnimeIndexPage.xaml.cs @@ -1,11 +1,13 @@ using BiliLite.Extensions; using BiliLite.Models.Common; -using BiliLite.Modules; using BiliLite.Services; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Navigation; +using BiliLite.Models.Common.Season; +using BiliLite.ViewModels.Season; +using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -18,13 +20,13 @@ namespace BiliLite.Pages.Bangumi public sealed partial class AnimeIndexPage : BasePage { private SeasonIndexParameter indexParameter; - readonly SeasonIndexVM seasonIndexVM; + private readonly SeasonIndexViewModel m_viewModel; public AnimeIndexPage() { + m_viewModel = App.ServiceProvider.GetRequiredService(); this.InitializeComponent(); Title = "剧集索引"; this.NavigationCacheMode = NavigationCacheMode.Enabled; - seasonIndexVM = new SeasonIndexVM(); } protected async override void OnNavigatedTo(NavigationEventArgs e) { @@ -40,11 +42,11 @@ protected async override void OnNavigatedTo(NavigationEventArgs e) indexParameter=e.Parameter as SeasonIndexParameter; } - seasonIndexVM.Parameter = indexParameter; - await seasonIndexVM.LoadConditions(); - if (seasonIndexVM.Conditions != null) + m_viewModel.Parameter = indexParameter; + await m_viewModel.LoadConditions(); + if (m_viewModel.Conditions != null) { - await seasonIndexVM.LoadResult(); + await m_viewModel.LoadResult(); } } } @@ -56,8 +58,8 @@ private void SeasonIndexResultItemOpen(object sender, SeasonIndexResultItemModel { icon = Symbol.Play, page = typeof(Pages.SeasonDetailPage), - parameters = item.season_id, - title = item.title, + parameters = item.SeasonId, + title = item.Title, dontGoTo = dontGoTo }); } @@ -79,12 +81,12 @@ private void MyAdaptiveGridView_PointerPressed(object sender, PointerRoutedEvent private async void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { var combox = sender as ComboBox; - if (combox.SelectedItem == null || seasonIndexVM.ConditionsLoading|| seasonIndexVM.Loading) + if (combox.SelectedItem == null || m_viewModel.ConditionsLoading|| m_viewModel.Loading) { return; } - seasonIndexVM.Page = 1; - await seasonIndexVM.LoadResult(); + m_viewModel.Page = 1; + await m_viewModel.LoadResult(); } } diff --git a/src/BiliLite.UWP/Pages/Bangumi/SeasonRankPage.xaml b/src/BiliLite.UWP/Pages/Bangumi/SeasonRankPage.xaml index dc5a0090..07b0c21d 100644 --- a/src/BiliLite.UWP/Pages/Bangumi/SeasonRankPage.xaml +++ b/src/BiliLite.UWP/Pages/Bangumi/SeasonRankPage.xaml @@ -9,7 +9,8 @@ mc:Ignorable="d" xmlns:convert="using:BiliLite.Converters" xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls" - xmlns:modules="using:BiliLite.Modules.Season" + xmlns:season="using:BiliLite.Models.Common.Season" + xmlns:viewModel="using:BiliLite.ViewModels.Season" Background="Transparent"> @@ -17,11 +18,11 @@ - + - - + + @@ -30,7 +31,7 @@ - + - + @@ -54,20 +55,20 @@ - - - + + + - - + + - - - 弹幕: - 综合评分 + + + 弹幕: + 综合评分 @@ -76,6 +77,6 @@ - + diff --git a/src/BiliLite.UWP/Pages/Bangumi/SeasonRankPage.xaml.cs b/src/BiliLite.UWP/Pages/Bangumi/SeasonRankPage.xaml.cs index b4816aa2..0d32ba40 100644 --- a/src/BiliLite.UWP/Pages/Bangumi/SeasonRankPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/Bangumi/SeasonRankPage.xaml.cs @@ -1,11 +1,13 @@ using BiliLite.Extensions; using BiliLite.Models.Common; -using BiliLite.Modules.Season; using BiliLite.Services; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Navigation; +using BiliLite.Models.Common.Season; +using BiliLite.ViewModels.Season; +using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -16,13 +18,14 @@ namespace BiliLite.Pages.Bangumi /// public sealed partial class SeasonRankPage : BasePage { - readonly SeasonRankVM seasonRankVM; + readonly SeasonRankViewModel m_viewModel; + public SeasonRankPage() { + m_viewModel = App.ServiceProvider.GetRequiredService(); this.InitializeComponent(); Title = "热门榜单"; this.NavigationCacheMode = NavigationCacheMode.Enabled; - seasonRankVM = new SeasonRankVM(); } protected override void OnNavigatedTo(NavigationEventArgs e) @@ -30,7 +33,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) base.OnNavigatedTo(e); if (e.NavigationMode == NavigationMode.New) { - seasonRankVM.LoadRankRegion((int)e.Parameter); + m_viewModel.LoadRankRegion((int)e.Parameter); } } @@ -40,10 +43,10 @@ private async void pivot_SelectionChanged(object sender, SelectionChangedEventAr { return; } - var data = pivot.SelectedItem as SeasonRankModel; + var data = pivot.SelectedItem as SeasonRankDataViewModel; if (data.Items == null || data.Items.Count == 0) { - await seasonRankVM.LoadRankDetail(data); + await m_viewModel.LoadRankDetail(data); } } @@ -54,8 +57,8 @@ private void SeasonRankItemOpen(object sender, SeasonRankItemModel item, bool do { icon = Symbol.Play, page = typeof(SeasonDetailPage), - title = item.title, - parameters = item.season_id, + title = item.Title, + parameters = item.SeasonId, dontGoTo = dontGoTo }); } diff --git a/src/BiliLite.UWP/Pages/Bangumi/TimelinePage.xaml b/src/BiliLite.UWP/Pages/Bangumi/TimelinePage.xaml index f0363440..28b0694b 100644 --- a/src/BiliLite.UWP/Pages/Bangumi/TimelinePage.xaml +++ b/src/BiliLite.UWP/Pages/Bangumi/TimelinePage.xaml @@ -8,28 +8,28 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:controls="using:BiliLite.Controls" - xmlns:modules="using:BiliLite.Modules" xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls" xmlns:fa="using:FontAwesome5" + xmlns:anime="using:BiliLite.Models.Common.Anime" Background="Transparent"> - + - + - - + + - + @@ -42,7 +42,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -98,6 +98,6 @@ - + diff --git a/src/BiliLite.UWP/Pages/Bangumi/TimelinePage.xaml.cs b/src/BiliLite.UWP/Pages/Bangumi/TimelinePage.xaml.cs index 66624815..31e03839 100644 --- a/src/BiliLite.UWP/Pages/Bangumi/TimelinePage.xaml.cs +++ b/src/BiliLite.UWP/Pages/Bangumi/TimelinePage.xaml.cs @@ -1,11 +1,13 @@ using BiliLite.Extensions; using BiliLite.Models.Common; -using BiliLite.Modules; using BiliLite.Services; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Navigation; +using BiliLite.Models.Common.Anime; +using BiliLite.ViewModels.Season; +using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -16,19 +18,22 @@ namespace BiliLite.Pages.Bangumi /// public sealed partial class TimelinePage : BasePage { - Modules.AnimeTimelineVM timelineVM; + private AnimeTimelineViewModel m_viewModel; + public TimelinePage() { this.InitializeComponent(); Title = "番剧时间表"; } + protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if(e.NavigationMode== NavigationMode.New) { - timelineVM = new AnimeTimelineVM((AnimeType)e.Parameter); - this.DataContext = timelineVM; + m_viewModel = App.ServiceProvider.GetRequiredService(); + m_viewModel.Init((AnimeType)e.Parameter); + this.DataContext = m_viewModel; // timeLine.ItemsSource = e.Parameter as List; // timeLine.SelectedItem = (e.Parameter as List).FirstOrDefault(x => x.is_today); } @@ -40,8 +45,8 @@ private async void cbType_SelectionChanged(object sender, SelectionChangedEventA { return; } - timelineVM.animeType = (cbType.SelectedItem as AnimeTypeItem).AnimeType; - await timelineVM.GetTimeline(); + m_viewModel.AnimeType = (cbType.SelectedItem as AnimeTypeItem).AnimeType; + await m_viewModel.GetTimeline(); } private void AdaptiveGridView_ItemClick(object sender, ItemClickEventArgs e) diff --git a/src/BiliLite.UWP/Pages/Home/AnimePage.xaml.cs b/src/BiliLite.UWP/Pages/Home/AnimePage.xaml.cs index 2b4c6cbb..3a7da6d6 100644 --- a/src/BiliLite.UWP/Pages/Home/AnimePage.xaml.cs +++ b/src/BiliLite.UWP/Pages/Home/AnimePage.xaml.cs @@ -1,7 +1,6 @@ using BiliLite.Extensions; using BiliLite.Models; using BiliLite.Models.Common; -using BiliLite.Modules; using BiliLite.Services; using System; using System.Threading.Tasks; @@ -9,6 +8,7 @@ using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; using BiliLite.Models.Common.Anime; +using BiliLite.Models.Common.Season; using BiliLite.ViewModels.Home; using Microsoft.Extensions.DependencyInjection; @@ -128,7 +128,7 @@ private void btnOpenIndex_Click(object sender, RoutedEventArgs e) title = animeType == AnimeType.Bangumi ? "番剧索引" : "国创索引", parameters = new SeasonIndexParameter() { - type = animeType == AnimeType.Bangumi ? IndexSeasonType.Anime : IndexSeasonType.Guochuang + Type = animeType == AnimeType.Bangumi ? IndexSeasonType.Anime : IndexSeasonType.Guochuang } }); } diff --git a/src/BiliLite.UWP/Pages/Home/MoviePage.xaml.cs b/src/BiliLite.UWP/Pages/Home/MoviePage.xaml.cs index 6cd10ef0..70d19414 100644 --- a/src/BiliLite.UWP/Pages/Home/MoviePage.xaml.cs +++ b/src/BiliLite.UWP/Pages/Home/MoviePage.xaml.cs @@ -1,7 +1,6 @@ using BiliLite.Extensions; using BiliLite.Models; using BiliLite.Models.Common; -using BiliLite.Modules; using BiliLite.Services; using System; using System.Threading.Tasks; @@ -9,6 +8,7 @@ using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; using BiliLite.Models.Common.Home; +using BiliLite.Models.Common.Season; using BiliLite.ViewModels.Home; using Microsoft.Extensions.DependencyInjection; @@ -110,7 +110,7 @@ private void OpenDocumentaryIndex_Click(object sender, RoutedEventArgs e) title = "纪录片索引", parameters = new SeasonIndexParameter() { - type = IndexSeasonType.Documentary + Type = IndexSeasonType.Documentary } }); } @@ -124,7 +124,7 @@ private void OpenMovieIndex_Click(object sender, RoutedEventArgs e) title = "电影索引", parameters = new SeasonIndexParameter() { - type = IndexSeasonType.Movie + Type = IndexSeasonType.Movie } }); } @@ -138,7 +138,7 @@ private void OpenTVIndex_Click(object sender, RoutedEventArgs e) title = "电视剧索引", parameters = new SeasonIndexParameter() { - type = IndexSeasonType.TV + Type = IndexSeasonType.TV } }); } @@ -168,7 +168,7 @@ private void OpenVarietyIndex_Click(object sender, RoutedEventArgs e) title = "综艺索引", parameters = new SeasonIndexParameter() { - type = IndexSeasonType.Variety + Type = IndexSeasonType.Variety } }); } diff --git a/src/BiliLite.UWP/Pages/Other/FindMorePage.xaml b/src/BiliLite.UWP/Pages/Other/FindMorePage.xaml index 71280f40..7bcda15d 100644 --- a/src/BiliLite.UWP/Pages/Other/FindMorePage.xaml +++ b/src/BiliLite.UWP/Pages/Other/FindMorePage.xaml @@ -7,8 +7,9 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" - xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls" xmlns:modules="using:BiliLite.Modules.Other" - Background="Transparent"> + xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls" + xmlns:other="using:BiliLite.Models.Common.Other" + Background="Transparent"> @@ -28,17 +29,17 @@ - + - + - - 《SPY×FAMILY 間諜家家酒》、《輝夜姬想讓人告白》、《派對咖孔明》、《街角的魔族女孩》 + + 《SPY×FAMILY 間諜家家酒》、《輝夜姬想讓人告白》、《派對咖孔明》、《街角的魔族女孩》 @@ -47,6 +48,6 @@ - + diff --git a/src/BiliLite.UWP/Pages/Other/FindMorePage.xaml.cs b/src/BiliLite.UWP/Pages/Other/FindMorePage.xaml.cs index c461ee71..f6c84685 100644 --- a/src/BiliLite.UWP/Pages/Other/FindMorePage.xaml.cs +++ b/src/BiliLite.UWP/Pages/Other/FindMorePage.xaml.cs @@ -1,21 +1,12 @@ using BiliLite.Models.Common; -using BiliLite.Modules.Other; using BiliLite.Services; using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; using Windows.System; -using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; +using BiliLite.Models.Common.Other; +using BiliLite.ViewModels.Other; +using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -26,36 +17,37 @@ namespace BiliLite.Pages.Other /// public sealed partial class FindMorePage : BasePage { - readonly FindMoreVM findMoreVM; + private readonly FindMoreViewModel m_viewModel; public FindMorePage() { + m_viewModel = App.ServiceProvider.GetRequiredService(); this.InitializeComponent(); - findMoreVM=new FindMoreVM(); } + protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); - if (e.NavigationMode == NavigationMode.New && findMoreVM.Items == null) + if (e.NavigationMode == NavigationMode.New && m_viewModel.Items == null) { - findMoreVM.LoadEntrance(); + m_viewModel.LoadEntrance(); } } private async void AdaptiveGridView_ItemClick(object sender, ItemClickEventArgs e) { var item = e.ClickedItem as FindMoreEntranceModel; - if (item.type == 0) + if (item.Type == 0) { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon =Symbol.Link, - title =item.name, + title =item.Name, page=typeof(WebPage), - parameters=item.link + parameters=item.Link }); } - else if(item.type == 1) + else if(item.Type == 1) { - await Launcher.LaunchUriAsync(new Uri(item.link)); + await Launcher.LaunchUriAsync(new Uri(item.Link)); } } diff --git a/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml b/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml index 491ddad2..7dec89df 100644 --- a/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml +++ b/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml @@ -9,9 +9,9 @@ xmlns:fa="using:FontAwesome5" xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls" xmlns:convert="using:BiliLite.Converters" - xmlns:modules="using:BiliLite.Modules" - xmlns:control="using:BiliLite.Controls" xmlns:season="using:BiliLite.Modules.Season" - xmlns:season1="using:BiliLite.Models.Common.Season" + xmlns:control="using:BiliLite.Controls" + xmlns:model="using:BiliLite.Models.Common.Season" + xmlns:viewModel="using:BiliLite.ViewModels.Season" Background="Transparent" SizeChanged="SeasonDetailPage_OnSizeChanged"> @@ -215,7 +215,7 @@ - + @@ -241,7 +241,7 @@ - + @@ -272,7 +272,7 @@ - + @@ -310,7 +310,7 @@ - + @@ -327,7 +327,7 @@ - + @@ -350,7 +350,7 @@ - + @@ -365,7 +365,7 @@ - + @@ -375,7 +375,7 @@ - + @@ -383,35 +383,35 @@ xiaoyaocz --> - - + + - + - + - - + - - + @@ -432,10 +432,10 @@ - + 加载更多 - + diff --git a/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs index 1e263109..43e6d95e 100644 --- a/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs @@ -2,7 +2,6 @@ using BiliLite.Dialogs; using BiliLite.Models.Requests.Api; using BiliLite.Modules; -using BiliLite.Modules.Season; using Microsoft.UI.Xaml.Controls; using System; using System.Collections.Generic; @@ -37,20 +36,20 @@ public sealed partial class SeasonDetailPage : PlayPage { private static readonly ILogger logger = GlobalLogger.FromCurrentType(); - SeasonDetailPageViewModel m_viewModel; - SeasonReviewVM seasonReviewVM; + private readonly SeasonDetailPageViewModel m_viewModel; + private readonly SeasonReviewViewModel m_seasonReviewViewModel; string season_id = ""; string ep_id = ""; bool selectProview = false; public SeasonDetailPage() { + m_viewModel = App.ServiceProvider.GetRequiredService(); + m_seasonReviewViewModel = App.ServiceProvider.GetRequiredService(); this.InitializeComponent(); Title = "剧集详情"; this.Loaded += SeasonDetailPage_Loaded; this.Player = this.player; NavigationCacheMode = NavigationCacheMode.Enabled; - m_viewModel = new SeasonDetailPageViewModel(); - seasonReviewVM = new SeasonReviewVM(); DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView(); dataTransferManager.DataRequested += DataTransferManager_DataRequested; m_viewModel.DefaultRightInfoWidth = new GridLength(SettingService.GetValue(SettingConstants.UI.RIGHT_DETAIL_WIDTH, 320), GridUnitType.Pixel); @@ -134,7 +133,7 @@ private async Task InitSeasonDetail() ChangeTitle(m_viewModel.Detail.Title); - seasonReviewVM.MediaID = m_viewModel.Detail.MediaId; + m_seasonReviewViewModel.MediaID = m_viewModel.Detail.MediaId; InitializePlayInfo(); await CreateQR(); @@ -423,8 +422,8 @@ private void btnOpenIndexWithArea_Click(object sender, RoutedEventArgs e) title = data.Name, parameters = new SeasonIndexParameter() { - type = (IndexSeasonType)m_viewModel.Detail.Type, - area = data.Id + Type = (IndexSeasonType)m_viewModel.Detail.Type, + Area = data.Id } }); } @@ -440,43 +439,43 @@ private void btnOpenIndexWithStyle_Click(object sender, RoutedEventArgs e) title = data.Name, parameters = new SeasonIndexParameter() { - type = (IndexSeasonType)m_viewModel.Detail.Type, - style = data.Id + Type = (IndexSeasonType)m_viewModel.Detail.Type, + Style = data.Id } }); } private async void pivot_SelectionChanged(object sender, SelectionChangedEventArgs e) { - if (pivot.SelectedIndex == 3 && (seasonReviewVM.Items == null || seasonReviewVM.Items.Count == 0)) + if (pivot.SelectedIndex == 3 && (m_seasonReviewViewModel.Items == null || m_seasonReviewViewModel.Items.Count == 0)) { - await seasonReviewVM.GetItems(); + await m_seasonReviewViewModel.GetItems(); } } private void btnReviewLike_Click(object sender, RoutedEventArgs e) { - var item = (sender as HyperlinkButton).DataContext as SeasonShortReviewItemModel; - seasonReviewVM.Like(item); + var item = (sender as HyperlinkButton).DataContext as SeasonShortReviewItemViewModel; + m_seasonReviewViewModel.Like(item); } private void btnReviewDislike_Click(object sender, RoutedEventArgs e) { - var item = (sender as HyperlinkButton).DataContext as SeasonShortReviewItemModel; - seasonReviewVM.Dislike(item); + var item = (sender as HyperlinkButton).DataContext as SeasonShortReviewItemViewModel; + m_seasonReviewViewModel.Dislike(item); } private async void btnSendReview_Click(object sender, RoutedEventArgs e) { - if (seasonReviewVM == null || seasonReviewVM.MediaID == 0) return; + if (m_seasonReviewViewModel == null || m_seasonReviewViewModel.MediaID == 0) return; if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) { Notify.ShowMessageToast("请先登录后再操作"); return; } - SendReviewDialog sendReviewDialog = new SendReviewDialog(seasonReviewVM.MediaID); + SendReviewDialog sendReviewDialog = new SendReviewDialog(m_seasonReviewViewModel.MediaID); await sendReviewDialog.ShowAsync(); } diff --git a/src/BiliLite.UWP/Pages/User/FavoriteDetailPage.xaml b/src/BiliLite.UWP/Pages/User/FavoriteDetailPage.xaml index 782a2c04..9f7b6007 100644 --- a/src/BiliLite.UWP/Pages/User/FavoriteDetailPage.xaml +++ b/src/BiliLite.UWP/Pages/User/FavoriteDetailPage.xaml @@ -11,7 +11,7 @@ xmlns:fa="using:FontAwesome5" xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls" xmlns:convert="using:BiliLite.Converters" - xmlns:model="using:BiliLite.Modules" + xmlns:favorites="using:BiliLite.Models.Common.Favorites" Background="Transparent"> - + @@ -36,12 +36,12 @@ --> - + - - UP: - 播放: 弹幕: + + UP: + 播放: 弹幕: @@ -57,37 +57,37 @@ - - 创建者:,共个视频 + + 创建者:,共个视频 - + - - + + - - 全选/反选 - - + + 全选/反选 + + - + - - + 加载更多 - + - 这里还什么都没有呢~ + 这里还什么都没有呢~ - + diff --git a/src/BiliLite.UWP/Pages/User/FavoriteDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/User/FavoriteDetailPage.xaml.cs index 98f9bf52..da65a965 100644 --- a/src/BiliLite.UWP/Pages/User/FavoriteDetailPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/User/FavoriteDetailPage.xaml.cs @@ -1,7 +1,6 @@ using BiliLite.Dialogs; using BiliLite.Extensions; using BiliLite.Models.Common; -using BiliLite.Modules; using BiliLite.Services; using System; using System.Collections.Generic; @@ -11,7 +10,10 @@ using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Navigation; +using BiliLite.Models.Common.Favorites; using BiliLite.Models.Common.Video; +using BiliLite.ViewModels.Favourites; +using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -27,25 +29,25 @@ public class FavoriteDetailArgs /// public sealed partial class FavoriteDetailPage : BasePage, IRefreshablePage { - FavoriteDetailVM favoriteDetailVM; + private readonly FavoriteDetailViewModel m_viewModel; public FavoriteDetailPage() { + m_viewModel = App.ServiceProvider.GetRequiredService(); this.InitializeComponent(); Title = "收藏夹详情"; - favoriteDetailVM = new FavoriteDetailVM(); } protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); - if (e.NavigationMode == NavigationMode.New && favoriteDetailVM.FavoriteInfo == null) + if (e.NavigationMode == NavigationMode.New && m_viewModel.FavoriteInfo == null) { FavoriteDetailArgs args = e.Parameter as FavoriteDetailArgs; - favoriteDetailVM.Id = args.Id; - favoriteDetailVM.Type = args.Type; - favoriteDetailVM.Page = 1; - favoriteDetailVM.Keyword = ""; - await favoriteDetailVM.LoadFavoriteInfo(); + m_viewModel.Id = args.Id; + m_viewModel.Type = args.Type; + m_viewModel.Page = 1; + m_viewModel.Keyword = ""; + await m_viewModel.LoadFavoriteInfo(); } } @@ -67,8 +69,8 @@ private void FavoriteInfoVideoItemModelOpen(object sender, FavoriteInfoVideoItem { icon = Symbol.Play, page = typeof(VideoDetailPage), - title = item.title, - parameters = item.id, + title = item.Title, + parameters = item.Id, dontGoTo = dontGoTo }); } @@ -83,7 +85,7 @@ private void Video_ItemPressed(object sender, PointerRoutedEventArgs e) private void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) { - favoriteDetailVM.Search(searchBox.Text); + m_viewModel.Search(searchBox.Text); } private void CheckBox_Checked(object sender, RoutedEventArgs e) @@ -109,7 +111,7 @@ private async void btnDelete_Click(object sender, RoutedEventArgs e) { ls.Add(item); } - await favoriteDetailVM.Delete(ls); + await m_viewModel.Delete(ls); } } @@ -122,9 +124,9 @@ private async void btnMove_Click(object sender, RoutedEventArgs e) { ls.Add(item); } - CopyOrMoveFavVideoDialog copyOrMoveFavVideoDialog = new CopyOrMoveFavVideoDialog(favoriteDetailVM.Id, favoriteDetailVM.FavoriteInfo.mid, true, ls); + CopyOrMoveFavVideoDialog copyOrMoveFavVideoDialog = new CopyOrMoveFavVideoDialog(m_viewModel.Id, m_viewModel.FavoriteInfo.Mid, true, ls); await copyOrMoveFavVideoDialog.ShowAsync(); - favoriteDetailVM.Refresh(); + m_viewModel.Refresh(); } } @@ -137,7 +139,7 @@ private async void btnCopy_Click(object sender, RoutedEventArgs e) { ls.Add(item); } - CopyOrMoveFavVideoDialog copyOrMoveFavVideoDialog = new CopyOrMoveFavVideoDialog(favoriteDetailVM.Id, favoriteDetailVM.FavoriteInfo.mid, false, ls); + CopyOrMoveFavVideoDialog copyOrMoveFavVideoDialog = new CopyOrMoveFavVideoDialog(m_viewModel.Id, m_viewModel.FavoriteInfo.Mid, false, ls); await copyOrMoveFavVideoDialog.ShowAsync(); } } @@ -149,37 +151,37 @@ private async void btnClean_Click(object sender, RoutedEventArgs e) return; } - await favoriteDetailVM.Clean(); + await m_viewModel.Clean(); } private void AddToWatchLater_Click(object sender, RoutedEventArgs e) { var data = (sender as MenuFlyoutItem).DataContext as FavoriteInfoVideoItemModel; - Modules.User.WatchLaterVM.Instance.AddToWatchlater(data.id); + Modules.User.WatchLaterVM.Instance.AddToWatchlater(data.Id); } private async void PlayAll_Click(object sender, RoutedEventArgs e) { - if (favoriteDetailVM.ShowLoadMore) + if (m_viewModel.ShowLoadMore) { Notify.ShowMessageToast("正在读取全部视频,请稍后"); - while (favoriteDetailVM.ShowLoadMore) + while (m_viewModel.ShowLoadMore) { - await favoriteDetailVM.LoadFavoriteInfo(); + await m_viewModel.LoadFavoriteInfo(); } } List items = new List(); - foreach (var item in favoriteDetailVM.Videos) + foreach (var item in m_viewModel.Videos) { - if (item.title != "已失效视频") + if (item.Title != "已失效视频") { items.Add(new VideoPlaylistItem() { - Cover = item.cover, - Author = item.upper.name, - Id = item.id, - Title = item.title + Cover = item.Cover, + Author = item.Upper.Name, + Id = item.Id, + Title = item.Title }); } @@ -193,29 +195,29 @@ private async void PlayAll_Click(object sender, RoutedEventArgs e) { Index = 0, Playlist = items, - Title = $"收藏夹:{favoriteDetailVM.FavoriteInfo.title}" + Title = $"收藏夹:{m_viewModel.FavoriteInfo.Title}" } }); } public async Task Refresh() { - favoriteDetailVM.Refresh(); + m_viewModel.Refresh(); } private async void FavItemGridView_OnDragItemsCompleted(ListViewBase sender, DragItemsCompletedEventArgs args) { var item = args.Items.FirstOrDefault(); if (!(item is FavoriteInfoVideoItemModel favVideo)) return; - var endIndex = favoriteDetailVM.Videos.IndexOf(favVideo); + var endIndex = m_viewModel.Videos.IndexOf(favVideo); var targetId = ""; if (endIndex != 0) { - var target = favoriteDetailVM.Videos[endIndex - 1]; - targetId = target.id; + var target = m_viewModel.Videos[endIndex - 1]; + targetId = target.Id; } - await favoriteDetailVM.Sort(favVideo.id, targetId); + await m_viewModel.Sort(favVideo.Id, targetId); } } } diff --git a/src/BiliLite.UWP/ViewModels/Favourites/FavoriteDetailViewModel.cs b/src/BiliLite.UWP/ViewModels/Favourites/FavoriteDetailViewModel.cs new file mode 100644 index 00000000..a54faa5c --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Favourites/FavoriteDetailViewModel.cs @@ -0,0 +1,364 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Input; +using Windows.UI.Xaml.Controls; +using BiliLite.Extensions; +using BiliLite.Models; +using BiliLite.Models.Attributes; +using BiliLite.Models.Common.Favorites; +using BiliLite.Models.Exceptions; +using BiliLite.Models.Requests.Api.User; +using BiliLite.Modules; +using BiliLite.Services; +using BiliLite.ViewModels.Common; +using PropertyChanged; + +namespace BiliLite.ViewModels.Favourites +{ + [RegisterTransientViewModel] + public class FavoriteDetailViewModel : BaseViewModel + { + #region Fields + + private readonly FavoriteApi m_favoriteApi; + private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); + + #endregion + + #region Constructors + + public FavoriteDetailViewModel() + { + m_favoriteApi = new FavoriteApi(); + RefreshCommand = new RelayCommand(Refresh); + LoadMoreCommand = new RelayCommand(LoadMore); + CollectCommand = new RelayCommand(DoCollect); + CancelCollectCommand = new RelayCommand(DoCancelCollect); + SelectCommand = new RelayCommand(SetSelectMode); + } + + #endregion + + #region Properties + + [DoNotNotify] + public ICommand CollectCommand { get; private set; } + + [DoNotNotify] + public ICommand CancelCollectCommand { get; private set; } + + [DoNotNotify] + public ICommand RefreshCommand { get; private set; } + + [DoNotNotify] + public ICommand LoadMoreCommand { get; private set; } + + [DoNotNotify] + public ICommand SelectCommand { get; private set; } + + [DoNotNotify] + public int Page { get; set; } = 1; + + [DoNotNotify] + public string Keyword { get; set; } = ""; + + [DoNotNotify] + public string Id { get; set; } + + [DoNotNotify] + public int Type { get; set; } + + public bool Loading { get; set; } + + public FavoriteInfoModel FavoriteInfo { get; set; } + + public ObservableCollection Videos { get; set; } + + public ListViewSelectionMode SelectionMode { get; set; } = ListViewSelectionMode.None; + + public bool IsItemClickEnabled { get; set; } = true; + + public bool Nothing { get; set; } + + public bool ShowLoadMore { get; set; } + + public bool IsSelf { get; set; } + + public bool ShowCollect { get; set; } + + public bool ShowCancelCollect { get; set; } + + #endregion + + #region Private Methods + + private void SetSelectMode(object data) + { + if (data == null) + { + IsItemClickEnabled = true; + SelectionMode = ListViewSelectionMode.None; + } + else + { + IsItemClickEnabled = false; + SelectionMode = ListViewSelectionMode.Multiple; + } + } + + private void LoadFavoriteInfoCore(ApiDataModel data) + { + if (Page == 1) + { + FavoriteInfo = data.data.Info; + IsSelf = FavoriteInfo.Mid == SettingService.Account.UserID.ToString(); + if (!IsSelf) + { + ShowCollect = FavoriteInfo.FavState != 1; + ShowCancelCollect = !ShowCollect; + } + + if (data.data.Medias == null || data.data.Medias.Count == 0) + { + Nothing = true; + return; + } + + Videos = new ObservableCollection(data.data.Medias); + } + else + { + if (data.data.Medias != null) + { + foreach (var item in data.data.Medias) + { + Videos.Add(item); + } + } + } + + if (Videos.Count != FavoriteInfo.MediaCount) + { + ShowLoadMore = true; + Page++; + } + } + + #endregion + + #region Public Methods + + public async Task LoadFavoriteInfo() + { + try + { + ShowLoadMore = false; + Loading = true; + Nothing = false; + var api = m_favoriteApi.FavoriteInfo(Id, Keyword, Page); + if (Type == 21) + { + api = m_favoriteApi.FavoriteSeasonInfo(Id, Keyword, Page); + } + var results = await api.Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = await results.GetJson>(); + if (!data.success) throw new CustomizedErrorException(data.message); + LoadFavoriteInfoCore(data); + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + finally + { + Loading = false; + } + } + + public async Task Delete(List items) + { + try + { + if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) + { + Notify.ShowMessageToast("请先登录后再操作"); + return; + } + var results = await m_favoriteApi.Delete(Id, items.Select(x => x.Id).ToList()).Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = await results.GetData(); + if (!data.success) throw new CustomizedErrorException(data.message); + foreach (var item in items) + { + Videos.Remove(item); + } + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + } + + public async Task Clean() + { + try + { + if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) + { + Notify.ShowMessageToast("请先登录后再操作"); + return; + } + var results = await m_favoriteApi.Clean(Id).Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = await results.GetData(); + if (!data.success) throw new CustomizedErrorException(data.message); + Refresh(); + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + } + + public async void Refresh() + { + if (Loading) + { + return; + } + Page = 1; + FavoriteInfo = null; + Videos = null; + await LoadFavoriteInfo(); + } + + public async Task Sort(string sourceId, string targetId) + { + try + { + var result = await m_favoriteApi.SortResource(Id, sourceId, targetId).Request(); + if (!result.status) throw new CustomizedErrorException("排序失败" + result.message); + + var data = await result.GetData(); + if (!data.success) throw new CustomizedErrorException("排序失败" + data.message); + Notify.ShowMessageToast("排序成功"); + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + } + + public async void LoadMore() + { + if (Loading) + { + return; + } + if (Videos == null || Videos.Count == 0) + { + return; + } + await LoadFavoriteInfo(); + } + + public async void Search(string keyword) + { + if (Loading) + { + return; + } + Keyword = keyword; + Page = 1; + FavoriteInfo = null; + Videos = null; + await LoadFavoriteInfo(); + } + + public async void DoCollect() + { + if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) + { + Notify.ShowMessageToast("请先登录后再操作"); + return; + } + try + { + var results = await m_favoriteApi.CollectFavorite(FavoriteInfo.Id).Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = await results.GetJson>(); + if (!data.success) throw new CustomizedErrorException(data.message); + ShowCancelCollect = true; + ShowCollect = false; + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + } + + public async void DoCancelCollect() + { + if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) + { + Notify.ShowMessageToast("请先登录后再操作"); + return; + } + try + { + var results = await m_favoriteApi.CacnelCollectFavorite(FavoriteInfo.Id).Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = await results.GetJson>(); + if (!data.success) throw new CustomizedErrorException(data.message); + ShowCancelCollect = false; + ShowCollect = true; + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + } + + #endregion + } +} diff --git a/src/BiliLite.UWP/ViewModels/Home/AnimePageViewModel.cs b/src/BiliLite.UWP/ViewModels/Home/AnimePageViewModel.cs index 9ba73c3a..26cc24ac 100644 --- a/src/BiliLite.UWP/ViewModels/Home/AnimePageViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Home/AnimePageViewModel.cs @@ -11,6 +11,7 @@ using BiliLite.Models; using BiliLite.Models.Common; using BiliLite.Models.Common.Anime; +using BiliLite.Models.Common.Season; using BiliLite.Models.Requests.Api.Home; using BiliLite.Models.Requests.Api.User; using BiliLite.Modules; @@ -108,8 +109,8 @@ public void SetAnimeType(AnimeType animeType) title="索引", parameters=new SeasonIndexParameter() { - type= IndexSeasonType.Anime, - area=m_animeType== AnimeType.Bangumi?"-1":"1,6,7" + Type= IndexSeasonType.Anime, + Area=m_animeType== AnimeType.Bangumi?"-1":"1,6,7" } } }, diff --git a/src/BiliLite.UWP/ViewModels/Home/CinemaViewModel.cs b/src/BiliLite.UWP/ViewModels/Home/CinemaViewModel.cs index e0997250..9d894cf8 100644 --- a/src/BiliLite.UWP/ViewModels/Home/CinemaViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Home/CinemaViewModel.cs @@ -11,6 +11,7 @@ using BiliLite.Models.Common; using BiliLite.Models.Common.Anime; using BiliLite.Models.Common.Home; +using BiliLite.Models.Common.Season; using BiliLite.Models.Exceptions; using BiliLite.Models.Requests.Api.Home; using BiliLite.Models.Requests.Api.User; @@ -62,7 +63,7 @@ public CinemaViewModel(IMapper mapper) title="电影索引", parameters=new SeasonIndexParameter() { - type= IndexSeasonType.Movie + Type= IndexSeasonType.Movie } } }, @@ -75,7 +76,7 @@ public CinemaViewModel(IMapper mapper) title="电视剧索引", parameters=new SeasonIndexParameter() { - type= IndexSeasonType.TV + Type= IndexSeasonType.TV } } }, @@ -88,7 +89,7 @@ public CinemaViewModel(IMapper mapper) title="纪录片索引", parameters=new SeasonIndexParameter() { - type= IndexSeasonType.Documentary + Type= IndexSeasonType.Documentary } } }, @@ -101,7 +102,7 @@ public CinemaViewModel(IMapper mapper) title="综艺索引", parameters=new SeasonIndexParameter() { - type= IndexSeasonType.Variety + Type= IndexSeasonType.Variety } } }, diff --git a/src/BiliLite.UWP/ViewModels/Other/FindMoreViewModel.cs b/src/BiliLite.UWP/ViewModels/Other/FindMoreViewModel.cs new file mode 100644 index 00000000..53391eb4 --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Other/FindMoreViewModel.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using BiliLite.Extensions; +using BiliLite.Models.Attributes; +using BiliLite.Models.Common.Other; +using BiliLite.Models.Requests.Api; +using BiliLite.ViewModels.Common; + +namespace BiliLite.ViewModels.Other +{ + [RegisterTransientViewModel] + public class FindMoreViewModel : BaseViewModel + { + private readonly GitApi m_gitApi; + + public FindMoreViewModel() + { + m_gitApi = new GitApi(); + } + + public bool Loading { get; set; } = true; + + public List Items { get; set; } + + public async void LoadEntrance() + { + try + { + Loading = true; + var results = await m_gitApi.FindMoreEntrance().Request(); + if (results.status) + { + var data = await results.GetJson>(); + await Task.Delay(2000); + Items = data; + } + else + { + Notify.ShowMessageToast(results.message); + + } + } + catch (Exception ex) + { + var handel = HandelError (ex); + Notify.ShowMessageToast(handel.message); + } + finally + { + Loading = false; + } + } + } +} diff --git a/src/BiliLite.UWP/ViewModels/Season/AnimeTimelineViewModel.cs b/src/BiliLite.UWP/ViewModels/Season/AnimeTimelineViewModel.cs new file mode 100644 index 00000000..669436c7 --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Season/AnimeTimelineViewModel.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using BiliLite.Extensions; +using BiliLite.Models; +using BiliLite.Models.Attributes; +using BiliLite.Models.Common; +using BiliLite.Models.Common.Anime; +using BiliLite.Models.Exceptions; +using BiliLite.Models.Requests.Api.Home; +using BiliLite.Services; +using BiliLite.ViewModels.Common; +using PropertyChanged; + +namespace BiliLite.ViewModels.Season +{ + [RegisterTransientViewModel] + public class AnimeTimelineViewModel : BaseViewModel + { + #region Fields + + private readonly AnimeAPI m_animeApi; + private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); + + #endregion + + #region Constructors + + public AnimeTimelineViewModel() + { + m_animeApi = new AnimeAPI(); + AnimeTypeItems = new List() + { + new AnimeTypeItem() + { + Name="番剧", + AnimeType= AnimeType.Bangumi + }, + new AnimeTypeItem() + { + Name="国创", + AnimeType= AnimeType.GuoChuang + } + }; + } + + #endregion + + #region Properties + + [DoNotNotify] + public AnimeType AnimeType { get; set; } + + public bool Loading { get; set; } = true; + + public List AnimeTypeItems { get; set; } + + public AnimeTypeItem SelectAnimeType { get; set; } + + public AnimeTimelineModel Today { get; set; } + + public List Timelines { get; set; } + + #endregion + + #region Public Methods + + public void Init(AnimeType type) + { + SelectAnimeType = AnimeTypeItems.FirstOrDefault(x => x.AnimeType == type); + AnimeType = type; + } + + public async Task GetTimeline() + { + try + { + Loading = true; + var api = m_animeApi.Timeline((int)AnimeType); + + var results = await api.Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = await results.GetJson>>(); + if (!data.success) throw new CustomizedErrorException(data.message); + Timelines = data.data; + Today = data.data.FirstOrDefault(x => x.IsToday); + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + finally + { + Loading = false; + } + } + + #endregion + } +} diff --git a/src/BiliLite.UWP/ViewModels/Season/SeasonDetailPageViewModel.cs b/src/BiliLite.UWP/ViewModels/Season/SeasonDetailPageViewModel.cs index b5be6711..5b916bb3 100644 --- a/src/BiliLite.UWP/ViewModels/Season/SeasonDetailPageViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Season/SeasonDetailPageViewModel.cs @@ -20,9 +20,11 @@ using Newtonsoft.Json.Linq; using PropertyChanged; using Windows.UI.Xaml.Media; +using BiliLite.Models.Attributes; namespace BiliLite.ViewModels.Season { + [RegisterTransientViewModel] public class SeasonDetailPageViewModel : BaseViewModel { #region Fields diff --git a/src/BiliLite.UWP/ViewModels/Season/SeasonIndexViewModel.cs b/src/BiliLite.UWP/ViewModels/Season/SeasonIndexViewModel.cs new file mode 100644 index 00000000..e5e09b3b --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Season/SeasonIndexViewModel.cs @@ -0,0 +1,244 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Input; +using BiliLite.Extensions; +using BiliLite.Models.Attributes; +using BiliLite.Models.Common.Season; +using BiliLite.Models.Exceptions; +using BiliLite.Models.Requests.Api; +using BiliLite.Modules; +using BiliLite.Services; +using BiliLite.ViewModels.Common; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PropertyChanged; + +namespace BiliLite.ViewModels.Season +{ + [RegisterTransientViewModel] + public class SeasonIndexViewModel : BaseViewModel + { + #region Fields + + private readonly SeasonIndexAPI m_seasonIndexApi; + private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); + private bool m_canLoadMore = true; + + #endregion + + #region Constructors + + public SeasonIndexViewModel() + { + m_seasonIndexApi = new SeasonIndexAPI(); + RefreshCommand = new RelayCommand(Refresh); + LoadMoreCommand = new RelayCommand(LoadMore); + } + + #endregion + + #region Properties + + [DoNotNotify] + public ICommand RefreshCommand { get; private set; } + + [DoNotNotify] + public ICommand LoadMoreCommand { get; private set; } + + [DoNotNotify] + public SeasonIndexParameter Parameter { get; set; } + + public bool Loading { get; set; } = true; + + public bool ConditionsLoading { get; set; } = true; + + public ObservableCollection Conditions { get; set; } + + public ObservableCollection Result { get; set; } + + public int Page { get; set; } + + #endregion + + #region Private Methods + + private void LoadConditionsCore(JObject data) + { + var items = + JsonConvert.DeserializeObject>( + data["data"]["filter"].ToString()); + foreach (var item in items) + { + item.Current = item.Field switch + { + "style_id" => item.Values.FirstOrDefault(x => x.Keyword == Parameter.Style), + "area" => item.Values.FirstOrDefault(x => x.Keyword == Parameter.Area), + "pub_date" => item.Values.FirstOrDefault(x => x.Keyword == Parameter.Year), + "season_month" => item.Values.FirstOrDefault(x => x.Keyword == Parameter.Month), + _ => item.Values.FirstOrDefault() + }; + } + + var orders = new List(); + + foreach (var item in data["data"]["order"]) + { + orders.Add(new SeasonIndexConditionFilterItemModel() + { + Keyword = item["field"].ToString(), + Name = item["name"].ToString() + }); + } + + items.Insert(0, new SeasonIndexConditionFilterModel() + { + Name = "排序", + Values = orders, + Field = "order", + Current = orders.FirstOrDefault(x => x.Name == Parameter.Order) ?? orders[0], + }); + Conditions = items; + } + + private void LoadResultCore(List items) + { + if (items != null && items.Count != 0) + { + if (Page == 1) + { + Result = new ObservableCollection(items); + } + else + { + foreach (var item in items) + { + Result.Add(item); + } + } + + Page++; + } + else + { + m_canLoadMore = false; + Notify.ShowMessageToast("加载完了"); + } + } + + #endregion + + #region Public Methods + + public async Task LoadConditions() + { + try + { + ConditionsLoading = true; + var results = await m_seasonIndexApi.Condition((int)Parameter.Type).Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = results.GetJObject(); + if (data["code"].ToInt32() != 0) throw new CustomizedErrorException(data["message"].ToString()); + LoadConditionsCore(data); + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + finally + { + ConditionsLoading = false; + } + } + + public async Task LoadResult() + { + try + { + if (Loading) return; + + if (Page == 1) + { + m_canLoadMore = true; + Result = null; + } + else + { + if (!m_canLoadMore) + { + Loading = false; + return; + } + } + Loading = true; + var con = ""; + foreach (var item in Conditions) + { + con += $"&{item.Field}={Uri.EscapeDataString(item.Current.Keyword)}"; + } + con += $"&sort=0"; + var results = await m_seasonIndexApi.Result(Page, (int)Parameter.Type, con).Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = results.GetJObject(); + if (data["code"].ToInt32() != 0) throw new CustomizedErrorException(data["message"].ToString()); + var items = JsonConvert.DeserializeObject>( + data["data"]["list"]?.ToString() ?? "[]"); + LoadResultCore(items); + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + finally + { + Loading = false; + } + } + + public async void Refresh() + { + if (Loading) + { + return; + } + Page = 1; + if (Conditions == null) + { + await LoadConditions(); + } + if (Conditions != null) + { + await LoadResult(); + } + } + + public async void LoadMore() + { + if (Loading) + { + return; + } + if (Conditions == null || Conditions.Count == 0 || Result == null || Result.Count == 0) + { + return; + } + await LoadResult(); + } + + #endregion + } +} diff --git a/src/BiliLite.UWP/ViewModels/Season/SeasonRankDataViewModel.cs b/src/BiliLite.UWP/ViewModels/Season/SeasonRankDataViewModel.cs new file mode 100644 index 00000000..1aebac2c --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Season/SeasonRankDataViewModel.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using BiliLite.Models.Common.Season; +using BiliLite.ViewModels.Common; +using PropertyChanged; + +namespace BiliLite.ViewModels.Season; + +public class SeasonRankDataViewModel : BaseViewModel +{ + [DoNotNotify] + public string Name { get; set; } + + [DoNotNotify] + public int Type { get; set; } + + public List Items { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/ViewModels/Season/SeasonRankViewModel.cs b/src/BiliLite.UWP/ViewModels/Season/SeasonRankViewModel.cs new file mode 100644 index 00000000..e0c09369 --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Season/SeasonRankViewModel.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using BiliLite.Extensions; +using BiliLite.Models; +using BiliLite.Models.Attributes; +using BiliLite.Models.Common.Season; +using BiliLite.Models.Exceptions; +using BiliLite.Models.Requests.Api; +using BiliLite.Services; +using BiliLite.ViewModels.Common; +using Newtonsoft.Json.Linq; + +namespace BiliLite.ViewModels.Season +{ + [RegisterTransientViewModel] + public class SeasonRankViewModel : BaseViewModel + { + #region Fields + + private readonly RankAPI m_rankApi; + private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); + + #endregion + + #region Constructors + + public SeasonRankViewModel() + { + m_rankApi = new RankAPI(); + } + + #endregion + + #region Properties + + public bool Loading { get; set; } = true; + + public SeasonRankDataViewModel Current { get; set; } + + public List RegionItems { get; set; } + + #endregion + + #region Public Methods + + public void LoadRankRegion(int type = 1) + { + RegionItems = new List() + { + new SeasonRankDataViewModel() + { + Name="热门番剧", + Type=1 + }, + new SeasonRankDataViewModel() + { + Name="热门国创", + Type=4 + }, + new SeasonRankDataViewModel() + { + Name="热门电影", + Type=2 + }, + new SeasonRankDataViewModel() + { + Name="热门纪录片", + Type=3 + }, + new SeasonRankDataViewModel() + { + Name="热门电视剧", + Type=5 + }, + new SeasonRankDataViewModel() + { + Name="热门综艺", + Type=7 + }, + }; + Current = RegionItems.FirstOrDefault(x => x.Type.Equals(type)); + } + + public async Task LoadRankDetail(SeasonRankDataViewModel region) + { + try + { + Loading = true; + var results = await m_rankApi.SeasonRank(region.Type).Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = await results.GetJson>(); + if (!data.success) throw new CustomizedErrorException(data.message); + var result = await data.data["list"].ToString().DeserializeJson>(); + region.Items = result; + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + finally + { + Loading = false; + } + } + + #endregion + } +} diff --git a/src/BiliLite.UWP/ViewModels/Season/SeasonReviewViewModel.cs b/src/BiliLite.UWP/ViewModels/Season/SeasonReviewViewModel.cs new file mode 100644 index 00000000..7dcfc642 --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Season/SeasonReviewViewModel.cs @@ -0,0 +1,239 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Threading.Tasks; +using System.Windows.Input; +using AutoMapper; +using BiliLite.Extensions; +using BiliLite.Models; +using BiliLite.Models.Attributes; +using BiliLite.Models.Common.Season; +using BiliLite.Models.Exceptions; +using BiliLite.Models.Requests.Api; +using BiliLite.Modules; +using BiliLite.Services; +using BiliLite.ViewModels.Common; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PropertyChanged; + +namespace BiliLite.ViewModels.Season +{ + [RegisterTransientViewModel] + public class SeasonReviewViewModel : BaseViewModel + { + #region Fields + + readonly SeasonApi m_seasonApi; + private readonly IMapper m_mapper; + private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); + + #endregion + + #region Constructors + + public SeasonReviewViewModel(IMapper mapper) + { + m_mapper = mapper; + Items = new ObservableCollection(); + m_seasonApi = new SeasonApi(); + RefreshCommand = new RelayCommand(Refresh); + LoadMoreCommand = new RelayCommand(LoadMore); + } + + #endregion + + #region Properties + + [DoNotNotify] + public ICommand RefreshCommand { get; private set; } + + [DoNotNotify] + public ICommand LoadMoreCommand { get; private set; } + + [DoNotNotify] + public ObservableCollection Items { get; set; } + + [DoNotNotify] + public int MediaID { get; set; } + + public bool Loading { get; set; } + + public bool CanLoadMore { get; set; } + + [DoNotNotify] + public string Next { get; set; } = ""; + + #endregion + + #region Private Methods + + private void GetItemsCore(JObject data) + { + var items = JsonConvert.DeserializeObject>(data["data"]["list"] + .ToString()); + if (items == null) return; + var dataItems = m_mapper.Map>(items); + Items.AddRange(dataItems); + //Items = new IncrementalLoadingCollection(new LiveRecommendItemSource(items, SortType), 30); + if (Items.Count >= data["data"]["total"].ToInt32()) return; + Next = data["data"]["next"].ToString(); + CanLoadMore = true; + } + + private void LikeCore(SeasonShortReviewItemViewModel item, ApiDataModel data) + { + item.Stat.Liked = data.data["status"].ToInt32(); + if (item.Stat.Liked == 1) + { + item.Stat.Likes += 1; + } + else + { + item.Stat.Likes -= 1; + } + } + + #endregion + + #region Public Methods + + public async Task GetItems() + { + try + { + if (MediaID == 0) { return; } + Loading = true; + CanLoadMore = false; + var results = await m_seasonApi.ShortReview(MediaID, Next).Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = results.GetJObject(); + if (data["code"].ToInt32() != 0) throw new CustomizedErrorException(data["message"].ToString()); + GetItemsCore(data); + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + finally + { + Loading = false; + } + } + + public async void Refresh() + { + if (Loading) + { + return; + } + Items.Clear(); + Next = ""; + await GetItems(); + } + public async void LoadMore() + { + if (Loading) + { + return; + } + await GetItems(); + } + + public async void Like(SeasonShortReviewItemViewModel item) + { + if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) + { + Notify.ShowMessageToast("请先登录后再操作"); + return; + } + try + { + var api = m_seasonApi.LikeReview(MediaID, item.ReviewId, ReviewType.Short); + var results = await api.Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = await results.GetJson>(); + if (!data.success) throw new CustomizedErrorException(data.message); + LikeCore(item, data); + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + } + + public async void Dislike(SeasonShortReviewItemViewModel item) + { + if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) + { + Notify.ShowMessageToast("请先登录后再操作"); + return; + } + try + { + var api = m_seasonApi.DislikeReview(MediaID, item.ReviewId, ReviewType.Short); + var results = await api.Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = await results.GetJson>(); + if (!data.success) throw new CustomizedErrorException(data.message); + item.Stat.Disliked = data.data["status"].ToInt32(); + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + } + + } + + public async Task SendShortReview(string content, bool share, int score) + { + if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) + { + Notify.ShowMessageToast("请先登录后再操作"); + return false; + } + try + { + var api = m_seasonApi.SendShortReview(MediaID, content, share, score); + var results = await api.Request(); + if (!results.status) throw new CustomizedErrorException(results.message); + var data = await results.GetJson>(); + if (!data.success) throw new CustomizedErrorException(data.message); + Notify.ShowMessageToast("发表成功"); + return true; + } + catch (CustomizedErrorException ex) + { + Notify.ShowMessageToast(ex.Message); + _logger.Error(ex.Message, ex); + return false; + } + catch (Exception ex) + { + var handel = HandelError(ex); + Notify.ShowMessageToast(handel.message); + return false; + } + } + + #endregion + } +} diff --git a/src/BiliLite.UWP/ViewModels/Season/SeasonShortReviewItemStatViewModel.cs b/src/BiliLite.UWP/ViewModels/Season/SeasonShortReviewItemStatViewModel.cs new file mode 100644 index 00000000..a85071c1 --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Season/SeasonShortReviewItemStatViewModel.cs @@ -0,0 +1,21 @@ +using BiliLite.ViewModels.Common; + +namespace BiliLite.ViewModels.Season; + +public class SeasonShortReviewItemStatViewModel : BaseViewModel +{ + /// + /// 是否已经点踩👎 + /// + public int Disliked { get; set; } + + /// + /// 是否已经点赞👍 + /// + public int Liked { get; set; } + + /// + /// 点赞数量 + /// + public int Likes { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/ViewModels/Season/SeasonShortReviewItemViewModel.cs b/src/BiliLite.UWP/ViewModels/Season/SeasonShortReviewItemViewModel.cs new file mode 100644 index 00000000..dcb7b40e --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Season/SeasonShortReviewItemViewModel.cs @@ -0,0 +1,27 @@ +using BiliLite.Models.Common.Season; + +namespace BiliLite.ViewModels.Season; + +public class SeasonShortReviewItemViewModel +{ + public long Ctime { get; set; } + + public long Mid { get; set; } + + public int ReviewId { get; set; } + + public string Content { get; set; } + + public string Progress { get; set; } + + public int Score { get; set; } + + /// + /// 评分,转为5分制 + /// + public int Score5 => Score / 2; + + public SeasonShortReviewItemAuthorModel Author { get; set; } + + public SeasonShortReviewItemStatViewModel Stat { get; set; } +} \ No newline at end of file From ea13e5aef60a55416bebedd76e64bb9ec39f6f53 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Wed, 11 Dec 2024 22:45:42 +0800 Subject: [PATCH 11/17] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dx64=20native=E7=BC=96?= =?UTF-8?q?=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 497 +++++++++++++++++----------------- scripts/setNative.ps1 | 47 ++++ 2 files changed, 293 insertions(+), 251 deletions(-) create mode 100644 scripts/setNative.ps1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c32b160f..ae41e059 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,32 +3,32 @@ name: Release on: workflow_dispatch: inputs: - version: - description: '版本号' + version: + description: "版本号" required: true - default: '0.0.0.0' + default: "0.0.0.0" enableX64: - description: '启用x64' + description: "启用x64" required: true default: true type: boolean enableX64Native: - description: '启用x64Native' + description: "启用x64Native" required: true default: true type: boolean enableX86: - description: '启用x86' + description: "启用x86" required: true default: false type: boolean enableArm64: - description: '启用Arm64' + description: "启用Arm64" required: true default: true type: boolean enableArm32: - description: '启用Arm32' + description: "启用Arm32" required: true default: false type: boolean @@ -53,246 +53,241 @@ jobs: nuget_package: biliuwp-lite-nuget-packages.zip steps: - - - name: Configure Pagefile - uses: al-cheb/configure-pagefile-action@v1.2 - with: - minimum-size: 32GB - maximum-size: 32GB - disk-root: "C:" - - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: EchoInput - run: | - echo 启用x64编译 ${{ github.event.inputs.enableX64 }} - echo 启用x86编译 ${{ github.event.inputs.enableX86 }} - echo 启用Arm64编译 ${{ github.event.inputs.enableArm64 }} - echo 启用Arm编译 ${{ github.event.inputs.enableArm32 }} - - - name: Download and process necessary files - run: | - curl --location $env:Webdav_addr --header "$env:Webdav_auth" -o "$env:UWP_Project_Directory/$env:SigningCertificate" --insecure - curl --location $env:nuget_package_addr --header "$env:Webdav_auth" -o "$env:nuget_package" --insecure - Expand-Archive -path $env:nuget_package -DestinationPath ./ - cp -r ./packages ./src/ - - - uses: release-drafter/release-drafter@v5 - name: Create release draft - id: release-drafter - - - name: Setup MSBuild.exe - uses: microsoft/setup-msbuild@v1.0.3 - - - name: Windows SDK Install - uses: ChristopheLav/windows-sdk-install@v1.0.1 - with: - version-sdk: 18362 - features: 'OptionId.WindowsPerformanceToolkit,OptionId.WindowsDesktopDebuggers,OptionId.AvrfExternal,OptionId.NetFxSoftwareDevelopmentKit,OptionId.WindowsSoftwareLogoToolkit,OptionId.IpOverUsb,OptionId.MSIInstallTools,OptionId.SigningTools,OptionId.UWPManaged,OptionId.UWPCPP,OptionId.UWPLocalized,OptionId.DesktopCPPx86,OptionId.DesktopCPPx64,OptionId.DesktopCPParm,OptionId.DesktopCPParm64' - - - name: Update manifest version - run: | - [xml]$manifest = get-content ".\$env:UWP_Project_Directory\Package.appxmanifest" - $manifest.Package.Identity.Version = "${{github.event.inputs.version}}" - $manifest.save(".\$env:UWP_Project_Directory\Package.appxmanifest") - - - name: Create Package Directory - run: New-Item -ItemType Directory -Path C:\Package - - - name: document processing - run: | - git clone https://github.com/ywmoyue/OnlinePageToPDF-Node.git - cd OnlinePageToPDF-Node - npm install - node index.js --waitTime=35000 --pageUrl="http://markdown.muyan233.top:352/?fileUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fywmoyue%2Fbiliuwp-lite%2Fdev%2Fdocument%2Finstall-readme.md" --pdfFilePath="安装教程.pdf" - cd .. - cp ./OnlinePageToPDF-Node/安装教程.pdf C:\Package\安装教程.pdf - - - name: Build x64 - run: | - msbuild $env:UWP_Project_Directory /p:Platform=x64 /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore - env: - BuildMode: SideloadOnly - Configuration: Release - if: github.event.inputs.enableX64 == 'true' - - - name: copy x64 document - run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test\安装教程.pdf - if: github.event.inputs.enableX64 == 'true' - - - name: Remove x64 useless files - run: | - cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test - rm -r -fo *.appxsym - cd Dependencies - rm -r -fo arm,arm64,x86 - if: github.event.inputs.enableX64 == 'true' - - - name: Create x64 archive - run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x64.zip - if: github.event.inputs.enableX64 == 'true' - - - name: Update x64 release asset - id: upload-release-asset-x64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} - if: github.event.inputs.enableX64 == 'true' - with: - upload_url: ${{ steps.release-drafter.outputs.upload_url }} - asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x64.zip - asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_x64.zip - asset_content_type: application/zip - - - - - name: Set x64 native - run: | - rm $env:UWP_Project_Path - cp $env:UWP_X64_Native_Project_Path $env:UWP_Project_Path - if: github.event.inputs.enableX64Native == 'true' - - - name: Build x64 native - run: | - msbuild $env:UWP_Project_Directory /p:Platform=x64 /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore - env: - BuildMode: SideloadOnly - Configuration: Release - if: github.event.inputs.enableX64Native == 'true' - - - name: copy x64 native document - run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test\安装教程.pdf - if: github.event.inputs.enableX64Native == 'true' - - - name: Remove x64 native useless files - run: | - cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test - rm -r -fo *.appxsym - cd Dependencies - rm -r -fo arm,arm64,x86 - if: github.event.inputs.enableX64Native == 'true' - - - name: Create x64 native archive - run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x64_native.zip - if: github.event.inputs.enableX64Native == 'true' - - - name: Update x64 native release asset - id: upload-release-asset-x64-native - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} - if: github.event.inputs.enableX64Native == 'true' - with: - upload_url: ${{ steps.release-drafter.outputs.upload_url }} - asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x64_native.zip - asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_x64_native.zip - asset_content_type: application/zip - - - - name: Build x86 - run: msbuild $env:UWP_Project_Directory /p:Platform=x86 /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore - if: github.event.inputs.enableX86 == 'true' - env: - BuildMode: SideloadOnly - Configuration: Release - - - name: copy x86 document - run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x86_Test\安装教程.pdf - if: github.event.inputs.enableX86 == 'true' - - - name: Remove x86 useless files - run: | - cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x86_Test - rm -r -fo *.appxsym - cd Dependencies - rm -r -fo arm,arm64,x64 - if: github.event.inputs.enableX86 == 'true' - - - name: Create x86 archive - run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x86_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x86.zip - if: github.event.inputs.enableX86 == 'true' - - - name: Update x86 release asset - id: upload-release-asset-x86 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} - if: github.event.inputs.enableX86 == 'true' - with: - upload_url: ${{ steps.release-drafter.outputs.upload_url }} - asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x86.zip - asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_x86.zip - asset_content_type: application/zip - - - name: Build ARM64 - run: msbuild $env:UWP_Project_Directory /p:Platform=ARM64 /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore - if: github.event.inputs.enableArm64 == 'true' - env: - BuildMode: SideloadOnly - Configuration: Release - - - name: copy arm64 document - run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM64_Test\安装教程.pdf - if: github.event.inputs.enableArm64 == 'true' - - - name: Remove arm64 useless files - run: | - cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM64_Test - rm -r -fo *.appxsym - cd Dependencies - rm -r -fo arm,x64,x86 - if: github.event.inputs.enableArm64 == 'true' - - - name: Create ARM64 archive - run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM64_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_ARM64.zip - if: github.event.inputs.enableArm64 == 'true' - - - name: Update ARM64 release asset - id: upload-release-asset-ARM64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} - if: github.event.inputs.enableArm64 == 'true' - with: - upload_url: ${{ steps.release-drafter.outputs.upload_url }} - asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_ARM64.zip - asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_ARM64.zip - asset_content_type: application/zip - - - name: Build ARM32 - run: msbuild $env:UWP_Project_Directory /p:Platform=ARM /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore - if: github.event.inputs.enableArm32 == 'true' - env: - BuildMode: SideloadOnly - Configuration: Release - - - name: copy arm32 document - run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM_Test\安装教程.pdf - if: github.event.inputs.enableArm32 == 'true' - - - name: Remove arm32 useless files - run: | - cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM_Test - rm -r -fo *.appxsym - cd Dependencies - rm -r -fo arm64,x64,x86 - if: github.event.inputs.enableArm32 == 'true' - - - name: Create ARM32 archive - run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_ARM.zip - if: github.event.inputs.enableArm32 == 'true' - - - name: Update ARM32 release asset - id: upload-release-asset-ARM32 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} - if: github.event.inputs.enableArm32 == 'true' - with: - upload_url: ${{ steps.release-drafter.outputs.upload_url }} - asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_ARM.zip - asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_ARM.zip - asset_content_type: application/zip + - name: Configure Pagefile + uses: al-cheb/configure-pagefile-action@v1.2 + with: + minimum-size: 32GB + maximum-size: 32GB + disk-root: "C:" + + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: EchoInput + run: | + echo 启用x64编译 ${{ github.event.inputs.enableX64 }} + echo 启用x86编译 ${{ github.event.inputs.enableX86 }} + echo 启用Arm64编译 ${{ github.event.inputs.enableArm64 }} + echo 启用Arm编译 ${{ github.event.inputs.enableArm32 }} + + - name: Download and process necessary files + run: | + curl --location $env:Webdav_addr --header "$env:Webdav_auth" -o "$env:UWP_Project_Directory/$env:SigningCertificate" --insecure + curl --location $env:nuget_package_addr --header "$env:Webdav_auth" -o "$env:nuget_package" --insecure + Expand-Archive -path $env:nuget_package -DestinationPath ./ + cp -r ./packages ./src/ + + - uses: release-drafter/release-drafter@v5 + name: Create release draft + id: release-drafter + + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v1.0.3 + + - name: Windows SDK Install + uses: ChristopheLav/windows-sdk-install@v1.0.1 + with: + version-sdk: 18362 + features: "OptionId.WindowsPerformanceToolkit,OptionId.WindowsDesktopDebuggers,OptionId.AvrfExternal,OptionId.NetFxSoftwareDevelopmentKit,OptionId.WindowsSoftwareLogoToolkit,OptionId.IpOverUsb,OptionId.MSIInstallTools,OptionId.SigningTools,OptionId.UWPManaged,OptionId.UWPCPP,OptionId.UWPLocalized,OptionId.DesktopCPPx86,OptionId.DesktopCPPx64,OptionId.DesktopCPParm,OptionId.DesktopCPParm64" + + - name: Update manifest version + run: | + [xml]$manifest = get-content ".\$env:UWP_Project_Directory\Package.appxmanifest" + $manifest.Package.Identity.Version = "${{github.event.inputs.version}}" + $manifest.save(".\$env:UWP_Project_Directory\Package.appxmanifest") + + - name: Create Package Directory + run: New-Item -ItemType Directory -Path C:\Package + + - name: document processing + run: | + git clone https://github.com/ywmoyue/OnlinePageToPDF-Node.git + cd OnlinePageToPDF-Node + npm install + node index.js --waitTime=35000 --pageUrl="http://markdown.muyan233.top:352/?fileUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fywmoyue%2Fbiliuwp-lite%2Fdev%2Fdocument%2Finstall-readme.md" --pdfFilePath="安装教程.pdf" + cd .. + cp ./OnlinePageToPDF-Node/安装教程.pdf C:\Package\安装教程.pdf + + - name: Build x64 + run: | + msbuild $env:UWP_Project_Directory /p:Platform=x64 /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore + env: + BuildMode: SideloadOnly + Configuration: Release + if: github.event.inputs.enableX64 == 'true' + + - name: copy x64 document + run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test\安装教程.pdf + if: github.event.inputs.enableX64 == 'true' + + - name: Remove x64 useless files + run: | + cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test + rm -r -fo *.appxsym + cd Dependencies + rm -r -fo arm,arm64,x86 + if: github.event.inputs.enableX64 == 'true' + + - name: Create x64 archive + run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x64.zip + if: github.event.inputs.enableX64 == 'true' + + - name: Update x64 release asset + id: upload-release-asset-x64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} + if: github.event.inputs.enableX64 == 'true' + with: + upload_url: ${{ steps.release-drafter.outputs.upload_url }} + asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x64.zip + asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_x64.zip + asset_content_type: application/zip + + - name: Set x64 native + run: | + ./scripts/setNative.ps1 -csprojPath $env:UWP_Project_Path + if: github.event.inputs.enableX64Native == 'true' + + - name: Build x64 native + run: | + msbuild $env:UWP_Project_Directory /p:Platform=x64 /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore /p:Use64BitCompiler=true + env: + BuildMode: SideloadOnly + Configuration: Release + if: github.event.inputs.enableX64Native == 'true' + + - name: copy x64 native document + run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test\安装教程.pdf + if: github.event.inputs.enableX64Native == 'true' + + - name: Remove x64 native useless files + run: | + cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test + rm -r -fo *.appxsym + cd Dependencies + rm -r -fo arm,arm64,x86 + if: github.event.inputs.enableX64Native == 'true' + + - name: Create x64 native archive + run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x64_native.zip + if: github.event.inputs.enableX64Native == 'true' + + - name: Update x64 native release asset + id: upload-release-asset-x64-native + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} + if: github.event.inputs.enableX64Native == 'true' + with: + upload_url: ${{ steps.release-drafter.outputs.upload_url }} + asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x64_native.zip + asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_x64_native.zip + asset_content_type: application/zip + + - name: Build x86 + run: msbuild $env:UWP_Project_Directory /p:Platform=x86 /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore + if: github.event.inputs.enableX86 == 'true' + env: + BuildMode: SideloadOnly + Configuration: Release + + - name: copy x86 document + run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x86_Test\安装教程.pdf + if: github.event.inputs.enableX86 == 'true' + + - name: Remove x86 useless files + run: | + cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x86_Test + rm -r -fo *.appxsym + cd Dependencies + rm -r -fo arm,arm64,x64 + if: github.event.inputs.enableX86 == 'true' + + - name: Create x86 archive + run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x86_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x86.zip + if: github.event.inputs.enableX86 == 'true' + + - name: Update x86 release asset + id: upload-release-asset-x86 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} + if: github.event.inputs.enableX86 == 'true' + with: + upload_url: ${{ steps.release-drafter.outputs.upload_url }} + asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x86.zip + asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_x86.zip + asset_content_type: application/zip + + - name: Build ARM64 + run: msbuild $env:UWP_Project_Directory /p:Platform=ARM64 /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore + if: github.event.inputs.enableArm64 == 'true' + env: + BuildMode: SideloadOnly + Configuration: Release + + - name: copy arm64 document + run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM64_Test\安装教程.pdf + if: github.event.inputs.enableArm64 == 'true' + + - name: Remove arm64 useless files + run: | + cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM64_Test + rm -r -fo *.appxsym + cd Dependencies + rm -r -fo arm,x64,x86 + if: github.event.inputs.enableArm64 == 'true' + + - name: Create ARM64 archive + run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM64_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_ARM64.zip + if: github.event.inputs.enableArm64 == 'true' + + - name: Update ARM64 release asset + id: upload-release-asset-ARM64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} + if: github.event.inputs.enableArm64 == 'true' + with: + upload_url: ${{ steps.release-drafter.outputs.upload_url }} + asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_ARM64.zip + asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_ARM64.zip + asset_content_type: application/zip + + - name: Build ARM32 + run: msbuild $env:UWP_Project_Directory /p:Platform=ARM /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore + if: github.event.inputs.enableArm32 == 'true' + env: + BuildMode: SideloadOnly + Configuration: Release + + - name: copy arm32 document + run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM_Test\安装教程.pdf + if: github.event.inputs.enableArm32 == 'true' + + - name: Remove arm32 useless files + run: | + cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM_Test + rm -r -fo *.appxsym + cd Dependencies + rm -r -fo arm64,x64,x86 + if: github.event.inputs.enableArm32 == 'true' + + - name: Create ARM32 archive + run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_ARM.zip + if: github.event.inputs.enableArm32 == 'true' + + - name: Update ARM32 release asset + id: upload-release-asset-ARM32 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} + if: github.event.inputs.enableArm32 == 'true' + with: + upload_url: ${{ steps.release-drafter.outputs.upload_url }} + asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_ARM.zip + asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_ARM.zip + asset_content_type: application/zip diff --git a/scripts/setNative.ps1 b/scripts/setNative.ps1 new file mode 100644 index 00000000..f6cc6cef --- /dev/null +++ b/scripts/setNative.ps1 @@ -0,0 +1,47 @@ +param ( + [string]$csprojPath +) + +# Check if the input file exists +if (-not (Test-Path $csprojPath)) { + Write-Error "File not found: $csprojPath" + exit 1 +} + +# Read the content of the csproj file with UTF-8 encoding +$csprojContent = Get-Content -Path $csprojPath -Raw -Encoding UTF8 + +# Define the target PropertyGroup condition +# Use backticks to escape the $ character +$targetCondition = "'`$(Configuration)|`$(Platform)' == 'Release|x64'" + +# Find the PropertyGroup with the target condition +$propertyGroupRegex = [regex]::Escape("") + ".*?" + [regex]::Escape("") +$propertyGroupMatch = [regex]::Match($csprojContent, $propertyGroupRegex, [Text.RegularExpressions.RegexOptions]::Singleline) + +if ($propertyGroupMatch.Success) { + # Extract the PropertyGroup content + $propertyGroupContent = $propertyGroupMatch.Value + + # Check if UseDotNetNativeToolchain exists in the PropertyGroup + $useDotNetNativeToolchainRegex = [regex]::Escape("") + ".*?" + [regex]::Escape("") + $useDotNetNativeToolchainMatch = [regex]::Match($propertyGroupContent, $useDotNetNativeToolchainRegex) + + if ($useDotNetNativeToolchainMatch.Success) { + # Replace the value of UseDotNetNativeToolchain with true + $updatedPropertyGroupContent = $propertyGroupContent -replace $useDotNetNativeToolchainRegex, "true" + } else { + # If UseDotNetNativeToolchain doesn't exist, add it + $updatedPropertyGroupContent = $propertyGroupContent -replace "", "true" + } + + # Replace the original PropertyGroup with the updated one + $csprojContent = $csprojContent -replace [regex]::Escape($propertyGroupContent), $updatedPropertyGroupContent + + # Write the updated content back to the file with UTF-8 encoding + Set-Content -Path $csprojPath -Value $csprojContent -Encoding UTF8 + + Write-Host "Updated UseDotNetNativeToolchain to true in the PropertyGroup with condition '$targetCondition'." +} else { + Write-Warning "PropertyGroup with condition '$targetCondition' not found in the csproj file." +} \ No newline at end of file From 5a0a96f6eb77220f29a0a9872bbbfcfcb76b6ce0 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Sat, 14 Dec 2024 18:14:47 +0800 Subject: [PATCH 12/17] =?UTF-8?q?#940=20=E8=A7=86=E9=A2=91=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E5=88=86=E4=BA=AB=E6=8C=89=E9=92=AE=E4=B8=AD?= =?UTF-8?q?=E6=8F=90=E4=BE=9Bav=E5=8F=B7=E5=8F=AF=E5=A4=8D=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/Pages/VideoDetailPage.xaml | 1 + src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml index 4782835b..f423f9e8 100644 --- a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml +++ b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml @@ -44,6 +44,7 @@ + diff --git a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs index 7dfefe91..ae203c4d 100644 --- a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs @@ -746,5 +746,10 @@ private void Pivot_OnPreviewKeyDown(object sender, KeyRoutedEventArgs e) e.OriginalSource.GetType() != typeof(TextBox)) e.Handled = true; } + + private void BtnCopyAvId_OnClick(object sender, RoutedEventArgs e) + { + ("av" + m_viewModel.VideoInfo.Aid).SetClipboard(); + } } } From 570c4ef7fe8c8d1d8dab7f1ed9ac886a17031ca5 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Sat, 14 Dec 2024 18:15:39 +0800 Subject: [PATCH 13/17] =?UTF-8?q?#939=20=E4=B8=8B=E8=BD=BD=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E9=A1=B5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models/Common/ComboBoxItemData.cs | 7 ++++ src/BiliLite.UWP/Models/Common/Enumerates.cs | 9 ++++ src/BiliLite.UWP/Pages/DownloadPage.xaml | 13 ++++++ src/BiliLite.UWP/Pages/DownloadPage.xaml.cs | 20 +++++++++ src/BiliLite.UWP/Services/DownloadService.cs | 41 +++++++++++++++++-- .../Download/DownloadPageViewModel.cs | 9 ++++ 6 files changed, 95 insertions(+), 4 deletions(-) diff --git a/src/BiliLite.UWP/Models/Common/ComboBoxItemData.cs b/src/BiliLite.UWP/Models/Common/ComboBoxItemData.cs index 3e5b070a..d2138704 100644 --- a/src/BiliLite.UWP/Models/Common/ComboBoxItemData.cs +++ b/src/BiliLite.UWP/Models/Common/ComboBoxItemData.cs @@ -6,4 +6,11 @@ public class ComboBoxItemData public int Value { get; set; } } + + public class ComboBoxItemData + { + public string Text { get; set; } + + public T Value { get; set; } + } } diff --git a/src/BiliLite.UWP/Models/Common/Enumerates.cs b/src/BiliLite.UWP/Models/Common/Enumerates.cs index 31112504..46011dc6 100644 --- a/src/BiliLite.UWP/Models/Common/Enumerates.cs +++ b/src/BiliLite.UWP/Models/Common/Enumerates.cs @@ -571,4 +571,13 @@ public enum IndexSeasonType TV = 5, Variety = 7 } + + public enum DownloadedSortMode + { + Default, + TimeDesc, + TimeAsc, + TitleDesc, + TitleAsc, + } } \ No newline at end of file diff --git a/src/BiliLite.UWP/Pages/DownloadPage.xaml b/src/BiliLite.UWP/Pages/DownloadPage.xaml index 0b3d8cde..b5f2bbd2 100644 --- a/src/BiliLite.UWP/Pages/DownloadPage.xaml +++ b/src/BiliLite.UWP/Pages/DownloadPage.xaml @@ -34,6 +34,19 @@ % + + + + + [] m_sortOptions = new ComboBoxItemData[] + { + new() { Text = "默认", Value = DownloadedSortMode.Default }, + new() { Text = "时间倒序", Value = DownloadedSortMode.TimeDesc }, + new() { Text = "时间顺序", Value = DownloadedSortMode.TimeAsc }, + new() { Text = "标题顺序", Value = DownloadedSortMode.TitleAsc }, + new() { Text = "标题倒序", Value = DownloadedSortMode.TitleDesc }, + }; public DownloadPage() { @@ -46,6 +54,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) public async Task Refresh() { + CbSortMode.SelectedIndex = 0; m_downloadService.RefreshDownloaded(); } @@ -350,5 +359,16 @@ private void BtnResumeSubItem_OnClick(object sender, RoutedEventArgs e) m_downloadService.ResumeItem(item); } } + + private void BtnClearSearch_OnClick(object sender, RoutedEventArgs e) + { + m_downloadService.SearchDownloaded(""); + DownloadPivot.SelectedIndex = 1; + } + + private void SortOptions_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + m_downloadService.SetDownloadedSortMode((DownloadedSortMode)CbSortMode.SelectedValue); + } } } diff --git a/src/BiliLite.UWP/Services/DownloadService.cs b/src/BiliLite.UWP/Services/DownloadService.cs index ff1dbc86..5ff38a92 100644 --- a/src/BiliLite.UWP/Services/DownloadService.cs +++ b/src/BiliLite.UWP/Services/DownloadService.cs @@ -335,6 +335,30 @@ private async Task LoadDownloadFromIndex() m_downloadPageViewModel.DownloadedViewModels = new ObservableCollection(downloadedItems); } + private IEnumerable QueryDownloaded() + { + var query = m_downloadPageViewModel.Downloadeds.AsEnumerable(); + + // 提前处理搜索条件 + var searchKeyword = m_downloadPageViewModel.SearchKeyword?.ToLower(); + if (!string.IsNullOrEmpty(searchKeyword)) + { + query = query.Where(x => x.Title.ToLower().Contains(searchKeyword)); + } + + // 使用 switch 表达式简化排序逻辑 + query = m_downloadPageViewModel.DownloadedSortMode switch + { + DownloadedSortMode.TimeDesc => query.OrderByDescending(x => x.UpdateTime), + DownloadedSortMode.TimeAsc => query.OrderBy(x => x.UpdateTime), + DownloadedSortMode.TitleDesc => query.OrderByDescending(x => x.Title), + DownloadedSortMode.TitleAsc => query.OrderBy(x => x.Title), + _ => query // 默认不排序 + }; + + return query; + } + #endregion #region Public Methods @@ -428,8 +452,10 @@ public void RefreshDownloaded() public void SearchDownloaded(string keyword) { - var searchResult = m_downloadPageViewModel.Downloadeds - .Where(x => x.Title.ToLower().Contains(keyword.ToLower())).ToList(); + m_downloadPageViewModel.SearchKeyword = keyword; + m_downloadPageViewModel.IsSearching = !string.IsNullOrEmpty(keyword); + + var searchResult = QueryDownloaded(); m_downloadPageViewModel.DownloadedViewModels.Clear(); m_downloadPageViewModel.DownloadedViewModels.AddRange(searchResult); } @@ -807,9 +833,16 @@ public void ClearIndex() m_biliLiteDbContext.DownloadedItems.RemoveRange(m_biliLiteDbContext.DownloadedItems); } - #endregion + public void SetDownloadedSortMode(DownloadedSortMode mode) + { + m_downloadPageViewModel.DownloadedSortMode = mode; + m_downloadPageViewModel.DownloadedViewModels.Clear(); + var query = QueryDownloaded(); + m_downloadPageViewModel.DownloadedViewModels.AddRange(query); + } + #endregion } -} +} \ No newline at end of file diff --git a/src/BiliLite.UWP/ViewModels/Download/DownloadPageViewModel.cs b/src/BiliLite.UWP/ViewModels/Download/DownloadPageViewModel.cs index 8888bf25..bd712b72 100644 --- a/src/BiliLite.UWP/ViewModels/Download/DownloadPageViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Download/DownloadPageViewModel.cs @@ -9,6 +9,7 @@ using System.Threading; using Windows.Networking.BackgroundTransfer; using AutoMapper; +using BiliLite.Models.Common; namespace BiliLite.ViewModels.Download { @@ -60,6 +61,8 @@ public DownloadPageViewModel(IMapper mapper) [DoNotNotify] public List Downloadeds { get; set; } + public bool IsSearching { get; set; } + public bool LoadingDownloaded { get; set; } = true; public double DiskTotal { get; set; } @@ -75,6 +78,12 @@ public DownloadPageViewModel(IMapper mapper) [DependsOn(nameof(TotalDownloadedCount), nameof(LoadedDownloadedCount))] public int LoadingDownloadedPercent => (int)((LoadedDownloadedCount * 1f / TotalDownloadedCount * 1f) * 100); + [DoNotNotify] + public DownloadedSortMode DownloadedSortMode { get; set; } + + [DoNotNotify] + public string SearchKeyword { get; set; } + #endregion } } From 7a20b61d737bbabd2a230de7f0097669c6eacd62 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Sat, 14 Dec 2024 18:17:50 +0800 Subject: [PATCH 14/17] =?UTF-8?q?#938=20=E7=9B=B4=E6=92=AD=E5=B0=86?= =?UTF-8?q?=E4=BA=92=E5=8A=A8=E5=8C=BA=E8=87=AA=E5=8A=A8=E6=B8=85=E7=90=86?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E6=97=B6=E6=9C=BA=E6=B7=BB=E5=8A=A0=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=AC=A2=E8=BF=8E=E6=B6=88=E6=81=AF=E6=97=B6=E8=A7=A6?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models/Common/Live/LiveMessageHandleActionsMap.cs | 3 ++- src/BiliLite.UWP/ViewModels/Live/LiveRoomViewModel.cs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/BiliLite.UWP/Models/Common/Live/LiveMessageHandleActionsMap.cs b/src/BiliLite.UWP/Models/Common/Live/LiveMessageHandleActionsMap.cs index e5ae4779..35c85b28 100644 --- a/src/BiliLite.UWP/Models/Common/Live/LiveMessageHandleActionsMap.cs +++ b/src/BiliLite.UWP/Models/Common/Live/LiveMessageHandleActionsMap.cs @@ -91,7 +91,7 @@ private void Danmu(LiveRoomViewModel viewModel, object message) } } - if (viewModel.Messages.Count >= viewModel.CleanCount) viewModel.Messages.RemoveAt(0); + viewModel.CheckClearMessages(); viewModel.Messages.Add(m); AddNewDanmu?.Invoke(null, m); } @@ -137,6 +137,7 @@ private void InteractWord(LiveRoomViewModel viewModel, object message) msg.ShowMedal = info.ShowMedal; } + viewModel.CheckClearMessages(); viewModel.Messages.Add(msg); } diff --git a/src/BiliLite.UWP/ViewModels/Live/LiveRoomViewModel.cs b/src/BiliLite.UWP/ViewModels/Live/LiveRoomViewModel.cs index eefb556e..4817e60d 100644 --- a/src/BiliLite.UWP/ViewModels/Live/LiveRoomViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Live/LiveRoomViewModel.cs @@ -1314,6 +1314,11 @@ public async Task JoinRedPocketLottery() } + public void CheckClearMessages() + { + if (Messages.Count >= CleanCount) Messages.RemoveAt(0); + } + public void Dispose() { foreach (var item in LotteryDanmu) From 1e9ab999a00592980760a11b81ed67049ab5c158 Mon Sep 17 00:00:00 2001 From: ProJend <55018532+ProJend@users.noreply.github.com> Date: Tue, 17 Dec 2024 23:16:44 +0800 Subject: [PATCH 15/17] =?UTF-8?q?#925=20#900=20=E8=B0=83=E6=95=B4=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E6=A0=8F=E6=A0=B7=E5=BC=8F=E3=80=81=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E7=9B=B8=E5=85=B3=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=20(#932)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #943 #925 #900 #864 实现左上角可点击,右上角不可点击 --- src/BiliLite.UWP/BiliLite.UWP.csproj | 1 + .../Controls/PlayerControl.xaml.cs | 10 ++-- .../Controls/Settings/UISettingsControl.xaml | 26 ++++++---- .../Settings/UISettingsControl.xaml.cs | 30 ++++++++++++ .../Converters/InverseBooleanConverter.cs | 12 +++++ src/BiliLite.UWP/MainPage.xaml | 2 - src/BiliLite.UWP/MainPage.xaml.cs | 25 ++++++---- .../Models/Common/SettingConstants.cs | 14 ++++-- src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs | 13 +++++ .../Pages/SeasonDetailPage.xaml.cs | 8 +++- .../Pages/VideoDetailPage.xaml.cs | 11 ++++- .../Services/FrostMasterDanmakuController.cs | 19 +------- .../Services/NsDanmakuController.cs | 19 +------- src/BiliLite.UWP/Styles/Converter.xaml | 1 + src/BiliLite.UWP/Styles/TabViewStyle.xaml | 47 +++++++------------ .../ViewModels/Common/MainPageViewModel.cs | 5 ++ 16 files changed, 143 insertions(+), 100 deletions(-) create mode 100644 src/BiliLite.UWP/Converters/InverseBooleanConverter.cs diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index 755fd1b5..05028001 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -186,6 +186,7 @@ VideoListView.xaml + EditPlaySpeedMenuDialog.xaml diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs index 23b5d429..16558e6b 100644 --- a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs @@ -173,7 +173,7 @@ public PlayerControl() } else { - m_danmakuController = App.ServiceProvider.GetRequiredService(); + m_danmakuController = App.ServiceProvider.GetRequiredService(); m_danmakuController.Init(DanmakuCanvas); } } @@ -496,7 +496,7 @@ private void LoadPlayerSetting() { //音量 Player.Volume = SettingService.GetValue(SettingConstants.Player.PLAYER_VOLUME, SettingConstants.Player.DEFAULT_PLAYER_VOLUME); - + var lockPlayerVolume = SettingService.GetValue(SettingConstants.Player.LOCK_PLAYER_VOLUME, SettingConstants.Player.DEFAULT_LOCK_PLAYER_VOLUME); if (!lockPlayerVolume) { @@ -1588,7 +1588,7 @@ private async Task ChangeQualityPlayVideo(BiliPlayUrlInfo qual if (quality.PlayUrlType == BiliPlayUrlType.DASH) { var realPlayerType = (RealPlayerType)SettingService.GetValue(SettingConstants.Player.USE_REAL_PLAYER_TYPE, (int)SettingConstants.Player.DEFAULT_USE_REAL_PLAYER_TYPE); - if (realPlayerType==RealPlayerType.Native) + if (realPlayerType == RealPlayerType.Native) { result = await Player.PlayerDashUseNative(quality.DashInfo, quality.UserAgent, quality.Referer, positon: _postion); @@ -1681,10 +1681,6 @@ public void FullScreen(bool fullScreen) BottomBtnFull.Visibility = Visibility.Collapsed; BottomBtnFullWindows.Visibility = Visibility.Collapsed; BottomBtnExitFullWindows.Visibility = Visibility.Collapsed; - if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0) - { - TopControlBar.Margin = new Thickness(0, 48, 0, 0); - } //全屏 if (!view.IsFullScreenMode) diff --git a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml index 71de8f30..68daec49 100644 --- a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml +++ b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml @@ -330,16 +330,24 @@ - - - + + + + + - - - + + + + + + + + diff --git a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs index 54b614a0..dd8fc806 100644 --- a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs @@ -306,6 +306,36 @@ private void LoadUI() }; }; + // 标签最小宽度 + NumTabItemMinWidth.Value = SettingService.GetValue(SettingConstants.UI.TAB_ITEM_MIN_WIDTH, SettingConstants.UI.DEFAULT_TAB_ITEM_MIN_WIDTH); + NumTabItemMinWidth.Loaded += (sender, e) => + { + NumTabItemMinWidth.ValueChanged += (obj, args) => + { + SettingService.SetValue(SettingConstants.UI.TAB_ITEM_MIN_WIDTH, NumTabItemMinWidth.Value); + }; + }; + + // 标签最大宽度 + NumTabItemMaxWidth.Value = SettingService.GetValue(SettingConstants.UI.TAB_ITEM_MAX_WIDTH, SettingConstants.UI.DEFAULT_TAB_ITEM_MAX_WIDTH); + NumTabItemMaxWidth.Loaded += (sender, e) => + { + NumTabItemMaxWidth.ValueChanged += (obj, args) => + { + SettingService.SetValue(SettingConstants.UI.TAB_ITEM_MAX_WIDTH, NumTabItemMaxWidth.Value); + }; + }; + + // 标签高度 + NumTabHeight.Value = SettingService.GetValue(SettingConstants.UI.TAB_HEIGHT, SettingConstants.UI.DEFAULT_TAB_HEIGHT); + NumTabHeight.Loaded += (sender, e) => + { + NumTabHeight.ValueChanged += (obj, args) => + { + SettingService.SetValue(SettingConstants.UI.TAB_HEIGHT, NumTabHeight.Value); + }; + }; + //显示视频底部进度条 SwShowVideoBottomProgress.IsOn = SettingService.GetValue(SettingConstants.UI.SHOW_VIDEO_BOTTOM_VIRTUAL_PROGRESS_BAR, SettingConstants.UI.DEFAULT_SHOW_VIDEO_BOTTOM_VIRTUAL_PROGRESS_BAR); SwShowVideoBottomProgress.Loaded += (sender, e) => diff --git a/src/BiliLite.UWP/Converters/InverseBooleanConverter.cs b/src/BiliLite.UWP/Converters/InverseBooleanConverter.cs new file mode 100644 index 00000000..3a63bea4 --- /dev/null +++ b/src/BiliLite.UWP/Converters/InverseBooleanConverter.cs @@ -0,0 +1,12 @@ +using System; +using Windows.UI.Xaml.Data; + +namespace BiliLite.Converters +{ + public class InverseBooleanConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) => !(bool)value; + + public object ConvertBack(object value, Type targetType, object parameter, string language) => throw new NotImplementedException(); + } +} diff --git a/src/BiliLite.UWP/MainPage.xaml b/src/BiliLite.UWP/MainPage.xaml index 01fb1013..4876fd6c 100644 --- a/src/BiliLite.UWP/MainPage.xaml +++ b/src/BiliLite.UWP/MainPage.xaml @@ -25,7 +25,6 @@ PreviewKeyDown="TabView_OnPreviewKeyDown" TabCloseRequested="TabView_TabCloseRequested" TabItemsChanged="tabView_TabItemsChanged" - LayoutUpdated="TabView_OnLayoutUpdated" TabWidthMode="SizeToContent"> diff --git a/src/BiliLite.UWP/MainPage.xaml.cs b/src/BiliLite.UWP/MainPage.xaml.cs index 1534dd8c..af0ccc58 100644 --- a/src/BiliLite.UWP/MainPage.xaml.cs +++ b/src/BiliLite.UWP/MainPage.xaml.cs @@ -265,6 +265,9 @@ private void ClosePage(TabViewItem tabItem) } private void tabView_Loaded(object sender, RoutedEventArgs e) { + // 根据Tab高度设置图片视图边距 + gridViewer.Margin = new Thickness(0, m_viewModel.TabHeight, 0, 0); + var frame = new MyFrame(); frame.Navigate(typeof(HomePage)); @@ -325,17 +328,19 @@ private void InitTabViewStyle() var styleKvp = dict.FirstOrDefault(x => x.Key.ToString().Contains("TabViewItem")); - if (!(styleKvp.Value is Style style)) return; - style.Setters.Add(new Setter(TabViewItem.MinWidthProperty, m_viewModel.TabItemMinWidth)); - style.Setters.Add(new Setter(TabViewItem.MaxWidthProperty, m_viewModel.TabItemMaxWidth)); - } + if (styleKvp.Value is Style style) + { + style.Setters.Add(new Setter(TabViewItem.MinWidthProperty, m_viewModel.TabItemMinWidth)); + style.Setters.Add(new Setter(TabViewItem.MaxWidthProperty, m_viewModel.TabItemMaxWidth)); + style.Setters.Add(new Setter(TabViewItem.HeightProperty, m_viewModel.TabHeight)); + } - private void TabView_OnLayoutUpdated(object sender, object e) - { - // TODO: LayoutUpdated调用频繁,后续更换其他事件 - var tabList = tabView.FindFirstChildByType(); - if (tabList == null) return; - tabList.MaxWidth = tabView.ActualWidth - 175; + var tabStyleKvp = dict.FirstOrDefault(x => x.Key.ToString().Contains("TabViewListView")); + + if (tabStyleKvp.Value is Style tabStyle) + { + tabStyle.Setters.Add(new Setter(TabViewItem.HeightProperty, m_viewModel.TabHeight)); + } } } } diff --git a/src/BiliLite.UWP/Models/Common/SettingConstants.cs b/src/BiliLite.UWP/Models/Common/SettingConstants.cs index 77bcdb67..68ebef35 100644 --- a/src/BiliLite.UWP/Models/Common/SettingConstants.cs +++ b/src/BiliLite.UWP/Models/Common/SettingConstants.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; -using BiliLite.Models.Attributes; +using BiliLite.Models.Attributes; using BiliLite.Models.Common.Player; using BiliLite.Services; +using System.Collections.Generic; namespace BiliLite.Models.Common { @@ -233,7 +233,13 @@ public class UI public const string TAB_ITEM_MIN_WIDTH = "TabItemMinWidth"; [SettingDefaultValue] - public const double DEFAULT_TAB_ITEM_MIN_WIDTH = 192; + public const double DEFAULT_TAB_ITEM_MIN_WIDTH = 0; + + [SettingKey(typeof(double))] + public const string TAB_HEIGHT = "TabHeight"; + + [SettingDefaultValue] + public const double DEFAULT_TAB_HEIGHT = 40; /// /// 是否启用动态磁贴 @@ -612,7 +618,7 @@ public class Player [SettingKey(typeof(object))] public const string FfmpegOptions = "FfmpegOptions"; - /// + /// /// 使用外站视频替换无法播放的视频 bool /// [SettingKey(typeof(bool))] diff --git a/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs index 4182d6a6..5c0f1045 100644 --- a/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs @@ -323,10 +323,23 @@ await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => if (e.NewState.IsFullscreen && !view.IsFullScreenMode) { view.TryEnterFullScreenMode(); + + if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) <= 0) + { + var marginOffset = SettingService.GetValue(SettingConstants.UI.TAB_HEIGHT, + SettingConstants.UI.DEFAULT_TAB_HEIGHT); + this.Margin = new Thickness(0, marginOffset * -1, 0, 0); + } + else + { + this.Margin = new Thickness(0, -40, 0, 0); + } } else if (view.IsFullScreenMode) { view.ExitFullScreenMode(); + + this.Margin = new Thickness(0); } }); } diff --git a/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs index 43e6d95e..1fa7e166 100644 --- a/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs @@ -275,7 +275,13 @@ private void PlayerControl_FullScreenEvent(object sender, bool e) { if (e) { - this.Margin = new Thickness(0, SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) == 0 ? -48 : -48, 0, 0); + if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) <= 0) + { + var marginOffset = SettingService.GetValue(SettingConstants.UI.TAB_HEIGHT, + SettingConstants.UI.DEFAULT_TAB_HEIGHT); + this.Margin = new Thickness(0, marginOffset * -1, 0, 0); + } + m_viewModel.DefaultRightInfoWidth = new GridLength(0, GridUnitType.Pixel); BottomInfo.Height = new GridLength(0, GridUnitType.Pixel); } diff --git a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs index ae203c4d..b7029014 100644 --- a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs @@ -449,14 +449,21 @@ private void PlayerControl_FullScreenEvent(object sender, bool e) { if (e) { - this.Margin = new Thickness(0, SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) == 0 ? -48 : -48, 0, 0); + if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) <= 0) + { + var marginOffset = SettingService.GetValue(SettingConstants.UI.TAB_HEIGHT, + SettingConstants.UI.DEFAULT_TAB_HEIGHT); + this.Margin = new Thickness(0, marginOffset * -1, 0, 0); + } + m_viewModel.DefaultRightInfoWidth = new GridLength(0, GridUnitType.Pixel); BottomInfo.Height = new GridLength(0, GridUnitType.Pixel); } else { this.Margin = new Thickness(0); - m_viewModel.DefaultRightInfoWidth = new GridLength(SettingService.GetValue(SettingConstants.UI.RIGHT_DETAIL_WIDTH, 320), GridUnitType.Pixel); + m_viewModel.DefaultRightInfoWidth = new GridLength( + SettingService.GetValue(SettingConstants.UI.RIGHT_DETAIL_WIDTH, 320), GridUnitType.Pixel); BottomInfo.Height = GridLength.Auto; } } diff --git a/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs b/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs index 6e2eb235..5339ac4d 100644 --- a/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs +++ b/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs @@ -6,7 +6,6 @@ using Windows.UI.Xaml.Controls; using Atelier39; using AutoMapper; -using BiliLite.Models.Common; using BiliLite.Models.Common.Danmaku; using BiliLite.Services.Interfaces; using BiliLite.ViewModels.Video; @@ -115,23 +114,7 @@ public override void SetSpeed(int speed) public override void SetTopMargin(double topMargin) { base.SetTopMargin(topMargin); - if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0) - { - m_danmakuCanvas.Margin = DanmakuViewModel.Fullscreen ? new Thickness(0, DanmakuViewModel.MarginTop + 16, 0, 0) : new Thickness(0, DanmakuViewModel.MarginTop, 0, 0); - } - else - { - m_danmakuCanvas.Margin = new Thickness(0, topMargin, 0, 0); - } - } - - public override void SetFullscreen(bool fullscreen) - { - base.SetFullscreen(fullscreen); - if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0) - { - m_danmakuCanvas.Margin = fullscreen ? new Thickness(0, DanmakuViewModel.MarginTop + 16, 0, 0) : new Thickness(0, DanmakuViewModel.MarginTop, 0, 0); - } + m_danmakuCanvas.Margin = new Thickness(0, topMargin, 0, 0); } public override void SetOpacity(double opacity) diff --git a/src/BiliLite.UWP/Services/NsDanmakuController.cs b/src/BiliLite.UWP/Services/NsDanmakuController.cs index bb72e099..615210e2 100644 --- a/src/BiliLite.UWP/Services/NsDanmakuController.cs +++ b/src/BiliLite.UWP/Services/NsDanmakuController.cs @@ -12,7 +12,6 @@ using BiliLite.ViewModels.Video; using NSDanmaku.Controls; using NSDanmaku.Model; -using BiliLite.Models.Common; namespace BiliLite.Services { @@ -112,23 +111,7 @@ public override void SetSpeed(int speed) public override void SetTopMargin(double topMargin) { base.SetTopMargin(topMargin); - if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0) - { - m_danmakuControl.Margin = DanmakuViewModel.Fullscreen ? new Thickness(0, DanmakuViewModel.MarginTop + 16, 0, 0) : new Thickness(0, DanmakuViewModel.MarginTop, 0, 0); - } - else - { - m_danmakuControl.Margin = new Thickness(0, topMargin, 0, 0); - } - } - - public override void SetFullscreen(bool fullscreen) - { - base.SetFullscreen(fullscreen); - if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0) - { - m_danmakuControl.Margin = fullscreen ? new Thickness(0, DanmakuViewModel.MarginTop + 16, 0, 0) : new Thickness(0, DanmakuViewModel.MarginTop, 0, 0); - } + m_danmakuControl.Margin = new Thickness(0, topMargin, 0, 0); } public override void SetOpacity(double opacity) diff --git a/src/BiliLite.UWP/Styles/Converter.xaml b/src/BiliLite.UWP/Styles/Converter.xaml index 49b1fe3c..e07280f5 100644 --- a/src/BiliLite.UWP/Styles/Converter.xaml +++ b/src/BiliLite.UWP/Styles/Converter.xaml @@ -8,4 +8,5 @@ + diff --git a/src/BiliLite.UWP/Styles/TabViewStyle.xaml b/src/BiliLite.UWP/Styles/TabViewStyle.xaml index 2fdb4d6c..4abc4796 100644 --- a/src/BiliLite.UWP/Styles/TabViewStyle.xaml +++ b/src/BiliLite.UWP/Styles/TabViewStyle.xaml @@ -24,16 +24,10 @@ - + - + @@ -74,8 +68,8 @@