Skip to content

Commit

Permalink
修复番剧动态
Browse files Browse the repository at this point in the history
  • Loading branch information
ywmoyue committed May 2, 2024
1 parent 2962986 commit a31b9fa
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 73 deletions.
10 changes: 5 additions & 5 deletions src/BiliLite.UWP/Controls/Dynamic/DynamicItemV2Control.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</Grid.ColumnDefinitions>
<HyperlinkButton Padding="0"
Command="{x:Bind Path=ViewModel.Parent.UserCommand,Mode=OneWay}"
CommandParameter="{x:Bind Path=ViewModel.Author.Mid,Mode=OneWay}"
CommandParameter="{x:Bind Path=ViewModel,Mode=OneWay}"
Visibility="{x:Bind ViewModel.IsRepost,Converter={StaticResource display},Mode=OneWay}"
VerticalAlignment="Top">
<Grid >
Expand All @@ -43,14 +43,14 @@
<HyperlinkButton
Grid.Column="1"
Command="{x:Bind Path=ViewModel.Parent.UserCommand,Mode=OneWay}"
CommandParameter="{x:Bind Path=ViewModel.Author.Mid,Mode=OneWay}"
CommandParameter="{x:Bind Path=ViewModel,Mode=OneWay}"
Visibility="{x:Bind ViewModel.IsRepost,Converter={StaticResource display},Mode=OneWay}"
Padding="12,0,0,0" VerticalAlignment="Top" >
<Grid Height="56" >
<StackPanel VerticalAlignment="Center" >
<StackPanel Orientation="Horizontal" >
<TextBlock Text="{x:Bind Path=ViewModel.Author.Author.Name,Mode=OneWay}" Foreground="DeepPink" Opacity=".8" Visibility="{x:Bind Path=ViewModel.Author.Author.Vip.Status,Converter={StaticResource display},ConverterParameter=1,Mode=OneWay}"></TextBlock>
<TextBlock Text="{x:Bind Path=ViewModel.Author.Author.Name,Mode=OneWay}" Foreground="{ThemeResource TextColor}" Visibility="{x:Bind Path=ViewModel.Author.Author.Vip.Status,Mode=OneWay,Converter={StaticResource display},ConverterParameter=0}"></TextBlock>
<TextBlock Text="{x:Bind Path=ViewModel.Author.Author.Name,Mode=OneWay}" Foreground="DeepPink" Opacity=".8" Visibility="{x:Bind ViewModel.AuthorIsVip,Mode=OneWay}"></TextBlock>
<TextBlock Text="{x:Bind Path=ViewModel.Author.Author.Name,Mode=OneWay}" Foreground="{ThemeResource TextColor}" Visibility="{x:Bind ViewModel.AuthorIsVip,Mode=OneWay,Converter={StaticResource display}}"></TextBlock>
</StackPanel>
<TextBlock Margin="0 4 0 0" FontSize="12" Foreground="Gray" Text="{x:Bind Path=ViewModel.Author.PtimeLabelText,Mode=OneWay}"></TextBlock>
</StackPanel>
Expand Down Expand Up @@ -98,7 +98,7 @@
HorizontalAlignment="Stretch"
Grid.ColumnSpan="2"
Command="{x:Bind Path=ViewModel.Parent.UserCommand,Mode=OneWay}"
CommandParameter="{x:Bind Path=ViewModel.AuthorForward.Uid,Mode=OneWay}"
CommandParameter="{x:Bind Path=ViewModel,Mode=OneWay}"
Visibility="{x:Bind Path=ViewModel.IsRepost,Mode=OneWay}"
Padding="0" >
<Grid >
Expand Down
82 changes: 57 additions & 25 deletions src/BiliLite.UWP/Controls/Dynamic/DynamicV2Template.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,34 +81,66 @@
<DataTemplate x:Key="DynamicPgc">
<local:DynamicItemV2Control ViewModel="{Binding}">
<local:DynamicItemV2Control.CardContent>
<Button HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left"
Padding="0"
Background="Transparent"
Command="{Binding Path=Parent.LaunchUrlCommand}"
CommandParameter="{Binding Path=Dynamic.DynPgc.Uri}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid>
<Button HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left"
Padding="0"
Background="Transparent"
Visibility="{Binding Dynamic.DynPgc,Converter={StaticResource display}}"
Command="{Binding Path=Parent.LaunchUrlCommand}"
CommandParameter="{Binding Path=Dynamic.DynPgc.Uri}">
<Grid>
<Border CornerRadius="4">
<Image Source="{Binding Path=Dynamic.DynPgc.Cover}" Width="{Binding Path=CoverWidth}"></Image>
</Border>
<Border Background="#C8FF69B4" CornerRadius="2" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="4">
<TextBlock Margin="4 2" Foreground="White" FontSize="12" Text="番剧"></TextBlock>
</Border>
<Border Background="#C8000000" CornerRadius="2" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="4">
<TextBlock Margin="4 2" Foreground="White" FontSize="12" Text="{Binding Path=Dynamic.DynArchive.CoverLeftText1}"></TextBlock>
</Border>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid>
<Border CornerRadius="4">
<Image Source="{Binding Path=Dynamic.DynPgc.Cover}" Width="{Binding Path=CoverWidth}"></Image>
</Border>
<Border Background="#C8FF69B4" CornerRadius="2" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="4">
<TextBlock Margin="4 2" Foreground="White" FontSize="12" Text="番剧"></TextBlock>
</Border>
<Border Background="#C8000000" CornerRadius="2" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="4">
<TextBlock Margin="4 2" Foreground="White" FontSize="12" Text="{Binding Path=Dynamic.DynArchive.CoverLeftText1}"></TextBlock>
</Border>
</Grid>

