Skip to content

Commit

Permalink
Merge pull request #401 from ywmoyue/dev
Browse files Browse the repository at this point in the history
4.6.21
  • Loading branch information
ywmoyue authored Nov 13, 2023
2 parents 29c0936 + 240f0b3 commit 3b73f77
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 52 deletions.
6 changes: 6 additions & 0 deletions src/BiliLite.UWP/Controls/CommentControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public CommentControl()
this.InitializeComponent();
m_commentApi = new CommentApi();
emoteVM = new EmoteVM();
Unloaded += CommentControl_Unloaded;
}

#endregion
Expand All @@ -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()
Expand Down
21 changes: 16 additions & 5 deletions src/BiliLite.UWP/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ public static RichTextBlock ToRichTextBlock(this string txt, JObject emote)
{
if (txt != null)
{

//处理特殊字符
input = input.Replace("&", "&");
input = input.Replace("<", "&lt;");
input = input.Replace(">", "&gt;");
input = input.Replace("\r\n", "<LineBreak/>");
input = input.Replace("\n", "<LineBreak/>");
//处理其他控制字符
input = Regex.Replace(input, @"\p{C}+", string.Empty);

//处理链接
input = HandelUrl(input);

Expand Down Expand Up @@ -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))
Expand All @@ -369,11 +372,14 @@ private static string HandelVideoID(string input)
string.Format(
@" CommandParameter=""{1}"" ><TextBlock>{0}</TextBlock></HyperlinkButton></InlineUIContainer>",
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))
Expand All @@ -387,12 +393,15 @@ private static string HandelVideoID(string input)
string.Format(
@" CommandParameter=""{1}"" ><TextBlock>{0}</TextBlock></HyperlinkButton></InlineUIContainer>",
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))
Expand All @@ -406,7 +415,9 @@ private static string HandelVideoID(string input)
string.Format(
@" CommandParameter=""{1}"" ><TextBlock>{0}</TextBlock></HyperlinkButton></InlineUIContainer>",
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;
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/BiliLite.UWP/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
{
Expand Down
79 changes: 61 additions & 18 deletions src/BiliLite.UWP/Modules/Home/HotVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async Task GetPopular(string idx = "0", string last_param = "")
var items = JsonConvert.DeserializeObject<ObservableCollection<HotDataItemModel>>(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)
Expand Down Expand Up @@ -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;
}
}
18 changes: 9 additions & 9 deletions src/BiliLite.UWP/Pages/Home/HotPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@
</Grid.ColumnDefinitions>
<Border Margin="4" CornerRadius="{StaticResource ImageCornerRadius}">
<Grid >
<toolkit:ImageEx IsCacheEnabled="True" PlaceholderSource="ms-appx:///Assets/Thumbnails/Placeholde.png" Stretch="UniformToFill" Source="{x:Bind Path=cover,Converter={StaticResource imageConvert},ConverterParameter='120h'}"></toolkit:ImageEx>
<toolkit:ImageEx IsCacheEnabled="True" PlaceholderSource="ms-appx:///Assets/Thumbnails/Placeholde.png" Stretch="UniformToFill" Source="{x:Bind Path=Cover,Converter={StaticResource imageConvert},ConverterParameter='120h'}"></toolkit:ImageEx>
<Border CornerRadius="4" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="4" Padding="4 2" Background="#99000000">
<TextBlock Foreground="White" FontSize="12" Text="{x:Bind cover_right_text_1}"></TextBlock>
<TextBlock Foreground="White" FontSize="12" Text="{x:Bind TextInfo1}"></TextBlock>
</Border>
</Grid>
</Border>
<StackPanel Grid.Column="1" Margin="4 0 0 0" >
<TextBlock MaxLines="2" TextWrapping="Wrap" TextTrimming="CharacterEllipsis" Text="{x:Bind title}"></TextBlock>
<Border Margin="0 2 0 0" BorderThickness="1" BorderBrush="{x:Bind Path=rcmd_reason_style.BorderColor,Converter={StaticResource colorConvert}}" Background="{x:Bind Path=rcmd_reason_style.BgColor,Converter={StaticResource colorConvert}}" HorizontalAlignment="Left" Padding="4 0" CornerRadius="2">
<TextBlock TextWrapping="Wrap" FontSize="12" Foreground="{x:Bind Path=rcmd_reason_style.TextColor,Converter={StaticResource colorConvert}}" TextTrimming="CharacterEllipsis" Text="{x:Bind Path=rcmd_reason_style.Text}"></TextBlock>
<TextBlock MaxLines="2" TextWrapping="Wrap" TextTrimming="CharacterEllipsis" Text="{x:Bind Title}"></TextBlock>
<Border Margin="0 2 0 0" BorderThickness="1" BorderBrush="{x:Bind Path=RcmdReason.BorderColor,Converter={StaticResource colorConvert}}" Background="{x:Bind Path=RcmdReason.BgColor,Converter={StaticResource colorConvert}}" HorizontalAlignment="Left" Padding="4 0" CornerRadius="2">
<TextBlock TextWrapping="Wrap" FontSize="12" Foreground="{x:Bind Path=RcmdReason.TextColor,Converter={StaticResource colorConvert}}" TextTrimming="CharacterEllipsis" Text="{x:Bind Path=RcmdReason.Text}"></TextBlock>
</Border>
<TextBlock Margin="0 2 0 0" TextTrimming="CharacterEllipsis" Foreground="Gray" Text="{x:Bind right_desc_1}"></TextBlock>
<TextBlock Margin="0 2 0 0" TextTrimming="CharacterEllipsis" Foreground="Gray" Text="{x:Bind right_desc_2}"></TextBlock>
<TextBlock Margin="0 2 0 0" TextTrimming="CharacterEllipsis" Foreground="Gray" Text="{x:Bind TextInfo2}"></TextBlock>
<TextBlock Margin="0 2 0 0" TextTrimming="CharacterEllipsis" Foreground="Gray" Text="{x:Bind TextInfo3}"></TextBlock>
</StackPanel>
<!--<TextBlock Grid.Row="2" Margin="4 0 4 4" FontSize="12" Foreground="Gray" MaxLines="2" TextWrapping="Wrap" TextTrimming="CharacterEllipsis" Text="{Binding desc}"></TextBlock>-->
</Grid>
Expand All @@ -72,8 +72,8 @@
<GridView.ItemTemplate>
<DataTemplate x:DataType="modules:HotTopItemModel">
<StackPanel>
<Image Width="48" Margin="0 8" Height="48" Source="{x:Bind icon}"></Image>
<TextBlock Margin="0 0 0 8" TextAlignment="Center" Text="{x:Bind title}"></TextBlock>
<Image Width="48" Margin="0 8" Height="48" Source="{x:Bind Icon}"></Image>
<TextBlock Margin="0 0 0 8" TextAlignment="Center" Text="{x:Bind Title}"></TextBlock>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
Expand Down
14 changes: 7 additions & 7 deletions src/BiliLite.UWP/Pages/Home/HotPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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()
{
Expand All @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion src/BiliLite.UWP/Pages/SettingPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 12 additions & 8 deletions src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,19 @@ public VideoDetailPage()
dataTransferManager.DataRequested += DataTransferManager_DataRequested;
m_viewModel.DefaultRightInfoWidth = new GridLength(SettingService.GetValue<double>(SettingConstants.UI.RIGHT_DETAIL_WIDTH, 320), GridUnitType.Pixel);
this.RightInfoGridSplitter.IsEnabled = SettingService.GetValue<bool>(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)
Expand All @@ -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)
{
Expand Down Expand Up @@ -191,7 +195,7 @@ private async Task InitializeVideo(string id)
}
}
InitPlayInfo();

comment.LoadComment(new LoadCommentInfo()
{
CommentMode = (int)CommentApi.CommentType.Video,
Expand Down
2 changes: 1 addition & 1 deletion src/BiliLite.UWP/Services/ApiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/BiliLite.UWP/ViewModels/Live/LiveRoomViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public LiveRoomViewModel()
/// <summary>
/// 房间标题
/// </summary>
[DoNotNotify]
public string RoomTitle { get; set; }

[DoNotNotify]
Expand Down

0 comments on commit 3b73f77

Please sign in to comment.