diff --git a/src/BiliLite.UWP/Controls/CommentControl.xaml.cs b/src/BiliLite.UWP/Controls/CommentControl.xaml.cs index caa145e0..881e5fae 100644 --- a/src/BiliLite.UWP/Controls/CommentControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/CommentControl.xaml.cs @@ -54,6 +54,7 @@ public CommentControl() this.InitializeComponent(); m_commentApi = new CommentApi(); emoteVM = new EmoteVM(); + Unloaded += CommentControl_Unloaded; } #endregion @@ -66,6 +67,11 @@ public CommentControl() #region Private Methods + private void CommentControl_Unloaded(object sender, RoutedEventArgs e) + { + Bindings.StopTracking(); + } + private void BtnUser_Click(object sender, RoutedEventArgs e) { MessageCenter.NavigateToPage(this, new NavigationInfo() diff --git a/src/BiliLite.UWP/Extensions/StringExtensions.cs b/src/BiliLite.UWP/Extensions/StringExtensions.cs index 9947c570..d811c259 100644 --- a/src/BiliLite.UWP/Extensions/StringExtensions.cs +++ b/src/BiliLite.UWP/Extensions/StringExtensions.cs @@ -86,13 +86,15 @@ public static RichTextBlock ToRichTextBlock(this string txt, JObject emote) { if (txt != null) { - //处理特殊字符 input = input.Replace("&", "&"); input = input.Replace("<", "<"); input = input.Replace(">", ">"); input = input.Replace("\r\n", ""); input = input.Replace("\n", ""); + //处理其他控制字符 + input = Regex.Replace(input, @"\p{C}+", string.Empty); + //处理链接 input = HandelUrl(input); @@ -355,7 +357,8 @@ private static string HandelVideoID(string input) if (!Regex.IsMatch(input, @"/[aAbBcC][vV]([a-zA-Z0-9]+)")) { //处理AV号 - MatchCollection av = Regex.Matches(input, @"[aA][vV](\d+)"); + MatchCollection av = Regex.Matches(input, @"[aA][vV](\d+)"); + var offset = 0; foreach (Match item in av) { if (keyword.Contains(item.Groups[0].Value)) @@ -369,11 +372,14 @@ private static string HandelVideoID(string input) string.Format( @" CommandParameter=""{1}"" >{0}", item.Groups[0].Value, "bilibili://video/" + item.Groups[0].Value); - input = input.Replace(item.Groups[0].Value, data); + input = input.Remove(item.Index + offset, item.Length); + input = input.Insert(item.Index + offset, data); + offset += data.Length - item.Length; } //处理AV号 MatchCollection bv = Regex.Matches(input, @"[bB][vV]([a-zA-Z0-9]{8,})"); + offset = 0; foreach (Match item in bv) { if (keyword.Contains(item.Groups[0].Value)) @@ -387,12 +393,15 @@ private static string HandelVideoID(string input) string.Format( @" CommandParameter=""{1}"" >{0}", item.Groups[0].Value, "bilibili://video/" + item.Groups[0].Value); - input = input.Replace(item.Groups[0].Value, data); + input = input.Remove(item.Index + offset, item.Length); + input = input.Insert(item.Index + offset, data); + offset += data.Length - item.Length; } //处理CV号 MatchCollection cv = Regex.Matches(input, @"[cC][vV](\d+)"); + offset = 0; foreach (Match item in cv) { if (keyword.Contains(item.Groups[0].Value)) @@ -406,7 +415,9 @@ private static string HandelVideoID(string input) string.Format( @" CommandParameter=""{1}"" >{0}", item.Groups[0].Value, "bilibili://article/" + item.Groups[1].Value); - input = input.Replace(item.Groups[0].Value, data); + input = input.Remove(item.Index + offset, item.Length); + input = input.Insert(item.Index + offset, data); + offset += data.Length - item.Length; } } diff --git a/src/BiliLite.UWP/MainPage.xaml.cs b/src/BiliLite.UWP/MainPage.xaml.cs index e3cfd012..23360672 100644 --- a/src/BiliLite.UWP/MainPage.xaml.cs +++ b/src/BiliLite.UWP/MainPage.xaml.cs @@ -198,7 +198,6 @@ private void TabView_AddTabButtonClick(Microsoft.UI.Xaml.Controls.TabView sender page = typeof(NewPage), title = "新建页面" }); - } private void TabView_TabCloseRequested(TabView sender, TabViewTabCloseRequestedEventArgs args) @@ -215,7 +214,7 @@ private void ClosePage(TabViewItem tabItem) // frame.BackStack.Clear(); tabItem.Content = null; tabView.TabItems.Remove(tabItem); - //GC.Collect(); + GC.Collect(); } private void tabView_Loaded(object sender, RoutedEventArgs e) { diff --git a/src/BiliLite.UWP/Modules/Home/HotVM.cs b/src/BiliLite.UWP/Modules/Home/HotVM.cs index 1b508c33..d0d8a095 100644 --- a/src/BiliLite.UWP/Modules/Home/HotVM.cs +++ b/src/BiliLite.UWP/Modules/Home/HotVM.cs @@ -64,7 +64,7 @@ public async Task GetPopular(string idx = "0", string last_param = "") var items = JsonConvert.DeserializeObject>(data["data"].ToString()); for (int i = items.Count - 1; i >= 0; i--) { - if (items[i].card_goto != "av") + if (items[i].CardGoto != "av") items.Remove(items[i]); } if (HotItems == null) @@ -122,29 +122,72 @@ public async void LoadMore() return; } var last = HotItems.LastOrDefault(); - await GetPopular(last.idx, last.param); + await GetPopular(last.Idx, last.Param); } } public class HotTopItemModel { - public int entrance_id { get; set; } - public string icon { get; set; } - public string module_id { get; set; } - public string uri { get; set; } - public string title { get; set; } + [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 { - public string card_type { get; set; } - public string card_goto { 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; } - public string cover_right_text_1 { get; set; } - public string right_desc_1 { get; set; } - public string right_desc_2 { get; set; } - public RecommendRcmdReasonStyleModel rcmd_reason_style { get; set; } + [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/Pages/Home/HotPage.xaml b/src/BiliLite.UWP/Pages/Home/HotPage.xaml index c4b6f59a..0b081c00 100644 --- a/src/BiliLite.UWP/Pages/Home/HotPage.xaml +++ b/src/BiliLite.UWP/Pages/Home/HotPage.xaml @@ -49,19 +49,19 @@ - + - + - - - + + + - - + + @@ -72,8 +72,8 @@ - - + + diff --git a/src/BiliLite.UWP/Pages/Home/HotPage.xaml.cs b/src/BiliLite.UWP/Pages/Home/HotPage.xaml.cs index 763d6b62..d8c16b57 100644 --- a/src/BiliLite.UWP/Pages/Home/HotPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/Home/HotPage.xaml.cs @@ -52,20 +52,20 @@ private async void gridHot_ItemClick(object sender, ItemClickEventArgs e) private async Task HotDataItemModelOpen(object sender, HotDataItemModel item, bool dontGoTo = false) { if (item == null) return; - if (item.card_goto == "av") + if (item.CardGoto == "av") { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.Play, page = typeof(VideoDetailPage), - title = item.title, - parameters = item.param, + title = item.Title, + parameters = item.Param, dontGoTo = dontGoTo }); } else { - await MessageCenter.HandelUrl(item.uri, dontGoTo); + await MessageCenter.HandelUrl(item.Uri, dontGoTo); } } @@ -80,7 +80,7 @@ private async void gridHot_ItemPressed(object sender, PointerRoutedEventArgs e) private async void gridTop_ItemClick(object sender, ItemClickEventArgs e) { var data = (e.ClickedItem as Modules.HotTopItemModel); - if (data.module_id == "rank") + if (data.ModuleId == "rank") { MessageCenter.NavigateToPage(this, new NavigationInfo() { @@ -91,14 +91,14 @@ private async void gridTop_ItemClick(object sender, ItemClickEventArgs e) } else { - await MessageCenter.HandelUrl(data.uri); + await MessageCenter.HandelUrl(data.Uri); } } private void AddToWatchLater_Click(object sender, RoutedEventArgs e) { var data = (sender as MenuFlyoutItem).DataContext as HotDataItemModel; - WatchLaterVM.Instance.AddToWatchlater(data.param); + WatchLaterVM.Instance.AddToWatchlater(data.Param); } } } diff --git a/src/BiliLite.UWP/Pages/SettingPage.xaml.cs b/src/BiliLite.UWP/Pages/SettingPage.xaml.cs index d957f694..36a25bd6 100644 --- a/src/BiliLite.UWP/Pages/SettingPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/SettingPage.xaml.cs @@ -1002,7 +1002,7 @@ private void mirrorComboboxSelectAction(object selectedValue) case ApiHelper.GHPROXY_GIT_RAW_URL: { mirrorDonateText.Visibility = Visibility.Visible; - mirrorDonateUrl.NavigateUri = new Uri("https://ghproxy.com/donate"); + mirrorDonateUrl.NavigateUri = new Uri("https://gh-proxy.com"); break; } case ApiHelper.KGITHUB_GIT_RAW_URL: diff --git a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs index 9c0fe2bd..047ded6f 100644 --- a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs @@ -62,17 +62,19 @@ public VideoDetailPage() dataTransferManager.DataRequested += DataTransferManager_DataRequested; m_viewModel.DefaultRightInfoWidth = new GridLength(SettingService.GetValue(SettingConstants.UI.RIGHT_DETAIL_WIDTH, 320), GridUnitType.Pixel); this.RightInfoGridSplitter.IsEnabled = SettingService.GetValue(SettingConstants.UI.RIGHT_WIDTH_CHANGEABLE, false); + Unloaded += VideoDetailPage_Unloaded; } - private void VideoDetailPage_Loaded(object sender, RoutedEventArgs e) + private void VideoDetailPage_Unloaded(object sender, RoutedEventArgs e) { + Bindings.StopTracking(); + } - if (this.Parent is MyFrame) - { - (this.Parent as MyFrame).ClosedPage -= VideoDetailPage_ClosedPage; - (this.Parent as MyFrame).ClosedPage += VideoDetailPage_ClosedPage; - } - + private void VideoDetailPage_Loaded(object sender, RoutedEventArgs e) + { + if (!(this.Parent is MyFrame frame)) return; + frame.ClosedPage -= VideoDetailPage_ClosedPage; + frame.ClosedPage += VideoDetailPage_ClosedPage; } private void VideoDetailPage_ClosedPage(object sender, EventArgs e) @@ -91,6 +93,8 @@ private void ClosePage() player?.FullScreen(false); player?.MiniWidnows(false); player?.Dispose(); + if (!(this.Parent is MyFrame frame)) return; + frame.ClosedPage -= VideoDetailPage_ClosedPage; } private void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args) { @@ -191,7 +195,7 @@ private async Task InitializeVideo(string id) } } InitPlayInfo(); - + comment.LoadComment(new LoadCommentInfo() { CommentMode = (int)CommentApi.CommentType.Video, diff --git a/src/BiliLite.UWP/Services/ApiHelper.cs b/src/BiliLite.UWP/Services/ApiHelper.cs index b2d7aad4..b81e2f5e 100644 --- a/src/BiliLite.UWP/Services/ApiHelper.cs +++ b/src/BiliLite.UWP/Services/ApiHelper.cs @@ -21,7 +21,7 @@ public static class ApiHelper public const string GIT_RAW_URL = "https://raw.githubusercontent.com/ywmoyue/biliuwp-lite/master"; // 镜像 GIT RAW路径 - public const string GHPROXY_GIT_RAW_URL = "https://ghproxy.com/https://raw.githubusercontent.com/ywmoyue/biliuwp-lite/master"; + public const string GHPROXY_GIT_RAW_URL = "https://gh-proxy.com/https://raw.githubusercontent.com/ywmoyue/biliuwp-lite/master"; public const string KGITHUB_GIT_RAW_URL = "https://raw.kkgithub.com/ywmoyue/biliuwp-lite/master"; // 哔哩哔哩API diff --git a/src/BiliLite.UWP/ViewModels/Live/LiveRoomViewModel.cs b/src/BiliLite.UWP/ViewModels/Live/LiveRoomViewModel.cs index 6234746c..45af7dc8 100644 --- a/src/BiliLite.UWP/ViewModels/Live/LiveRoomViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Live/LiveRoomViewModel.cs @@ -103,7 +103,6 @@ public LiveRoomViewModel() /// /// 房间标题 /// - [DoNotNotify] public string RoomTitle { get; set; } [DoNotNotify]