<StackPanel HorizontalAlignment="Stretch" Grid.Column="1" Margin="8 4 8 0">
<TextBlock Text="{Binding Path=Dynamic.DynPgc.Title}" Foreground="{ThemeResource TextColor}" TextTrimming="CharacterEllipsis" MaxLines="2" TextWrapping="Wrap"></TextBlock>
</StackPanel>
</Grid>
</Button>
<Button HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left"
Padding="0"
Background="Transparent"
Visibility="{Binding Dynamic.DynArchive,Converter={StaticResource display}}"
Command="{Binding Path=Parent.LaunchUrlCommand}"
CommandParameter="{Binding Path=Dynamic.DynArchive.Uri}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid>
<Border CornerRadius="4">
<Image Source="{Binding Path=Dynamic.DynArchive.Cover}" Width="{Binding Path=CoverWidth}"></Image>
</Border>
<Border Background="#C8FF69B4" CornerRadius="2" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="4">
<TextBlock Margin="4 2" Foreground="White" FontSize="12" Text="番剧"></TextBlock>
</Border>
<Border Background="#C8000000" CornerRadius="2" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="4">
<TextBlock Margin="4 2" Foreground="White" FontSize="12" Text="{Binding Path=Dynamic.DynArchive.CoverLeftText1}"></TextBlock>
</Border>
</Grid>

<StackPanel HorizontalAlignment="Stretch" Grid.Column="1" Margin="8 4 8 0">
<TextBlock Text="{Binding Path=Dynamic.DynPgc.Title}" Foreground="{ThemeResource TextColor}" TextTrimming="CharacterEllipsis" MaxLines="2" TextWrapping="Wrap"></TextBlock>
</StackPanel>
</Grid>
</Button>
<StackPanel HorizontalAlignment="Stretch" Grid.Column="1" Margin="8 4 8 0">
<TextBlock Text="{Binding Path=Dynamic.DynArchive.Title}" Foreground="{ThemeResource TextColor}" TextTrimming="CharacterEllipsis" MaxLines="2" TextWrapping="Wrap"></TextBlock>
</StackPanel>
</Grid>
</Button>
</Grid>
</local:DynamicItemV2Control.CardContent>
</local:DynamicItemV2Control>
</DataTemplate>
Expand Down
84 changes: 43 additions & 41 deletions src/BiliLite.UWP/Services/MessageCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,49 @@ public static async Task<bool> HandelUrl(string url, bool dontGoTo = false)
return true;
}

