fix: 修复收藏夹无法显示视频列表的问题

This commit is contained in:
姚彪
2024-02-04 10:51:45 +08:00
parent 18527e9488
commit 6fce331de4
3 changed files with 72 additions and 105 deletions

View File

@@ -1,5 +1,6 @@
using Avalonia.Media.Imaging;
using DownKyi.Images;
using DownKyi.Utils;
using Prism.Mvvm;
namespace DownKyi.ViewModels.PageViewModels;
@@ -133,17 +134,17 @@ public class Favorites : BindableBase
{
#region
// Play = NormalIcon.Instance().Play;
// Play.Fill = DictionaryResource.GetColor("ColorTextGrey2");
//
// Like = NormalIcon.Instance().Like;
// Like.Fill = DictionaryResource.GetColor("ColorTextGrey2");
//
// Favorite = NormalIcon.Instance().Favorite;
// Favorite.Fill = DictionaryResource.GetColor("ColorTextGrey2");
//
// Share = NormalIcon.Instance().Share;
// Share.Fill = DictionaryResource.GetColor("ColorTextGrey2");
Play = NormalIcon.Instance().Play;
Play.Fill = DictionaryResource.GetColor("ColorTextGrey2");
Like = NormalIcon.Instance().Like;
Like.Fill = DictionaryResource.GetColor("ColorTextGrey2");
Favorite = NormalIcon.Instance().Favorite;
Favorite.Fill = DictionaryResource.GetColor("ColorTextGrey2");
Share = NormalIcon.Instance().Share;
Share.Fill = DictionaryResource.GetColor("ColorTextGrey2");
#endregion
}

View File

