From c27c980ffb8f827f1945bd87f5a766f911af6bde Mon Sep 17 00:00:00 2001 From: ProJend <55018532+ProJend@users.noreply.github.com> Date: Mon, 20 Jan 2025 18:10:03 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=B8=AA=E6=80=A7=E5=8C=96=E8=AE=BE=E7=BD=AE=E9=A1=B9=20(#1000?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/BiliLite.UWP.csproj | 7 + .../Settings/PerformanceSettingsControl.xaml | 64 +++++++++ .../PerformanceSettingsControl.xaml.cs | 81 +++++++++++ .../Settings/ShortcutKeySettingsControl.xaml | 126 ++++++++++-------- .../ShortcutKeySettingsControl.xaml.cs | 27 ++-- .../Controls/Settings/UISettingsControl.xaml | 63 --------- .../Settings/UISettingsControl.xaml.cs | 83 ++---------- src/BiliLite.UWP/Pages/SettingPage.xaml | 11 +- .../Settings/ShortcutFunctionViewModel.cs | 8 +- 9 files changed, 263 insertions(+), 207 deletions(-) create mode 100644 src/BiliLite.UWP/Controls/Settings/PerformanceSettingsControl.xaml create mode 100644 src/BiliLite.UWP/Controls/Settings/PerformanceSettingsControl.xaml.cs diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index 70cd125ed..7d1456bf9 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -168,6 +168,9 @@ LiveSettingsControl.xaml + + PerformanceSettingsControl.xaml + PlaySettingsControl.xaml @@ -1258,6 +1261,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/src/BiliLite.UWP/Controls/Settings/PerformanceSettingsControl.xaml b/src/BiliLite.UWP/Controls/Settings/PerformanceSettingsControl.xaml new file mode 100644 index 000000000..43587d9cc --- /dev/null +++ b/src/BiliLite.UWP/Controls/Settings/PerformanceSettingsControl.xaml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/BiliLite.UWP/Controls/Settings/PerformanceSettingsControl.xaml.cs b/src/BiliLite.UWP/Controls/Settings/PerformanceSettingsControl.xaml.cs new file mode 100644 index 000000000..b6fa3fb16 --- /dev/null +++ b/src/BiliLite.UWP/Controls/Settings/PerformanceSettingsControl.xaml.cs @@ -0,0 +1,81 @@ +using BiliLite.Extensions; +using BiliLite.Models.Common; +using BiliLite.Services; +using Microsoft.Toolkit.Uwp.UI; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +//https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板 + +namespace BiliLite.Controls.Settings +{ + public sealed partial class PerformanceSettingsControl : UserControl + { + public PerformanceSettingsControl() + { + InitializeComponent(); + LoadPerformance(); + } + + private void LoadPerformance() + { + //加载原图 + swPictureQuality.IsOn = SettingService.GetValue(SettingConstants.UI.ORTGINAL_IMAGE, false); + swPictureQuality.Loaded += new RoutedEventHandler((sender, e) => + { + swPictureQuality.Toggled += new RoutedEventHandler((obj, args) => + { + SettingService.SetValue(SettingConstants.UI.ORTGINAL_IMAGE, swPictureQuality.IsOn); + SettingService.UI.LoadOriginalImage = null; + }); + }); + //缓存页面 + swHomeCache.IsOn = SettingService.GetValue(SettingConstants.UI.CACHE_HOME, true); + swHomeCache.Loaded += new RoutedEventHandler((sender, e) => + { + swHomeCache.Toggled += new RoutedEventHandler((obj, args) => + { + SettingService.SetValue(SettingConstants.UI.CACHE_HOME, swHomeCache.IsOn); + + }); + }); + + //新窗口浏览图片 + swPreviewImageNavigateToPage.IsOn = SettingService.GetValue(SettingConstants.UI.NEW_WINDOW_PREVIEW_IMAGE, false); + swPreviewImageNavigateToPage.Loaded += new RoutedEventHandler((sender, e) => + { + swPreviewImageNavigateToPage.Toggled += new RoutedEventHandler((obj, args) => + { + SettingService.SetValue(SettingConstants.UI.NEW_WINDOW_PREVIEW_IMAGE, swPreviewImageNavigateToPage.IsOn); + }); + }); + + //启动应用时打开上次浏览的标签页 + SwitchOpenLastPage.IsOn = SettingService.GetValue(SettingConstants.UI.ENABLE_OPEN_LAST_PAGE, SettingConstants.UI.DEFAULT_ENABLE_OPEN_LAST_PAGE); + SwitchOpenLastPage.Loaded += (sender, e) => + { + SwitchOpenLastPage.Toggled += (obj, args) => + { + SettingService.SetValue(SettingConstants.UI.ENABLE_OPEN_LAST_PAGE, SwitchOpenLastPage.IsOn); + }; + }; + + //浏览器打开无法处理的链接 + swOpenUrlWithBrowser.IsOn = SettingService.GetValue(SettingConstants.UI.OPEN_URL_BROWSER, false); + swOpenUrlWithBrowser.Loaded += new RoutedEventHandler((sender, e) => + { + swOpenUrlWithBrowser.Toggled += new RoutedEventHandler((obj, args) => + { + SettingService.SetValue(SettingConstants.UI.OPEN_URL_BROWSER, swOpenUrlWithBrowser.IsOn); + }); + }); + + } + + private async void btnCleanImageCache_Click(object sender, RoutedEventArgs e) + { + await ImageCache.Instance.ClearAsync(); + Notify.ShowMessageToast("已清除图片缓存"); + } + } +} diff --git a/src/BiliLite.UWP/Controls/Settings/ShortcutKeySettingsControl.xaml b/src/BiliLite.UWP/Controls/Settings/ShortcutKeySettingsControl.xaml index b1f2598a6..a1c45fe42 100644 --- a/src/BiliLite.UWP/Controls/Settings/ShortcutKeySettingsControl.xaml +++ b/src/BiliLite.UWP/Controls/Settings/ShortcutKeySettingsControl.xaml @@ -2,47 +2,67 @@ x:Class="BiliLite.Controls.Settings.ShortcutKeySettingsControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:local="using:BiliLite.Controls.Settings" + xmlns:controls="using:CommunityToolkit.WinUI.Controls" + xmlns:controls1="using:Microsoft.UI.Xaml.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:font="using:FontAwesome5" xmlns:functions="using:BiliLite.Models.Functions" - xmlns:controls="using:CommunityToolkit.WinUI.Controls" + xmlns:local="using:BiliLite.Controls.Settings" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:settings="using:BiliLite.ViewModels.Settings" - xmlns:controls1="using:Microsoft.UI.Xaml.Controls" - mc:Ignorable="d" d:DesignHeight="300" - d:DesignWidth="400"> + d:DesignWidth="400" + mc:Ignorable="d"> + + + + + + + + + 关闭页面 + 新标签页打开视频但不进入 + 无操作 + + + - - + 快捷键自定义 - - + + - + - + + + + - + - + @@ -53,45 +73,39 @@ - 其他设置 - - - - + 其他设置 + + - - + + - - - + - + - - + + diff --git a/src/BiliLite.UWP/Controls/Settings/ShortcutKeySettingsControl.xaml.cs b/src/BiliLite.UWP/Controls/Settings/ShortcutKeySettingsControl.xaml.cs index f04c1a680..04957afa9 100644 --- a/src/BiliLite.UWP/Controls/Settings/ShortcutKeySettingsControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/Settings/ShortcutKeySettingsControl.xaml.cs @@ -1,15 +1,16 @@ -using System; -using System.Collections.ObjectModel; -using System.Linq; -using System.Threading.Tasks; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using AutoMapper; +using AutoMapper; +using BiliLite.Models.Common; using BiliLite.Models.Functions; using BiliLite.Services; using BiliLite.ViewModels.Settings; using Microsoft.Extensions.DependencyInjection; using Microsoft.UI.Xaml.Controls; +using System; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; //https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板 @@ -34,7 +35,17 @@ public ShortcutKeySettingsControl() InitializeComponent(); m_shortcutKeyService.OnRecordKeyDown += ShortcutKeyService_OnRecordKeyDown; - m_shortcutKeyService.OnRecordStoped += ShortcutKeyService_OnRecordStoped; ; + m_shortcutKeyService.OnRecordStoped += ShortcutKeyService_OnRecordStoped; + + // 鼠标中键/侧键行为 + cbMouseMiddleAction.SelectedIndex = SettingService.GetValue(SettingConstants.UI.MOUSE_MIDDLE_ACTION, (int)MouseMiddleActions.Back); + cbMouseMiddleAction.Loaded += new RoutedEventHandler((sender, e) => + { + cbMouseMiddleAction.SelectionChanged += new SelectionChangedEventHandler((obj, args) => + { + SettingService.SetValue(SettingConstants.UI.MOUSE_MIDDLE_ACTION, cbMouseMiddleAction.SelectedIndex); + }); + }); } private async void ShortcutKeyService_OnRecordStoped(object sender, System.EventArgs e) diff --git a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml index 8434590e0..53a632942 100644 --- a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml +++ b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml @@ -43,31 +43,6 @@ - - - - - - - - - - - - - - - - - - - - - - - @@ -251,14 +226,6 @@ - - - - - - - @@ -285,28 +252,6 @@ - - - - - - - - - - - - - - 关闭页面 - 新标签页打开视频但不进入 - 无操作 - - - - @@ -322,14 +267,6 @@ - - - - - - - diff --git a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs index 7f039465b..3565d20bb 100644 --- a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs @@ -1,17 +1,16 @@ -using System.Collections.ObjectModel; -using System.Linq; -using Windows.Foundation; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using BiliLite.Extensions; +using BiliLite.Extensions; +using BiliLite.Extensions.Notifications; 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; -using BiliLite.Extensions.Notifications; +using System.Collections.ObjectModel; +using System.Linq; using Windows.ApplicationModel.Background; +using Windows.Foundation; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; //https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板 @@ -24,7 +23,7 @@ public sealed partial class UISettingsControl : UserControl public UISettingsControl() { m_themeService = App.ServiceProvider.GetRequiredService(); - InitializeComponent(); + InitializeComponent(); LoadUI(); } private void LoadUI() @@ -61,26 +60,6 @@ private void LoadUI() }); }); - //加载原图 - swPictureQuality.IsOn = SettingService.GetValue(SettingConstants.UI.ORTGINAL_IMAGE, false); - swPictureQuality.Loaded += new RoutedEventHandler((sender, e) => - { - swPictureQuality.Toggled += new RoutedEventHandler((obj, args) => - { - SettingService.SetValue(SettingConstants.UI.ORTGINAL_IMAGE, swPictureQuality.IsOn); - SettingService.UI.LoadOriginalImage = null; - }); - }); - //缓存页面 - swHomeCache.IsOn = SettingService.GetValue(SettingConstants.UI.CACHE_HOME, true); - swHomeCache.Loaded += new RoutedEventHandler((sender, e) => - { - swHomeCache.Toggled += new RoutedEventHandler((obj, args) => - { - SettingService.SetValue(SettingConstants.UI.CACHE_HOME, swHomeCache.IsOn); - - }); - }); // 显示推荐页横幅 SwitchDisplayRecommendBanner.IsOn = SettingService.GetValue(SettingConstants.UI.DISPLAY_RECOMMEND_BANNER, SettingConstants.UI.DEFAULT_DISPLAY_RECOMMEND_BANNER); @@ -174,36 +153,6 @@ private void LoadUI() }); }); - //新窗口浏览图片 - swPreviewImageNavigateToPage.IsOn = SettingService.GetValue(SettingConstants.UI.NEW_WINDOW_PREVIEW_IMAGE, false); - swPreviewImageNavigateToPage.Loaded += new RoutedEventHandler((sender, e) => - { - swPreviewImageNavigateToPage.Toggled += new RoutedEventHandler((obj, args) => - { - SettingService.SetValue(SettingConstants.UI.NEW_WINDOW_PREVIEW_IMAGE, swPreviewImageNavigateToPage.IsOn); - }); - }); - - //启动应用时打开上次浏览的标签页 - SwitchOpenLastPage.IsOn = SettingService.GetValue(SettingConstants.UI.ENABLE_OPEN_LAST_PAGE, SettingConstants.UI.DEFAULT_ENABLE_OPEN_LAST_PAGE); - SwitchOpenLastPage.Loaded += (sender, e) => - { - SwitchOpenLastPage.Toggled += (obj, args) => - { - SettingService.SetValue(SettingConstants.UI.ENABLE_OPEN_LAST_PAGE, SwitchOpenLastPage.IsOn); - }; - }; - - // 鼠标中键/侧键行为 - cbMouseMiddleAction.SelectedIndex = SettingService.GetValue(SettingConstants.UI.MOUSE_MIDDLE_ACTION, (int)MouseMiddleActions.Back); - cbMouseMiddleAction.Loaded += new RoutedEventHandler((sender, e) => - { - cbMouseMiddleAction.SelectionChanged += new SelectionChangedEventHandler((obj, args) => - { - SettingService.SetValue(SettingConstants.UI.MOUSE_MIDDLE_ACTION, cbMouseMiddleAction.SelectedIndex); - }); - }); - // 快速收藏 SwitchQuickDoFav.IsOn = SettingService.GetValue(SettingConstants.UI.QUICK_DO_FAV, SettingConstants.UI.DEFAULT_QUICK_DO_FAV); SwitchQuickDoFav.Loaded += (sender, e) => @@ -284,16 +233,6 @@ private void LoadUI() }); }); - //浏览器打开无法处理的链接 - swOpenUrlWithBrowser.IsOn = SettingService.GetValue(SettingConstants.UI.OPEN_URL_BROWSER, false); - swOpenUrlWithBrowser.Loaded += new RoutedEventHandler((sender, e) => - { - swOpenUrlWithBrowser.Toggled += new RoutedEventHandler((obj, args) => - { - SettingService.SetValue(SettingConstants.UI.OPEN_URL_BROWSER, swOpenUrlWithBrowser.IsOn); - }); - }); - //固定标签宽度 SwitchTabItemFixedWidth.IsOn = SettingService.GetValue(SettingConstants.UI.ENABLE_TAB_ITEM_FIXED_WIDTH, @@ -402,12 +341,6 @@ private void gridHomeNavItem_ItemClick(object sender, ItemClickEventArgs e) Notify.ShowMessageToast("更改成功,重启生效"); } - private async void btnCleanImageCache_Click(object sender, RoutedEventArgs e) - { - await ImageCache.Instance.ClearAsync(); - Notify.ShowMessageToast("已清除图片缓存"); - } - private void menuRemoveHomeItem_Click(object sender, RoutedEventArgs e) { var item = (sender as MenuFlyoutItem).DataContext as HomeNavItem; diff --git a/src/BiliLite.UWP/Pages/SettingPage.xaml b/src/BiliLite.UWP/Pages/SettingPage.xaml index 5d969be4a..24da08a75 100644 --- a/src/BiliLite.UWP/Pages/SettingPage.xaml +++ b/src/BiliLite.UWP/Pages/SettingPage.xaml @@ -30,7 +30,6 @@ - @@ -42,6 +41,16 @@ + + + 性能 + + + + + + + 代理 diff --git a/src/BiliLite.UWP/ViewModels/Settings/ShortcutFunctionViewModel.cs b/src/BiliLite.UWP/ViewModels/Settings/ShortcutFunctionViewModel.cs index 416db53b1..1382c9282 100644 --- a/src/BiliLite.UWP/ViewModels/Settings/ShortcutFunctionViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Settings/ShortcutFunctionViewModel.cs @@ -1,8 +1,8 @@ -using System.Collections.ObjectModel; -using System.Linq; +using BiliLite.Models.Functions; using BiliLite.ViewModels.Common; -using BiliLite.Models.Functions; using PropertyChanged; +using System.Collections.ObjectModel; +using System.Linq; namespace BiliLite.ViewModels.Settings { @@ -18,7 +18,7 @@ public class ShortcutFunctionViewModel : BaseViewModel public bool IsPressAction { get; set; } - public string Description => IsPressAction ? "按住行为" : "点击行为"; + public string Description => IsPressAction ? "长按执行" : "点击执行"; public bool Enable { get; set; } From 5fb91430cf0cd4a09ce7809e030bfc829cfe17ed Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Mon, 20 Jan 2025 20:09:29 +0800 Subject: [PATCH 02/12] =?UTF-8?q?#1001=20=E5=8D=95=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E8=BF=94=E5=9B=9E=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/NoTabMainPage.xaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/BiliLite.UWP/NoTabMainPage.xaml b/src/BiliLite.UWP/NoTabMainPage.xaml index f55a5d615..db857140e 100644 --- a/src/BiliLite.UWP/NoTabMainPage.xaml +++ b/src/BiliLite.UWP/NoTabMainPage.xaml @@ -45,6 +45,8 @@ Height="40" Margin="0,-4" Click="btnBack_Click" + Background="Transparent" + BorderThickness="0" Visibility="Visible"> Date: Mon, 20 Jan 2025 20:09:53 +0800 Subject: [PATCH 03/12] =?UTF-8?q?#1002=20=E6=90=9C=E7=B4=A2=E9=A1=B5?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=97=B6=E9=95=BF=E5=83=8F=E5=AE=98=E7=BD=91?= =?UTF-8?q?=E4=B8=80=E6=A0=B7=E6=98=BE=E7=A4=BA=E5=B0=8F=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/BiliLite.UWP.csproj | 1 + .../Converters/TimeSpanStrFormatConverter.cs | 41 +++++++++++++++++++ .../Models/Common/Search/SearchVideoItem.cs | 21 +++++++++- src/BiliLite.UWP/Pages/SearchPage.xaml | 8 ++-- 4 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 src/BiliLite.UWP/Converters/TimeSpanStrFormatConverter.cs diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index 7d1456bf9..0344a1bb9 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -194,6 +194,7 @@ + EditPlaySpeedMenuDialog.xaml diff --git a/src/BiliLite.UWP/Converters/TimeSpanStrFormatConverter.cs b/src/BiliLite.UWP/Converters/TimeSpanStrFormatConverter.cs new file mode 100644 index 000000000..cc118cf56 --- /dev/null +++ b/src/BiliLite.UWP/Converters/TimeSpanStrFormatConverter.cs @@ -0,0 +1,41 @@ +using System; + +namespace BiliLite.Converters; + +public static class TimeSpanStrFormatConverter +{ + public static string Convert(string timeSpanStr) + { + // 解析输入字符串 + var parts = timeSpanStr.Split(':'); + + // 根据分部的数量解析时间 + int hours = 0, minutes = 0, seconds = 0; + + switch (parts.Length) + { + case 1: // 只有秒数 + seconds = int.Parse(parts[0]); + break; + case 2: // 分钟和秒数 + minutes = int.Parse(parts[0]); + seconds = int.Parse(parts[1]); + break; + case 3: // 小时、分钟和秒数 + hours = int.Parse(parts[0]); + minutes = int.Parse(parts[1]); + seconds = int.Parse(parts[2]); + break; + default: + throw new ArgumentException("输入字符串格式不正确,应为 '秒'、'分钟:秒' 或 '小时:分钟:秒'。"); + } + + // 创建 TimeSpan 对象 + var timeSpan = new TimeSpan(hours, minutes, seconds); + + // 根据小时是否为0来动态调整格式字符串 + var format = timeSpan.Hours == 0 ? @"mm\:ss" : @"hh\:mm\:ss"; + // 根据指定格式格式化 TimeSpan + return timeSpan.ToString(format); + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Search/SearchVideoItem.cs b/src/BiliLite.UWP/Models/Common/Search/SearchVideoItem.cs index 366f8431b..103c86937 100644 --- a/src/BiliLite.UWP/Models/Common/Search/SearchVideoItem.cs +++ b/src/BiliLite.UWP/Models/Common/Search/SearchVideoItem.cs @@ -1,4 +1,7 @@ -namespace BiliLite.Models.Common.Search +using BiliLite.Converters; +using System; + +namespace BiliLite.Models.Common.Search { public class SearchVideoItem { @@ -24,6 +27,22 @@ public string title public int review { get; set; } public int favorites { get; set; } public string duration { get; set; } + + public string DurationShow + { + get + { + try + { + return TimeSpanStrFormatConverter.Convert(duration); + } + catch (Exception ex) + { + return duration; + } + } + } + private string _pic; public string pic { diff --git a/src/BiliLite.UWP/Pages/SearchPage.xaml b/src/BiliLite.UWP/Pages/SearchPage.xaml index 3567d82a2..23054e0c7 100644 --- a/src/BiliLite.UWP/Pages/SearchPage.xaml +++ b/src/BiliLite.UWP/Pages/SearchPage.xaml @@ -17,7 +17,7 @@ SizeChanged="SearchPage_OnSizeChanged" mc:Ignorable="d"> - + @@ -96,7 +96,7 @@ + Text="{x:Bind DurationShow}" /> @@ -228,7 +228,7 @@ Margin="0,0,0,4" FontSize="14" Foreground="Gray"> - 开播时间: + 开播时间: @@ -684,7 +684,7 @@ Margin="0,4" FontSize="14" Foreground="Gray"> - 时间: + 时间: From 1ba88beea71e9a1e30769371b777011a77e11496 Mon Sep 17 00:00:00 2001 From: ProJend <55018532+ProJend@users.noreply.github.com> Date: Tue, 21 Jan 2025 19:18:15 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E7=AE=80=E5=8C=96OnPropertyChanged?= =?UTF-8?q?=E9=80=9A=E7=94=A8=E4=BA=8B=E4=BB=B6=20(#1007)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/Common/BaseViewModel.cs | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/BiliLite.UWP/ViewModels/Common/BaseViewModel.cs b/src/BiliLite.UWP/ViewModels/Common/BaseViewModel.cs index 22bccb6e7..026939eee 100644 --- a/src/BiliLite.UWP/ViewModels/Common/BaseViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Common/BaseViewModel.cs @@ -1,12 +1,12 @@ -using System; +using BiliLite.Extensions; +using BiliLite.Models; +using BiliLite.Models.Common; +using BiliLite.Services; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Runtime.CompilerServices; -using BiliLite.Extensions; -using BiliLite.Models; -using BiliLite.Models.Common; -using BiliLite.Services; namespace BiliLite.ViewModels.Common { @@ -15,19 +15,9 @@ public class BaseViewModel : INotifyPropertyChanged public event PropertyChangedEventHandler PropertyChanged; private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); - protected void OnPropertyChanged(string propertyName) + protected void OnPropertyChanged([CallerMemberName] string propertyName = null) { - if (PropertyChanged != null) - { - try - { - PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); - } - catch (Exception ex) - { - - } - } + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } protected void OnLocalPropertyChanged(string propertyName) From 2e68477bbc1ff21e78cf39f32b9ce93c751b9d18 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Tue, 21 Jan 2025 19:19:58 +0800 Subject: [PATCH 05/12] =?UTF-8?q?#1003=20=E6=8F=90=E4=BE=9B=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=85=B3=E6=B3=A8=E7=94=A8=E6=88=B7=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E5=8F=AF=E5=9C=A8=E9=A6=96=E9=A1=B5=E7=9B=B4=E6=92=AD?= =?UTF-8?q?=E9=A1=B5=E6=9F=A5=E7=9C=8B=E6=9C=AC=E5=9C=B0=E5=85=B3=E6=B3=A8?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=9A=84=E7=9B=B4=E6=92=AD=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/BiliLite.UWP.csproj | 3 + .../Common/Live/LiveRoomInfoOldModel.cs | 74 ++++++++++++ .../Models/Common/SettingConstants.cs | 3 + .../Models/Common/User/LocalAttentionUser.cs | 8 ++ .../Models/Requests/Api/Live/LiveRoomAPI.cs | 16 +++ .../Live/LiveCenter/LiveAttentionVM.cs | 18 +++ src/BiliLite.UWP/Pages/Home/LivePage.xaml | 66 +++++++++++ src/BiliLite.UWP/Pages/Home/LivePage.xaml.cs | 46 ++++++-- src/BiliLite.UWP/Pages/UserInfoPage.xaml | 12 +- src/BiliLite.UWP/Pages/UserInfoPage.xaml.cs | 12 ++ .../Services/Biz/LocalAttentionUserService.cs | 106 ++++++++++++++++++ .../ViewModels/Home/LiveViewModel.cs | 2 + 12 files changed, 356 insertions(+), 10 deletions(-) create mode 100644 src/BiliLite.UWP/Models/Common/Live/LiveRoomInfoOldModel.cs create mode 100644 src/BiliLite.UWP/Models/Common/User/LocalAttentionUser.cs create mode 100644 src/BiliLite.UWP/Services/Biz/LocalAttentionUserService.cs diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index 0344a1bb9..11220aceb 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -217,6 +217,7 @@ + @@ -237,6 +238,7 @@ + @@ -328,6 +330,7 @@ MessagesPage.xaml + diff --git a/src/BiliLite.UWP/Models/Common/Live/LiveRoomInfoOldModel.cs b/src/BiliLite.UWP/Models/Common/Live/LiveRoomInfoOldModel.cs new file mode 100644 index 000000000..0d8991a8d --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Live/LiveRoomInfoOldModel.cs @@ -0,0 +1,74 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Live; + +public class LiveRoomInfoOldModel +{ + /// + /// 直播间状态 + /// 0:无房间,1:有房间 + /// + [JsonProperty("roomStatus")] + public int RoomStatus { get; set; } + + /// + /// 轮播状态 + /// 0:未轮播,1:轮播 + /// + [JsonProperty("roundStatus")] + public int RoundStatus { get; set; } + + /// + /// 直播状态 + /// 0:未开播,1:直播中 + /// + [JsonProperty("live_status")] + public int LiveStatus { get; set; } + + /// + /// 直播间网页URL + /// + [JsonProperty("url")] + public string Url { get; set; } + + /// + /// 直播间标题 + /// + [JsonProperty("title")] + public string Title { get; set; } + + /// + /// 直播间封面URL + /// + [JsonProperty("cover")] + public string Cover { get; set; } + + /// + /// 直播间人气 + /// 值为上次直播时刷新 + /// + [JsonProperty("online")] + public int Online { get; set; } + + /// + /// 直播间ID(短号) + /// + [JsonProperty("roomid")] + public int RoomId { get; set; } + + /// + /// 广播类型 + /// + [JsonProperty("broadcast_type")] + public int BroadcastType { get; set; } + + /// + /// 在线隐藏状态 + /// + [JsonProperty("online_hidden")] + public int OnlineHidden { get; set; } + + public string UserName { get; set; } + + public string UserId { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/SettingConstants.cs b/src/BiliLite.UWP/Models/Common/SettingConstants.cs index b539aa4f8..cfb2d1cc2 100644 --- a/src/BiliLite.UWP/Models/Common/SettingConstants.cs +++ b/src/BiliLite.UWP/Models/Common/SettingConstants.cs @@ -258,6 +258,9 @@ public class UI /// [SettingDefaultValue] public const bool DEFAULT_ENABLE_OPEN_LAST_PAGE = false; + + [SettingKey] + public const string LOCAL_ATTENTION_USER = "LocalAttentionUser"; } public class Account diff --git a/src/BiliLite.UWP/Models/Common/User/LocalAttentionUser.cs b/src/BiliLite.UWP/Models/Common/User/LocalAttentionUser.cs new file mode 100644 index 000000000..bc53ef8b1 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/User/LocalAttentionUser.cs @@ -0,0 +1,8 @@ +namespace BiliLite.Models.Common.User; + +public class LocalAttentionUser +{ + public string Name { get; set; } + + public string Id { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Requests/Api/Live/LiveRoomAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/Live/LiveRoomAPI.cs index 6e57918e0..2a54a7ac0 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/Live/LiveRoomAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/Live/LiveRoomAPI.cs @@ -447,5 +447,21 @@ public ApiModel GetLiveRoomEmoticon(int room_id) api.parameter += ApiHelper.GetSign(api.parameter, AppKey); return api; } + + /// + /// 获取用户对应的直播间状态 + /// + /// + /// + public ApiModel GetRoomInfoOld(string userId) + { + var api = new ApiModel() + { + method = HttpMethods.Get, + baseUrl = $"https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld", + parameter = $"mid={userId}", + }; + return api; + } } } diff --git a/src/BiliLite.UWP/Modules/Live/LiveCenter/LiveAttentionVM.cs b/src/BiliLite.UWP/Modules/Live/LiveCenter/LiveAttentionVM.cs index aba177a42..34931a018 100644 --- a/src/BiliLite.UWP/Modules/Live/LiveCenter/LiveAttentionVM.cs +++ b/src/BiliLite.UWP/Modules/Live/LiveCenter/LiveAttentionVM.cs @@ -7,17 +7,25 @@ using System.Windows.Input; using Windows.UI.Xaml.Media.Imaging; using BiliLite.Extensions; +using BiliLite.Services; +using BiliLite.Models.Common.Live; +using BiliLite.Services.Biz; +using Microsoft.Extensions.DependencyInjection; namespace BiliLite.Modules.Live.LiveCenter { public class LiveAttentionVM : IModules { readonly LiveCenterAPI liveCenterAPI; + private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); public LiveAttentionVM() { liveCenterAPI = new LiveCenterAPI(); RefreshCommand = new RelayCommand(Refresh); } + + public ObservableCollection LocalFollows { get; set; } + private ObservableCollection _Follow; public ObservableCollection Follow @@ -70,6 +78,15 @@ public async Task GetFollows() Loading = false; } } + + public async Task GetLocalFollows() + { + var localAttentionUserService = App.ServiceProvider.GetRequiredService(); + var roomList = await localAttentionUserService.GetLiveRooms(); + if (roomList == null) return; + LocalFollows = new ObservableCollection(roomList); + } + public async void Refresh() { if (Loading) @@ -78,6 +95,7 @@ public async void Refresh() } Follow = null; await GetFollows(); + await GetLocalFollows(); } } public class LiveFollowAnchorModel diff --git a/src/BiliLite.UWP/Pages/Home/LivePage.xaml b/src/BiliLite.UWP/Pages/Home/LivePage.xaml index f383af2b2..647f4dbad 100644 --- a/src/BiliLite.UWP/Pages/Home/LivePage.xaml +++ b/src/BiliLite.UWP/Pages/Home/LivePage.xaml @@ -13,6 +13,7 @@ xmlns:winui="using:Microsoft.UI.Xaml.Controls" xmlns:fa="using:FontAwesome5" xmlns:home="using:BiliLite.Models.Common.Home" + xmlns:live1="using:BiliLite.Models.Common.Live" Background="Transparent"> @@ -56,6 +57,71 @@ + + + 本地关注的直播 + + + + + + + + + + + + + + + + + + + + + + 取消本地关注 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 关注的直播 diff --git a/src/BiliLite.UWP/Pages/Home/LivePage.xaml.cs b/src/BiliLite.UWP/Pages/Home/LivePage.xaml.cs index 423a9750d..cd6097861 100644 --- a/src/BiliLite.UWP/Pages/Home/LivePage.xaml.cs +++ b/src/BiliLite.UWP/Pages/Home/LivePage.xaml.cs @@ -11,7 +11,10 @@ using Windows.UI.Xaml.Navigation; using BiliLite.Models.Common.Home; using BiliLite.ViewModels.Home; +using Microsoft.EntityFrameworkCore.Internal; using Microsoft.Extensions.DependencyInjection; +using BiliLite.Services.Biz; +using BiliLite.Models.Common.Live; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -52,6 +55,11 @@ private async Task LoadData() { m_viewModel.ShowFollows = true; await m_viewModel.LiveAttentionVm.GetFollows(); + await m_viewModel.LiveAttentionVm.GetLocalFollows(); + if (m_viewModel.LiveAttentionVm.LocalFollows != null && m_viewModel.LiveAttentionVm.LocalFollows.Any()) + { + m_viewModel.ShowLocalFollows = true; + } } } @@ -81,14 +89,26 @@ private async void RefreshContainer_RefreshRequested(Microsoft.UI.Xaml.Controls. private void FollowLive_ItemClick(object sender, ItemClickEventArgs e) { - var data = e.ClickedItem as LiveFollowAnchorModel; - MessageCenter.NavigateToPage(this, new NavigationInfo() + if (e.ClickedItem is LiveFollowAnchorModel data) { - icon = Symbol.Video, - page = typeof(LiveDetailPage), - title = data.uname + "的直播间", - parameters = data.roomid - }); + MessageCenter.NavigateToPage(this, new NavigationInfo() + { + icon = Symbol.Video, + page = typeof(LiveDetailPage), + title = data.uname + "的直播间", + parameters = data.roomid + }); + } + else if(e.ClickedItem is LiveRoomInfoOldModel info) + { + MessageCenter.NavigateToPage(this, new NavigationInfo() + { + icon = Symbol.Video, + page = typeof(LiveDetailPage), + title = info.UserName + "的直播间", + parameters = info.RoomId + }); + } } private void LiveItems_ItemClick(object sender, ItemClickEventArgs e) @@ -186,5 +206,17 @@ private async void btnOpenLiveCenter_Click(object sender, RoutedEventArgs e) }); } + + private void CancelLocalAttention_OnClick(object sender, RoutedEventArgs e) + { + if (sender is not FrameworkElement { DataContext: LiveRoomInfoOldModel roomInfo }) + { + return; + } + + var localAttentionUserService = App.ServiceProvider.GetRequiredService(); + localAttentionUserService.CancelAttention(roomInfo.UserId); + m_viewModel.LiveAttentionVm.LocalFollows.Remove(roomInfo); + } } } diff --git a/src/BiliLite.UWP/Pages/UserInfoPage.xaml b/src/BiliLite.UWP/Pages/UserInfoPage.xaml index ce265afb7..5df53fc21 100644 --- a/src/BiliLite.UWP/Pages/UserInfoPage.xaml +++ b/src/BiliLite.UWP/Pages/UserInfoPage.xaml @@ -61,7 +61,11 @@ - + + + 设置本地关注 + 取消本地关注 + @@ -596,7 +600,8 @@ + Visibility="{x:Bind Path=m_viewModel.IsFollowed,Mode=OneWay,Converter={StaticResource display}}" + ContextFlyout="{StaticResource AttentionContextManu}"> @@ -608,7 +613,8 @@ + Visibility="{x:Bind Path=m_viewModel.IsFollowed,Mode=OneWay}" + ContextFlyout="{StaticResource AttentionContextManu}"> diff --git a/src/BiliLite.UWP/Pages/UserInfoPage.xaml.cs b/src/BiliLite.UWP/Pages/UserInfoPage.xaml.cs index 3228a12c4..24fd6c2eb 100644 --- a/src/BiliLite.UWP/Pages/UserInfoPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/UserInfoPage.xaml.cs @@ -499,5 +499,17 @@ public void UpdatePivotLayout() pivot.UseLayoutRounding = !pivot.UseLayoutRounding; pivot.UseLayoutRounding = !pivot.UseLayoutRounding; } + + private void BtnSetLocalAttention_OnClick(object sender, RoutedEventArgs e) + { + var localAttentionUserService = App.ServiceProvider.GetRequiredService(); + localAttentionUserService.AttentionUp(m_viewModel.Mid, m_viewModel.UserSpaceInfo.Name); + } + + private void BtnCancelLocalAttention_OnClick(object sender, RoutedEventArgs e) + { + var localAttentionUserService = App.ServiceProvider.GetRequiredService(); + localAttentionUserService.CancelAttention(m_viewModel.Mid); + } } } diff --git a/src/BiliLite.UWP/Services/Biz/LocalAttentionUserService.cs b/src/BiliLite.UWP/Services/Biz/LocalAttentionUserService.cs new file mode 100644 index 000000000..bbdd6fd16 --- /dev/null +++ b/src/BiliLite.UWP/Services/Biz/LocalAttentionUserService.cs @@ -0,0 +1,106 @@ +using BiliLite.Models.Attributes; +using BiliLite.Models.Common.User; +using BiliLite.Models.Common; +using BiliLite.ViewModels.User.SendDynamic; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using BiliLite.Extensions; +using BiliLite.Models.Common.Live; +using BiliLite.Models.Requests.Api.Live; + +namespace BiliLite.Services.Biz; + +[RegisterTransientService] +public class LocalAttentionUserService : BaseBizService +{ + private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); + + public void AttentionUp(string id, string name) + { + var user = new LocalAttentionUser() + { + Id = id, + Name = name, + }; + var localAttentionUsers = SettingService.GetValue>(SettingConstants.UI.LOCAL_ATTENTION_USER, null); + if (localAttentionUsers == null) + { + localAttentionUsers = new List(); + } + + if (localAttentionUsers.Count > 5) + { + Notify.ShowMessageToast("本地关注人数超出限制"); + return; + } + + if (localAttentionUsers.Any(x => x.Id == user.Id)) + { + Notify.ShowMessageToast("已经关注了"); + return; + } + localAttentionUsers.Add(user); + SettingService.SetValue>(SettingConstants.UI.LOCAL_ATTENTION_USER, localAttentionUsers); + Notify.ShowMessageToast("已关注"); + } + + public void CancelAttention(string id) + { + var localAttentionUsers = SettingService.GetValue>(SettingConstants.UI.LOCAL_ATTENTION_USER, null); + if (localAttentionUsers == null) + { + return; + } + + var user = localAttentionUsers.FirstOrDefault(x => x.Id == id); + if (user == null) + { + return; + } + + localAttentionUsers.Remove(user); + SettingService.SetValue>(SettingConstants.UI.LOCAL_ATTENTION_USER, localAttentionUsers); + + Notify.ShowMessageToast("已取消关注"); + } + + public async Task> GetLiveRooms() + { + + var localAttentionUsers = SettingService.GetValue>(SettingConstants.UI.LOCAL_ATTENTION_USER, null); + if (localAttentionUsers == null || !localAttentionUsers.Any()) + { + return null; + } + + var roomList = new List(); + + foreach (var user in localAttentionUsers) + { + var api = new LiveRoomAPI().GetRoomInfoOld(user.Id); + var results = await api.Request(); + if (!results.status) + { + _logger.Warn(results.message); + continue; + } + + var data = await results.GetData(); + if (!data.success) + { + _logger.Warn(data.message); + continue; + } + + if (data.data.RoomStatus == 0) continue; + + data.data.UserName = user.Name; + data.data.UserId = user.Id; + + roomList.Add(data.data); + } + + return roomList; + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/ViewModels/Home/LiveViewModel.cs b/src/BiliLite.UWP/ViewModels/Home/LiveViewModel.cs index 5f5b5523b..c322a8b99 100644 --- a/src/BiliLite.UWP/ViewModels/Home/LiveViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Home/LiveViewModel.cs @@ -42,6 +42,8 @@ public LiveViewModel() public bool ShowFollows { get; set; } + public bool ShowLocalFollows { get; set; } + public bool Loading { get; set; } public bool LoadingFollow { get; set; } = true; From 8be4850c8ca3eb2ab65134fb6e4aceda0b1cc58d Mon Sep 17 00:00:00 2001 From: ProJend <55018532+ProJend@users.noreply.github.com> Date: Sun, 26 Jan 2025 17:28:51 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E5=B0=86=E8=A7=86=E9=A2=91=E5=86=85?= =?UTF-8?q?=E7=9A=84ComboBox=E6=8E=A7=E4=BB=B6=E6=9B=B4=E6=8D=A2=E4=B8=BAS?= =?UTF-8?q?lider=E6=8E=A7=E4=BB=B6=20(#991)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/BiliLite.UWP.csproj | 17 +- src/BiliLite.UWP/Controls/PlayerControl.xaml | 360 +++--------------- .../Controls/PlayerControl.xaml.cs | 340 ++++++++++------- .../Settings/PlaySettingsControl.xaml | 64 ++-- .../Settings/PlaySettingsControl.xaml.cs | 20 +- .../LiveLineSliderTooltipConverter.cs | 27 ++ .../LiveQualitySliderTooltipConverter.cs | 27 ++ .../PlaySpeedSliderTooltipConverter.cs | 31 ++ .../QualitySliderTooltipConverter.cs | 27 ++ .../SoundQualitySliderTooltipConverter.cs | 27 ++ .../Dialogs/EditPlaySpeedMenuDialog.xaml | 73 ++-- .../Dialogs/EditPlaySpeedMenuDialog.xaml.cs | 30 +- .../Models/Common/Player/PlaySpeedMenu.cs | 12 +- .../Player/Playurl/BiliPlayUrlRequest.cs | 24 +- src/BiliLite.UWP/Pages/LiveDetailPage.xaml | 320 ++-------------- src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs | 103 +++-- .../Services/PlaySpeedMenuService.cs | 33 +- .../ViewModels/Live/LiveRoomViewModel.cs | 33 +- .../Settings/EditPlaySpeedMenuViewModel.cs | 6 +- 19 files changed, 702 insertions(+), 872 deletions(-) create mode 100644 src/BiliLite.UWP/Converters/LiveLineSliderTooltipConverter.cs create mode 100644 src/BiliLite.UWP/Converters/LiveQualitySliderTooltipConverter.cs create mode 100644 src/BiliLite.UWP/Converters/PlaySpeedSliderTooltipConverter.cs create mode 100644 src/BiliLite.UWP/Converters/QualitySliderTooltipConverter.cs create mode 100644 src/BiliLite.UWP/Converters/SoundQualitySliderTooltipConverter.cs diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index 11220aceb..e47f22e19 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -1,6 +1,8 @@  - - + + Debug x86 @@ -194,6 +196,11 @@ + + + + + EditPlaySpeedMenuDialog.xaml @@ -1746,10 +1753,12 @@ Windows Desktop Extensions for the UWP - + 14.0 - + - - - - + + - - - - + - + - - - - + + + + + + + + + + + + + + + + + - - - - - - - @@ -176,19 +197,6 @@ - - - - - - - - - - - - @@ -221,14 +229,6 @@ - - - - - - - diff --git a/src/BiliLite.UWP/Controls/Settings/PlaySettingsControl.xaml.cs b/src/BiliLite.UWP/Controls/Settings/PlaySettingsControl.xaml.cs index fa4ccc714..64beed545 100644 --- a/src/BiliLite.UWP/Controls/Settings/PlaySettingsControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/Settings/PlaySettingsControl.xaml.cs @@ -1,14 +1,14 @@ using BiliLite.Dialogs; -using Microsoft.Extensions.DependencyInjection; -using System; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; using BiliLite.Models.Common; +using BiliLite.Models.Common.Player; using BiliLite.Services; using BiliLite.ViewModels.Settings; +using Microsoft.Extensions.DependencyInjection; +using System; using System.Linq; using System.Threading.Tasks; -using BiliLite.Models.Common.Player; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; //https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板 @@ -55,6 +55,16 @@ private void LoadPlayer() { cbVideoSpeed.SelectionChanged += (obj, args) => { + if (cbVideoSpeed.SelectedIndex == -1) // 空值初始化 + { + speeds = m_playSpeedMenuService.MenuItems + .Select(x => x.Value) + .ToList(); + SettingService.SetValue(SettingConstants.Player.DEFAULT_VIDEO_SPEED, 0); + cbVideoSpeed.SelectedIndex = 0; + return; + } + SettingService.SetValue(SettingConstants.Player.DEFAULT_VIDEO_SPEED, speeds[cbVideoSpeed.SelectedIndex]); }; }; diff --git a/src/BiliLite.UWP/Converters/LiveLineSliderTooltipConverter.cs b/src/BiliLite.UWP/Converters/LiveLineSliderTooltipConverter.cs new file mode 100644 index 000000000..70150a491 --- /dev/null +++ b/src/BiliLite.UWP/Converters/LiveLineSliderTooltipConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using Windows.UI.Xaml.Data; +using BiliLite.Models.Common.Player; + +namespace BiliLite.Converters; + +public class LiveLineSliderTooltipConverter : IValueConverter +{ + public List Lines { get; set; } + + public object Convert(object value, Type targetType, object parameter, string language) + { + if (value is double sliderValue) + { + return sliderValue >= 0 && sliderValue < Lines.Count + ? Lines[(int)sliderValue].Name + : sliderValue.ToString(); + } + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + return value; + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Converters/LiveQualitySliderTooltipConverter.cs b/src/BiliLite.UWP/Converters/LiveQualitySliderTooltipConverter.cs new file mode 100644 index 000000000..057084576 --- /dev/null +++ b/src/BiliLite.UWP/Converters/LiveQualitySliderTooltipConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using Windows.UI.Xaml.Data; +using BiliLite.Models.Common.Live; + +namespace BiliLite.Converters; + +public class LiveQualitySliderTooltipConverter : IValueConverter +{ + public List Qualites { get; set; } + + public object Convert(object value, Type targetType, object parameter, string language) + { + if (value is double sliderValue) + { + return sliderValue >= 0 && sliderValue < Qualites.Count + ? Qualites[(int)sliderValue].Desc + : sliderValue.ToString(); + } + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + return value; + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Converters/PlaySpeedSliderTooltipConverter.cs b/src/BiliLite.UWP/Converters/PlaySpeedSliderTooltipConverter.cs new file mode 100644 index 000000000..512c96386 --- /dev/null +++ b/src/BiliLite.UWP/Converters/PlaySpeedSliderTooltipConverter.cs @@ -0,0 +1,31 @@ +using System; +using BiliLite.Services; +using Windows.UI.Xaml.Data; + +namespace BiliLite.Converters; + +public class PlaySpeedSliderTooltipConverter : IValueConverter +{ + private readonly PlaySpeedMenuService m_playSpeedMenuService; + + public PlaySpeedSliderTooltipConverter(PlaySpeedMenuService playSpeedMenuService) + { + m_playSpeedMenuService = playSpeedMenuService; + } + + public object Convert(object value, Type targetType, object parameter, string language) + { + if (value is double sliderValue) + { + return sliderValue >= 0 && sliderValue < m_playSpeedMenuService.MenuItems.Count + ? m_playSpeedMenuService.MenuItems[(int)sliderValue].Content + : sliderValue.ToString(); + } + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + return value; + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Converters/QualitySliderTooltipConverter.cs b/src/BiliLite.UWP/Converters/QualitySliderTooltipConverter.cs new file mode 100644 index 000000000..9410f8cb3 --- /dev/null +++ b/src/BiliLite.UWP/Converters/QualitySliderTooltipConverter.cs @@ -0,0 +1,27 @@ +using System; +using BiliLite.Models.Common.Video.PlayUrlInfos; +using System.Collections.Generic; +using Windows.UI.Xaml.Data; + +namespace BiliLite.Converters; + +public class QualitySliderTooltipConverter : IValueConverter +{ + public List Qualites { get; set; } + + public object Convert(object value, Type targetType, object parameter, string language) + { + if (value is double sliderValue) + { + return sliderValue >= 0 && sliderValue < Qualites.Count + ? Qualites[(int)sliderValue].QualityName + : sliderValue.ToString(); + } + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + return value; + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Converters/SoundQualitySliderTooltipConverter.cs b/src/BiliLite.UWP/Converters/SoundQualitySliderTooltipConverter.cs new file mode 100644 index 000000000..43d3d74a8 --- /dev/null +++ b/src/BiliLite.UWP/Converters/SoundQualitySliderTooltipConverter.cs @@ -0,0 +1,27 @@ +using BiliLite.Models.Common.Video.PlayUrlInfos; +using System; +using System.Collections.Generic; +using Windows.UI.Xaml.Data; + +namespace BiliLite.Converters; + +public class SoundQualitySliderTooltipConverter : IValueConverter +{ + public List AudioQualites { get; set; } + + public object Convert(object value, Type targetType, object parameter, string language) + { + if (value is double sliderValue) + { + return sliderValue >= 0 && sliderValue < AudioQualites.Count + ? AudioQualites[(int)sliderValue].QualityName + : sliderValue.ToString(); + } + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + return value; + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Dialogs/EditPlaySpeedMenuDialog.xaml b/src/BiliLite.UWP/Dialogs/EditPlaySpeedMenuDialog.xaml index bbeb2c6cc..21485cf28 100644 --- a/src/BiliLite.UWP/Dialogs/EditPlaySpeedMenuDialog.xaml +++ b/src/BiliLite.UWP/Dialogs/EditPlaySpeedMenuDialog.xaml @@ -2,41 +2,70 @@ x:Class="BiliLite.Dialogs.EditPlaySpeedMenuDialog" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:local="using:BiliLite.Dialogs" + xmlns:controls="using:Microsoft.UI.Xaml.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="using:BiliLite.Dialogs" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:player="using:BiliLite.Models.Common.Player" - xmlns:controls="using:Microsoft.UI.Xaml.Controls" - mc:Ignorable="d" - Title="编辑播放速度菜单" - PrimaryButtonText="确定" + Title="自定义播放倍速" CloseButtonText="取消" - PrimaryButtonClick="ContentDialog_PrimaryButtonClick"> + PrimaryButtonClick="ContentDialog_PrimaryButtonClick" + PrimaryButtonText="确定" + mc:Ignorable="d"> - - + + - - - - - - + + + + - + - - + + - - + + - + diff --git a/src/BiliLite.UWP/Dialogs/EditPlaySpeedMenuDialog.xaml.cs b/src/BiliLite.UWP/Dialogs/EditPlaySpeedMenuDialog.xaml.cs index c093c7787..23f68aa9d 100644 --- a/src/BiliLite.UWP/Dialogs/EditPlaySpeedMenuDialog.xaml.cs +++ b/src/BiliLite.UWP/Dialogs/EditPlaySpeedMenuDialog.xaml.cs @@ -1,10 +1,12 @@ -using System.Collections.ObjectModel; -using System.Linq; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Input; +using BiliLite.Extensions; using BiliLite.Models.Common.Player; using BiliLite.Services; using BiliLite.ViewModels.Settings; +using System.Collections.ObjectModel; +using System.Linq; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Input; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“内容对话框”项模板 @@ -12,6 +14,8 @@ namespace BiliLite.Dialogs { public sealed partial class EditPlaySpeedMenuDialog : ContentDialog { + public double DialogHeight => Window.Current.Bounds.Height * 0.7; + private readonly EditPlaySpeedMenuViewModel m_viewModel; private readonly PlaySpeedMenuService m_playSpeedMenuService; @@ -38,9 +42,23 @@ private void BtnRemovePlaySpeed_OnTapped(object sender, TappedRoutedEventArgs e) private void BtnAddPlaySpeed_OnTapped(object sender, TappedRoutedEventArgs e) { + foreach (PlaySpeedMenuItem item in m_viewModel.PlaySpeedMenuItems) + { + if (item.Value == m_viewModel.AddPlaySpeedValue) + { + Notify.ShowMessageToast("已重复添加"); + return; + } + } + if (m_viewModel.AddPlaySpeedValue == 0) + { + Notify.ShowMessageToast("非法参数"); + return; + } + m_viewModel.PlaySpeedMenuItems.Add(new PlaySpeedMenuItem(m_viewModel.AddPlaySpeedValue)); - m_viewModel.PlaySpeedMenuItems = - new ObservableCollection(m_viewModel.PlaySpeedMenuItems.OrderByDescending(x => x.Value)); + m_viewModel.PlaySpeedMenuItems = + new ObservableCollection(m_viewModel.PlaySpeedMenuItems.OrderBy(x => x.Value)); } } } diff --git a/src/BiliLite.UWP/Models/Common/Player/PlaySpeedMenu.cs b/src/BiliLite.UWP/Models/Common/Player/PlaySpeedMenu.cs index bad6e73f7..104134337 100644 --- a/src/BiliLite.UWP/Models/Common/Player/PlaySpeedMenu.cs +++ b/src/BiliLite.UWP/Models/Common/Player/PlaySpeedMenu.cs @@ -1,14 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BiliLite.Models.Common.Player +namespace BiliLite.Models.Common.Player { public class PlaySpeedMenuItem { - public PlaySpeedMenuItem(){} + public PlaySpeedMenuItem() { } public PlaySpeedMenuItem(double value) { @@ -18,5 +12,7 @@ public PlaySpeedMenuItem(double value) public string Content => Value + "x"; public double Value { get; set; } + + public bool IsDeletable => Value != 1; } } diff --git a/src/BiliLite.UWP/Modules/Player/Playurl/BiliPlayUrlRequest.cs b/src/BiliLite.UWP/Modules/Player/Playurl/BiliPlayUrlRequest.cs index af285ba0e..26ff77ce4 100644 --- a/src/BiliLite.UWP/Modules/Player/Playurl/BiliPlayUrlRequest.cs +++ b/src/BiliLite.UWP/Modules/Player/Playurl/BiliPlayUrlRequest.cs @@ -1,21 +1,21 @@ -using Newtonsoft.Json.Linq; +using Bilibili.App.Playurl.V1; +using BiliLite.Extensions; +using BiliLite.gRPC.Api; +using BiliLite.Models.Common; +using BiliLite.Models.Common.Video; +using BiliLite.Models.Common.Video.PlayUrlInfos; +using BiliLite.Models.Requests.Api; +using BiliLite.Services; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Net.Http; using System.Text.RegularExpressions; using System.Threading.Tasks; -using System.Net.Http; -using Bilibili.App.Playurl.V1; -using BiliLite.Extensions; -using BiliLite.Models.Requests.Api; -using BiliLite.Services; -using BiliLite.Models.Common; -using BiliLite.Models.Common.Video; -using BiliLite.Models.Common.Video.PlayUrlInfos; using PlayURL = BiliLite.gRPC.Api.PlayURL; -using BiliLite.gRPC.Api; namespace BiliLite.Modules.Player.Playurl { @@ -124,6 +124,7 @@ private void ParseBiliPlayUrlInfoSupportFormats(BiliPlayUrlQualitesInfo info, JO HasPlayUrl = false, }); } + info.Qualites = [.. info.Qualites.OrderBy(x => x.QualityID)]; } private async Task ParseBiliPlayUrlInfoAudioDash(BiliPlayUrlQualitesInfo info, JObject playUrlInfoResult, @@ -178,6 +179,9 @@ private async Task ParseBiliPlayUrlInfoAudioDash(BiliPlayUrlQualit Audio = audio.ToBiliDashItem(), }); } + + info.AudioQualites = [.. info.AudioQualites.OrderBy(x => x.QualityID)]; + // 处理无损音质 if (flacAudio is { Display: true, Audio: { } }) { diff --git a/src/BiliLite.UWP/Pages/LiveDetailPage.xaml b/src/BiliLite.UWP/Pages/LiveDetailPage.xaml index 5ca4fa14f..d64edd73e 100644 --- a/src/BiliLite.UWP/Pages/LiveDetailPage.xaml +++ b/src/BiliLite.UWP/Pages/LiveDetailPage.xaml @@ -24,267 +24,6 @@ - @@ -728,36 +467,51 @@ - - - - - - - + + + diff --git a/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs index 714ed45bc..9da8e1d5a 100644 --- a/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs @@ -1,4 +1,5 @@ using BiliLite.Controls; +using BiliLite.Converters; using BiliLite.Extensions; using BiliLite.Models.Common; using BiliLite.Models.Common.Live; @@ -33,6 +34,7 @@ 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.Imaging; using Windows.UI.Xaml.Navigation; @@ -56,9 +58,12 @@ public sealed partial class LiveDetailPage : BasePage, IPlayPage, IUpdatePivotLa private readonly bool m_useNsDanmaku = true; private readonly IDanmakuController m_danmakuController; private readonly LiveSettingsControlViewModel m_liveSettingsControlViewModel; + private readonly LiveQualitySliderTooltipConverter m_liveQualitySliderTooltipConverter; + private readonly LiveLineSliderTooltipConverter m_liveLineSliderTooltipConverter; DisplayRequest dispRequest; LiveRoomViewModel m_liveRoomViewModel; + List basePlayUrls; DispatcherTimer timer_focus; DispatcherTimer controlTimer; DispatcherTimer chatScrollTimer; @@ -129,6 +134,9 @@ public LiveDetailPage() this.Loaded += LiveDetailPage_Loaded; this.Unloaded += LiveDetailPage_Unloaded; + m_liveQualitySliderTooltipConverter = new LiveQualitySliderTooltipConverter(); + m_liveLineSliderTooltipConverter = new LiveLineSliderTooltipConverter(); + m_useNsDanmaku = (DanmakuEngineType)SettingService.GetValue(SettingConstants.Live.DANMAKU_ENGINE, (int)SettingConstants.Live.DEFAULT_DANMAKU_ENGINE) == DanmakuEngineType.NSDanmaku; if (m_useNsDanmaku) @@ -432,33 +440,88 @@ private void SetMediaInfo() #endregion + #region Slider private void LiveRoomViewModelChangedPlayUrl(object sender, EventArgs e) { changePlayUrlFlag = true; + InitSliderQuality(); + InitSliderLine(); + changePlayUrlFlag = false; + } + + private void InitSliderQuality() + { + if (m_liveRoomViewModel.Qualites.IndexOf(m_liveRoomViewModel.CurrentQn) == -1) + { + return; // 空值检查 + } + + MinQuality.Text = m_liveRoomViewModel.Qualites[0].Desc; + MaxQuality.Text = m_liveRoomViewModel.Qualites[m_liveRoomViewModel.Qualites.Count - 1].Desc; + + BottomBtnQuality.IsEnabled = m_liveRoomViewModel.Qualites.Count > 1; + BottomBtnQuality.Content = m_liveRoomViewModel.CurrentQn.Desc; + SliderQuality.Maximum = m_liveRoomViewModel.Qualites.Count - 1; + SliderQuality.Value = m_liveRoomViewModel.Qualites.IndexOf(m_liveRoomViewModel.CurrentQn); + m_liveQualitySliderTooltipConverter.Qualites = m_liveRoomViewModel.Qualites; + SliderQuality.ThumbToolTipValueConverter = m_liveQualitySliderTooltipConverter; + } + private async void SliderQuality_ValueChanged(object sender, RangeBaseValueChangedEventArgs e) + { + if (changePlayUrlFlag) + { + return; + } + + var item = m_liveRoomViewModel.Qualites[(int)SliderQuality.Value]; + SettingService.SetValue(SettingConstants.Live.DEFAULT_QUALITY, item.Qn); + await m_liveRoomViewModel.GetPlayUrls(m_liveRoomViewModel.RoomID, item.Qn); + BottomBtnQuality.Content = item.Desc; + } + + private void InitSliderLine() + { m_realPlayInfo.PlayUrls.HlsUrls = m_liveRoomViewModel.HlsUrls; m_realPlayInfo.PlayUrls.FlvUrls = m_liveRoomViewModel.FlvUrls; - var urls = m_liveRoomViewModel.HlsUrls ?? m_liveRoomViewModel.FlvUrls; - BottomCBLine.ItemsSource = urls; + basePlayUrls = m_liveRoomViewModel.HlsUrls ?? m_liveRoomViewModel.FlvUrls; + + BottomBtnLine.IsEnabled = basePlayUrls.Count > 1; + + MinLine.Text = basePlayUrls[0].Name; + MaxLine.Text = basePlayUrls[basePlayUrls.Count - 1].Name; + SliderLine.Maximum = basePlayUrls.Count - 1; + m_liveLineSliderTooltipConverter.Lines = basePlayUrls; + SliderLine.ThumbToolTipValueConverter = m_liveLineSliderTooltipConverter; var flag = false; - for (var i = 0; i < urls.Count; i++) + for (var i = 0; i < basePlayUrls.Count; i++) { - var domain = new Uri(urls[i].Url).Host; + var domain = new Uri(basePlayUrls[i].Url).Host; if (domain.Contains(m_viewModel.LivePlayUrlSource) && !flag) { - BottomCBLine.SelectedIndex = i; + BottomBtnLine.Content = basePlayUrls[i].Name; + SliderLine.Value = i + 1; // 强制触发 SliderLine_ValueChanged 事件 + SliderLine.Value = i; + flag = true; } } if (!flag) { - BottomCBLine.SelectedIndex = 0; + BottomBtnLine.Content = basePlayUrls[0].Name; + SliderLine.Value = 0 + 1; + SliderLine.Value = 0; } + } - BottomCBQuality.SelectedItem = m_liveRoomViewModel.CurrentQn; - changePlayUrlFlag = false; + private async void SliderLine_ValueChanged(object sender, RangeBaseValueChangedEventArgs e) + { + BottomBtnLine.Content = basePlayUrls[(int)SliderLine.Value].Name; + + m_playerConfig.SelectedRouteLine = (int)SliderLine.Value; + await LoadPlayer(); } private async Task StopPlay() @@ -474,6 +537,7 @@ private async Task StopPlay() SetFullScreen(false); MiniWidnows(false); } + #endregion string roomid; @@ -701,29 +765,6 @@ private async Task LoadPlayer() } } - private async void BottomCBQuality_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - if (BottomCBQuality.SelectedItem == null || changePlayUrlFlag) - { - return; - } - var item = BottomCBQuality.SelectedItem as LiveRoomWebUrlQualityDescriptionItemModel; - SettingService.SetValue(SettingConstants.Live.DEFAULT_QUALITY, item.Qn); - await m_liveRoomViewModel.GetPlayUrls(m_liveRoomViewModel.RoomID, item.Qn); - } - - private async void BottomCBLine_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - if (BottomCBLine.SelectedIndex == -1) - { - return; - } - - m_playerConfig.SelectedRouteLine = BottomCBLine.SelectedIndex; - - await LoadPlayer(); - } - private async void BottomBtnPause_Click(object sender, RoutedEventArgs e) { await m_playerController.PauseState.Pause(); diff --git a/src/BiliLite.UWP/Services/PlaySpeedMenuService.cs b/src/BiliLite.UWP/Services/PlaySpeedMenuService.cs index 24e1433bb..68c2ff6c0 100644 --- a/src/BiliLite.UWP/Services/PlaySpeedMenuService.cs +++ b/src/BiliLite.UWP/Services/PlaySpeedMenuService.cs @@ -1,17 +1,19 @@ -using BiliLite.Models.Common.Player; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; using BiliLite.Models.Common; +using BiliLite.Models.Common.Player; +using System.Collections.ObjectModel; +using System.Linq; namespace BiliLite.Services { public class PlaySpeedMenuService { + public List MenuItems { get; private set; } + public PlaySpeedMenuService() { MenuItems = SettingService.GetValue(SettingConstants.Player.PLAY_SPEED_MENU, GetDefaultPlaySpeedMenu()); } - public List MenuItems { get; private set; } public void SetMenuItems(List menuItems) { @@ -19,17 +21,24 @@ public void SetMenuItems(List menuItems) SettingService.SetValue(SettingConstants.Player.PLAY_SPEED_MENU, menuItems); } + public int SpeedIndexOf(double speed) + { + return MenuItems.FindIndex(x => x.Value == speed); + } + private List GetDefaultPlaySpeedMenu() { - return new List() + return [.. new ObservableCollection() { - new PlaySpeedMenuItem(0.5), - new PlaySpeedMenuItem(0.75), - new PlaySpeedMenuItem(1.0), - new PlaySpeedMenuItem(1.25), - new PlaySpeedMenuItem(1.5), - new PlaySpeedMenuItem(2.0), - }.OrderByDescending(x => x.Value).ToList(); + new(0.25), + new(0.5), + new(0.75), + new(1.0), + new(1.25), + new(1.5), + new(1.75), + new(2.0), + }]; } } } diff --git a/src/BiliLite.UWP/ViewModels/Live/LiveRoomViewModel.cs b/src/BiliLite.UWP/ViewModels/Live/LiveRoomViewModel.cs index 9b541b84a..3398f57a1 100644 --- a/src/BiliLite.UWP/ViewModels/Live/LiveRoomViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Live/LiveRoomViewModel.cs @@ -1,12 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using System.Timers; -using System.Windows.Input; -using BiliLite.Extensions; +using BiliLite.Extensions; using BiliLite.Models; using BiliLite.Models.Common; using BiliLite.Models.Common.Live; @@ -21,6 +13,14 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PropertyChanged; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Timers; +using System.Windows.Input; using DateTime = System.DateTime; namespace BiliLite.ViewModels.Live @@ -161,7 +161,7 @@ public LiveRoomViewModel() public bool ShowBag { get; set; } public List Ranks { get; set; } - + public LiveRoomRankViewModel SelectRank { get; set; } [DoNotNotify] @@ -228,7 +228,7 @@ public LiveRoomViewModel() public string ManualPlayUrl { get; set; } = ""; [DoNotNotify] - public Dictionary LotteryDanmu = new Dictionary { { "AnchorLottery", "" }, {"RedPocketLottery", ""} }; + public Dictionary LotteryDanmu = new Dictionary { { "AnchorLottery", "" }, { "RedPocketLottery", "" } }; /// /// 有的特殊直播间没有一些娱乐内容. 例如央视新闻直播间. @@ -269,7 +269,7 @@ private LiveMessageHandleActionsMap InitLiveMessageHandleActionMap() actionMap.AddNewDanmu += (_, e) => { AddNewDanmu?.Invoke(this, e); - }; + }; actionMap.AnchorLotteryEnd += (_, e) => { AnchorLotteryEnd?.Invoke(this, e); @@ -364,7 +364,7 @@ private async void Timer_SuperChats_Elapsed(object sender, ElapsedEventArgs e) { await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { - for(int i = 0; i < SuperChats.Count; i++) + for (int i = 0; i < SuperChats.Count; i++) { if (SuperChats.ElementAt(i).Time <= 0) SuperChats.RemoveAt(i); else SuperChats.ElementAt(i).Time -= 1; @@ -480,15 +480,16 @@ private List GetSpecialPlayUrls(LiveRoomPlayUrlModel liveRoomPl var acceptQnList = codec.AcceptQn; Qualites ??= liveRoomPlayUrlModel.PlayUrlInfo.PlayUrl.GQnDesc.Where(item => acceptQnList.Contains(item.Qn)).ToList(); + Qualites = [.. Qualites.OrderBy(x => x.Qn)]; CurrentQn = liveRoomPlayUrlModel.PlayUrlInfo.PlayUrl.GQnDesc.FirstOrDefault(x => x.Qn == codec.CurrentQn); var urlList = codec.UrlInfo.Select(urlInfo => new BasePlayUrlInfo - { Url = urlInfo.Host + codec.BaseUrl + urlInfo.Extra, Name = urlInfo.Name }).ToList(); + { Url = urlInfo.Host + codec.BaseUrl + urlInfo.Extra, Name = urlInfo.Name }).ToList(); var regex = new Regex(@"live_\d+_\d+\.flv"); foreach (var item in urlList) { - if (regex.IsMatch(item.Url)) + if (regex.IsMatch(item.Url)) { SetManualPlayUrl?.Invoke(this, item.Url); break; @@ -1347,7 +1348,7 @@ public async Task JoinRedPocketLottery() return false; } // 参与红包抽奖会自动发送弹幕, 不用自己发 - return await JoinRedPocketLotteryRequest(SettingService.Account.UserID, + return await JoinRedPocketLotteryRequest(SettingService.Account.UserID, RoomID, AnchorUid, LotteryViewModel.RedPocketLotteryInfo.LotteryId.ToInt32()); diff --git a/src/BiliLite.UWP/ViewModels/Settings/EditPlaySpeedMenuViewModel.cs b/src/BiliLite.UWP/ViewModels/Settings/EditPlaySpeedMenuViewModel.cs index c4a6a835c..abb1a6725 100644 --- a/src/BiliLite.UWP/ViewModels/Settings/EditPlaySpeedMenuViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Settings/EditPlaySpeedMenuViewModel.cs @@ -1,6 +1,6 @@ -using System.Collections.ObjectModel; -using BiliLite.Models.Common.Player; +using BiliLite.Models.Common.Player; using BiliLite.ViewModels.Common; +using System.Collections.ObjectModel; namespace BiliLite.ViewModels.Settings { @@ -8,6 +8,6 @@ public class EditPlaySpeedMenuViewModel : BaseViewModel { public ObservableCollection PlaySpeedMenuItems { get; set; } - public double AddPlaySpeedValue { get; set; } = 1; + public double AddPlaySpeedValue { get; set; } = 3; } } From e7c77355904ba8c272001712168d2a21a9f3d671 Mon Sep 17 00:00:00 2001 From: ProJend <55018532+ProJend@users.noreply.github.com> Date: Sun, 26 Jan 2025 17:47:16 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E4=BC=98=E5=8C=96WebPage=20(#1009)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 启用系统级分享窗口 * 启用返回前进按钮 --- src/BiliLite.UWP/Pages/BasePage.cs | 17 ++++++++++++---- src/BiliLite.UWP/Pages/WebPage.xaml | 4 ++-- src/BiliLite.UWP/Pages/WebPage.xaml.cs | 27 +++++++++++++++++++++----- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/BiliLite.UWP/Pages/BasePage.cs b/src/BiliLite.UWP/Pages/BasePage.cs index 5be4e737b..9fc421fb4 100644 --- a/src/BiliLite.UWP/Pages/BasePage.cs +++ b/src/BiliLite.UWP/Pages/BasePage.cs @@ -1,14 +1,16 @@ -using System.Threading.Tasks; -using Windows.UI.Xaml; -using BiliLite.Controls; +using BiliLite.Controls; using BiliLite.Models.Common; using BiliLite.Services; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; namespace BiliLite.Pages { - public class BasePage : Page + public class BasePage : Page, INotifyPropertyChanged { public string Title { get; set; } public BasePage() @@ -34,6 +36,13 @@ protected override void OnNavigatedTo(NavigationEventArgs e) base.OnNavigatedTo(e); this.Visibility = Visibility.Visible; } + + public event PropertyChangedEventHandler PropertyChanged; + + protected void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } } public class PlayPage : BasePage, IPlayPage diff --git a/src/BiliLite.UWP/Pages/WebPage.xaml b/src/BiliLite.UWP/Pages/WebPage.xaml index 51c1c7abe..83a1e9430 100644 --- a/src/BiliLite.UWP/Pages/WebPage.xaml +++ b/src/BiliLite.UWP/Pages/WebPage.xaml @@ -23,12 +23,12 @@ - + - + diff --git a/src/BiliLite.UWP/Pages/WebPage.xaml.cs b/src/BiliLite.UWP/Pages/WebPage.xaml.cs index c8a174e48..88a1fcc64 100644 --- a/src/BiliLite.UWP/Pages/WebPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/WebPage.xaml.cs @@ -1,17 +1,18 @@ using BiliLite.Controls; using BiliLite.Extensions; +using BiliLite.Models.Common; using BiliLite.Services; +using Microsoft.Extensions.DependencyInjection; using Microsoft.UI.Xaml.Controls; +using Microsoft.Web.WebView2.Core; using System; using System.Threading.Tasks; +using Windows.ApplicationModel.DataTransfer; +using Windows.Storage; using Windows.UI.Popups; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; -using BiliLite.Models.Common; -using Microsoft.Web.WebView2.Core; -using Microsoft.Extensions.DependencyInjection; -using Windows.Storage; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -143,7 +144,17 @@ private void btnBack_Click(object sender, RoutedEventArgs e) private void btnShare_Click(object sender, RoutedEventArgs e) { - webView.Source.ToString().SetClipboard(); + DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView(); + dataTransferManager.DataRequested -= DataTransferManager_DataRequested; + dataTransferManager.DataRequested += DataTransferManager_DataRequested; + DataTransferManager.ShowShareUI(); + } + + private void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs e) + { + DataPackage dataPackage = e.Request.Data; + dataPackage.Properties.Title = "共享链接"; + dataPackage.SetWebLink(webView.Source); } private async void btnOpenBrowser_Click(object sender, RoutedEventArgs e) @@ -232,6 +243,12 @@ private async void WebView_OnNavigationCompleted(WebView2 sender, CoreWebView2Na { if (webView != null) webView.Visibility = Visibility.Visible; } + + IsEnableGoBack = webView.CanGoBack; + IsEnableGoForward = webView.CanGoForward; } + + bool IsEnableGoBack { get; set; } + bool IsEnableGoForward { get; set; } } } From de784069a4dc28dd1e5e54aa2eb268d2216c68bd Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Sun, 26 Jan 2025 18:06:16 +0800 Subject: [PATCH 08/12] =?UTF-8?q?#1009=20=E4=BF=AE=E5=A4=8D=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=A7=84=E8=8C=83?= 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/Pages/BasePage.cs | 9 +-------- src/BiliLite.UWP/Pages/WebPage.xaml | 6 ++++-- src/BiliLite.UWP/Pages/WebPage.xaml.cs | 10 +++++----- .../ViewModels/Common/WebPageViewModel.cs | 11 +++++++++++ 5 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 src/BiliLite.UWP/ViewModels/Common/WebPageViewModel.cs diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index e47f22e19..0d9df496d 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -1,8 +1,6 @@  - - + + Debug x86 @@ -347,6 +345,7 @@ + @@ -1753,12 +1752,10 @@ Windows Desktop Extensions for the UWP - + 14.0 - +