/*
* 番剧/影视
* https://bangumi.bilibili.com/anime/21680
* https://www.bilibili.com/bangumi/play/ss21715
* https://www.bilibili.com/bangumi/play/ep150706
* https://m.bilibili.com/bangumi/play/ep150706
* http://m.bilibili.com/bangumi/play/ss21715
* bilibili://bangumi/season/21715
* https://bangumi.bilibili.com/movie/12364
*/
if (uriHref.Contains("bangumi"))
{
var bangumi = StringExtensions.RegexMatch(url.Replace("movie", "ss").Replace("anime", "ss").Replace("season", "ss").Replace("/", ""), @"ss(\d{4,})");
if (bangumi != "")
{
NavigateToPage(null, new NavigationInfo()
{
icon = Symbol.Play,
page = typeof(SeasonDetailPage),
title = "剧集加载中...",
parameters = bangumi,
dontGoTo = dontGoTo,
});
return true;
}
bangumi = StringExtensions.RegexMatch(url, @"ep(\d+)");
if (bangumi != "")
{
NavigateToPage(null, new NavigationInfo()
{
icon = Symbol.Play,
page = typeof(SeasonDetailPage),
title = "剧集加载中...",
dontGoTo = dontGoTo,
parameters = new object[] {
await BiliExtensions.BangumiEpidToSid(bangumi),
bangumi
}
});
return true;
}
}

/*
* 视频
* https://www.bilibili.com/video/av3905642
Expand Down Expand Up @@ -238,47 +281,6 @@ public static async Task<bool> HandelUrl(string url, bool dontGoTo = false)
return true;
}

/*
* 番剧/影视
* https://bangumi.bilibili.com/anime/21680
* https://www.bilibili.com/bangumi/play/ss21715
* https://www.bilibili.com/bangumi/play/ep150706
* https://m.bilibili.com/bangumi/play/ep150706
* http://m.bilibili.com/bangumi/play/ss21715
* bilibili://bangumi/season/21715
* https://bangumi.bilibili.com/movie/12364
*/

var bangumi = StringExtensions.RegexMatch(url.Replace("movie", "ss").Replace("anime", "ss").Replace("season", "ss").Replace("/", ""), @"ss(\d{4,})");
if (bangumi != "")
{
NavigateToPage(null, new NavigationInfo()
{
icon = Symbol.Play,
page = typeof(SeasonDetailPage),
title = "剧集加载中...",
parameters = bangumi,
dontGoTo = dontGoTo,
});
return true;
}
bangumi = StringExtensions.RegexMatch(url, @"ep(\d+)");
if (bangumi != "")
{
NavigateToPage(null, new NavigationInfo()
{
icon = Symbol.Play,
page = typeof(SeasonDetailPage),
title = "剧集加载中...",
dontGoTo = dontGoTo,
parameters = new object[] {
await BiliExtensions.BangumiEpidToSid(bangumi),
bangumi
}
});
return true;
}


/*
* 点评
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ public DynamicV2ItemViewModel()

public ModuleAuthor Author { get; set; }

public bool AuthorIsVip
{
get
{
if (Author?.Author.Vip == null) return false;
return Author.Author.Vip.Status == 1;
}
}

public ModuleAuthorForward AuthorForward { get; set; }

public UserDynamicSeasonInfo Season { get; set; }
Expand Down
24 changes: 22 additions & 2 deletions src/BiliLite.UWP/ViewModels/UserDynamic/UserDynamicAllViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public UserDynamicAllViewModel(GrpcService grpcService, IMapper mapper)
m_dynamicApi = new DynamicAPI();
m_watchLaterVm = new WatchLaterVM();
LoadMoreCommand = new RelayCommand(LoadMore);
UserCommand = new RelayCommand<object>(OpenUser);
UserCommand = new RelayCommand<DynamicV2ItemViewModel>(OpenUser);
DetailCommand = new RelayCommand<string>(OpenDetail);
ImageCommand = new RelayCommand<object>(OpenImage);
WebDetailCommand = new RelayCommand<string>(OpenWebDetail);
Expand Down Expand Up @@ -109,8 +109,28 @@ public UserDynamicAllViewModel(GrpcService grpcService, IMapper mapper)

#region Private Methods

private void OpenUser(object userId)
private void OpenUser(DynamicV2ItemViewModel dynamicItem)
{
if (dynamicItem.CardType == Constants.DynamicTypes.PGC)
{
var url = dynamicItem.Dynamic.DynPgc != null
? dynamicItem.Dynamic.DynPgc.Uri
: dynamicItem.Dynamic.DynArchive.Uri;
LaunchUrl(url);
return;
}

long userId = 0;

if (dynamicItem.Author != null)
{
userId = dynamicItem.Author.Author.Mid;
}
else if (dynamicItem.AuthorForward != null)
{
userId = dynamicItem.AuthorForward.Uid;
}

MessageCenter.NavigateToPage(this, new NavigationInfo()
{
icon = Symbol.Contact,
Expand Down

0 comments on commit a31b9fa

Please sign in to comment.