@@ -160,10 +160,9 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
#region
// 返回
private DelegateCommand backSpaceCommand;
private DelegateCommand? _backSpaceCommand;
public DelegateCommand BackSpaceCommand =>
backSpaceCommand ?? (backSpaceCommand = new DelegateCommand(ExecuteBackSpace));
public DelegateCommand BackSpaceCommand => _backSpaceCommand ??= new DelegateCommand(ExecuteBackSpace);
/// <summary>
/// 返回
@@ -183,11 +182,9 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
}
// 前往下载管理页面
private DelegateCommand downloadManagerCommand;
private DelegateCommand? _downloadManagerCommand;
public DelegateCommand DownloadManagerCommand => downloadManagerCommand ??
(downloadManagerCommand =
new DelegateCommand(ExecuteDownloadManagerCommand));
public DelegateCommand DownloadManagerCommand => _downloadManagerCommand ??= new DelegateCommand(ExecuteDownloadManagerCommand);
/// <summary>
/// 前往下载管理页面
@@ -204,10 +201,9 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
}
// 复制封面事件
private DelegateCommand copyCoverCommand;
private DelegateCommand? _copyCoverCommand;
public DelegateCommand CopyCoverCommand =>
copyCoverCommand ?? (copyCoverCommand = new DelegateCommand(ExecuteCopyCoverCommand));
public DelegateCommand CopyCoverCommand => _copyCoverCommand ??= new DelegateCommand(ExecuteCopyCoverCommand);
/// <summary>
/// 复制封面事件
@@ -220,11 +216,9 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
}
// 复制封面URL事件
private DelegateCommand copyCoverUrlCommand;
private DelegateCommand? _copyCoverUrlCommand;
public DelegateCommand CopyCoverUrlCommand => copyCoverUrlCommand ??
(copyCoverUrlCommand =
new DelegateCommand(ExecuteCopyCoverUrlCommand));
public DelegateCommand CopyCoverUrlCommand => _copyCoverUrlCommand ??= new DelegateCommand(ExecuteCopyCoverUrlCommand);
/// <summary>
/// 复制封面URL事件
@@ -237,8 +231,8 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
}
// 前往UP主页事件
private DelegateCommand upperCommand;
public DelegateCommand UpperCommand => upperCommand ?? (upperCommand = new DelegateCommand(ExecuteUpperCommand));
private DelegateCommand? _upperCommand;
public DelegateCommand UpperCommand => _upperCommand ??= new DelegateCommand(ExecuteUpperCommand);
/// <summary>
/// 前往UP主页事件
@@ -249,11 +243,9 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
}
// 添加选中项到下载列表事件
private DelegateCommand addToDownloadCommand;
private DelegateCommand? _addToDownloadCommand;
public DelegateCommand AddToDownloadCommand => addToDownloadCommand ??
(addToDownloadCommand =
new DelegateCommand(ExecuteAddToDownloadCommand));
public DelegateCommand AddToDownloadCommand => _addToDownloadCommand ??= new DelegateCommand(ExecuteAddToDownloadCommand);
/// <summary>
/// 添加选中项到下载列表事件
@@ -264,11 +256,9 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
}
// 添加所有视频到下载列表事件
private DelegateCommand addAllToDownloadCommand;
private DelegateCommand? _addAllToDownloadCommand;
public DelegateCommand AddAllToDownloadCommand => addAllToDownloadCommand ??
(addAllToDownloadCommand =
new DelegateCommand(ExecuteAddAllToDownloadCommand));
public DelegateCommand AddAllToDownloadCommand => _addAllToDownloadCommand ??= new DelegateCommand(ExecuteAddAllToDownloadCommand);
/// <summary>
/// 添加所有视频到下载列表事件
@@ -279,12 +269,9 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
}
// 列表选择事件
private DelegateCommand<object> favoritesMediasCommand;
private DelegateCommand<object>? _favoritesMediasCommand;
public DelegateCommand<object> FavoritesMediasCommand => favoritesMediasCommand ??
(favoritesMediasCommand =
new DelegateCommand<object>(
ExecuteFavoritesMediasCommand));
public DelegateCommand<object> FavoritesMediasCommand => _favoritesMediasCommand ??= new DelegateCommand<object>(ExecuteFavoritesMediasCommand);
/// <summary>
/// 列表选择事件
@@ -401,7 +388,7 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
MediaLoadingVisibility = true;
List<Core.BiliApi.Favorites.Models.FavoritesMedia> medias = FavoritesResource.GetAllFavoritesMedia(favoritesId);
var medias = FavoritesResource.GetAllFavoritesMedia(favoritesId);
if (medias == null || medias.Count == 0)
{
MediaLoadingVisibility = false;
@@ -426,18 +413,18 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
base.OnNavigatedTo(navigationContext);
// 根据传入参数不同执行不同任务
long parameter = navigationContext.Parameters.GetValue<long>("Parameter");
var parameter = navigationContext.Parameters.GetValue<long>("Parameter");
if (parameter == 0)
{
return;
}
InitView();
await Task.Run(new Action(() =>
await Task.Run(() =>
{
CancellationToken cancellationToken = tokenSource.Token;
var cancellationToken = tokenSource.Token;
UpdateView(new FavoritesService(), parameter, cancellationToken);
}), (tokenSource = new CancellationTokenSource()).Token);
}, (tokenSource = new CancellationTokenSource()).Token);
}
}

View File

@@ -112,7 +112,8 @@
<StackPanel
Grid.Column="1"
HorizontalAlignment="Right"
Orientation="Horizontal">
Orientation="Horizontal"
IsVisible="{Binding Favorites.MediaCount}">
<TextBlock
FontSize="12"
Foreground="{DynamicResource BrushTextGrey}"
@@ -121,18 +122,6 @@
FontSize="12"
Foreground="{DynamicResource BrushTextGrey}"
Text="{DynamicResource FavoritesMediaCount}" />
<!--<StackPanel.Style>
<Style TargetType="{x:Type StackPanel}">
<Style.Triggers>
<DataTrigger Binding="{Binding Favorites.MediaCount}" Value="0">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
<DataTrigger Binding="{Binding Favorites.MediaCount}" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>-->
</StackPanel>
</Grid>
@@ -280,7 +269,7 @@
<!-- 右侧内容区 -->
<ListBox
x:Name="nameFavoritesMedias"
x:Name="NameFavoritesMedias"
Grid.Column="1"
Margin="30,0,0,0"
ItemsSource="{Binding FavoritesMedias, Mode=TwoWay}"
@@ -288,7 +277,7 @@
<i:Interaction.Behaviors>
<ia:EventTriggerBehavior EventName="SelectionChanged">
<ia:InvokeCommandAction Command="{Binding FavoritesMediasCommand}"
CommandParameter="{Binding ElementName=nameFavoritesMedias, Path=SelectedItem}" />
CommandParameter="{Binding ElementName=NameFavoritesMedias, Path=SelectedItem}" />
</ia:EventTriggerBehavior>
</i:Interaction.Behaviors>
<ListBox.Template>
@@ -296,7 +285,9 @@
<ScrollViewer
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto">
<StackPanel Orientation="Vertical" />
<StackPanel Orientation="Vertical">
<ItemsPresenter />
</StackPanel>
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>
@@ -306,13 +297,8 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid Margin="0,10" Background="{DynamicResource BrushBackground}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<Grid Margin="0,10" Background="{DynamicResource BrushBackground}"
ColumnDefinitions="auto,150,*,auto">
<TextBlock
Grid.Column="0"
@@ -365,21 +351,20 @@
<i:Interaction.Behaviors>
<ia:EventTriggerBehavior EventName="PointerReleased">
<ia:InvokeCommandAction Command="{Binding TitleCommand}"
CommandParameter="{ReflectionBinding DataContext.PageName, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
CommandParameter="{ReflectionBinding DataContext.PageName, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
</ia:EventTriggerBehavior>
</i:Interaction.Behaviors>
<TextBlock.Theme>
<ControlTheme TargetType="{x:Type TextBlock}">
<TextBlock.Styles>
<Style Selector="TextBlock">
<Setter Property="Foreground"
Value="{DynamicResource BrushTextDark}" />
<!--<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground"
Value="{DynamicResource BrushPrimary}" />
</Trigger>
</Style.Triggers>-->
</ControlTheme>
</TextBlock.Theme>
<Style Selector="^:pointerover">
<Setter Property="Foreground"
Value="{DynamicResource BrushPrimary}">
</Setter>
</Style>
</Style>
</TextBlock.Styles>
</TextBlock>
<StackPanel Grid.Row="1" Orientation="Horizontal">
@@ -427,42 +412,36 @@
FontSize="12"
Text="{Binding UpName, StringFormat={}UP: {0}}">
<i:Interaction.Behaviors>
<ia:EventTriggerBehavior EventName="MouseLeftButtonUp">
<ia:EventTriggerBehavior EventName="PointerReleased">
<ia:InvokeCommandAction Command="{Binding VideoUpperCommand}"
CommandParameter="{ReflectionBinding DataContext.PageName, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
CommandParameter="{ReflectionBinding DataContext.PageName, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
</ia:EventTriggerBehavior>
</i:Interaction.Behaviors>
<TextBlock.Theme>
<ControlTheme TargetType="{x:Type TextBlock}">
<TextBlock.Styles>
<Style Selector="TextBlock">
<Setter Property="Foreground"
Value="{DynamicResource BrushTextGrey}" />
<!--<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground"
Value="{DynamicResource BrushPrimary}" />
</Trigger>
</Style.Triggers>-->
</ControlTheme>
</TextBlock.Theme>
<Style Selector="^:pointerover">
<Setter Property="Foreground"
Value="{DynamicResource BrushPrimary}" />
</Style>
</Style>
</TextBlock.Styles>
</TextBlock>
</Grid>
</Grid>
<!--<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="nameInfoPanel" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="nameIsSelected" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="nameIsSelected" Property="Visibility" Value="Collapsed" />
</Trigger>
</ControlTemplate.Triggers>-->
</ControlTemplate>
</Setter.Value>
</Setter>
<Style Selector="^ /template/ Image#nameIsSelected">
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="^:selected /template/ Image#nameIsSelected">
<Setter Property="IsVisible" Value="True" />
</Style>
<Style Selector="^:pointerover /template/ Border#nameInfoPanel">
<Setter Property="IsVisible" Value="True" />
</Style>
</ControlTheme>
</ListBox.ItemContainerTheme>
</ListBox>
@@ -480,7 +459,7 @@
Foreground="Gray"
IsActive="{Binding MediaLoading}" />
</StackPanel>
</Grid>
<!-- 加载gif -->
<StackPanel