mirror of
https://github.com/Pixeval/Pixeval.git
synced 2025-01-08 11:47:34 +08:00
收藏后自动下载功能 (#390)
This commit is contained in:
parent
855548ec01
commit
1920aae9cf
@ -6,6 +6,7 @@ using WinUI3Utilities.Attributes;
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<XamlUICommand>("Command")]
|
||||
[DependencyProperty<object>("CommandParameter", IsNullable = true)]
|
||||
public sealed partial class HeartButton
|
||||
{
|
||||
public HeartButton() => InitializeComponent();
|
||||
@ -14,7 +15,7 @@ public sealed partial class HeartButton
|
||||
{
|
||||
e.Handled = true;
|
||||
if (IsTapEnabled)
|
||||
Command.Execute(null);
|
||||
Command.Execute(CommandParameter);
|
||||
}
|
||||
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
@ -105,6 +105,9 @@ public partial record AppSettings : IWindowSettings
|
||||
[SettingMetadata(SettingEntryCategory.Download, typeof(SettingsPageResources), nameof(SettingsPageResources.MaxDownloadConcurrencyLevelEntryHeader))]
|
||||
public int MaxDownloadTaskConcurrencyLevel { get; set; } = Environment.ProcessorCount / 2;
|
||||
|
||||
[SettingMetadata(SettingEntryCategory.Download, typeof(SettingsPageResources), nameof(SettingsPageResources.DownloadWhenBookmarkedEntryHeader))]
|
||||
public bool DownloadWhenBookmarked { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The application-wide default sort option, any illustration page that supports
|
||||
/// different orders will use this as its default value
|
||||
@ -174,12 +177,6 @@ public partial record AppSettings : IWindowSettings
|
||||
[SettingMetadata(SettingEntryCategory.BrowsingExperience, typeof(SettingsPageResources), nameof(SettingsPageResources.FiltrateRestrictedContentEntryHeader))]
|
||||
public bool FiltrateRestrictedContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// How many rows to be preloaded in illustration grid
|
||||
/// </summary>
|
||||
[SettingMetadata(SettingEntryCategory.Misc, typeof(SettingsPageResources), nameof(SettingsPageResources.PreloadRowsEntryHeader))]
|
||||
public int PreLoadRows { get; set; } = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the maximum page count that are allowed to be retrieved during
|
||||
/// spotlight retrieval(10 entries per page)
|
||||
|
@ -34,8 +34,6 @@ namespace Pixeval.Controls;
|
||||
|
||||
public partial class ThumbnailEntryViewModel<T>
|
||||
{
|
||||
public XamlUICommand BookmarkCommand { get; } = "".GetCommand(FontIconSymbol.HeartEB51, VirtualKeyModifiers.Control, VirtualKey.D);
|
||||
|
||||
public XamlUICommand AddToBookmarkCommand { get; } = EntryItemResources.AddToBookmark.GetCommand(FontIconSymbol.BookmarksE8A4);
|
||||
|
||||
public XamlUICommand GenerateLinkCommand { get; } = EntryItemResources.GenerateLink.GetCommand(FontIconSymbol.LinkE71B);
|
||||
@ -48,6 +46,12 @@ public partial class ThumbnailEntryViewModel<T>
|
||||
|
||||
public XamlUICommand ShowPixEzQrCodeCommand { get; } = EntryItemResources.ShowPixEzQrCode.GetCommand(FontIconSymbol.Photo2EB9F);
|
||||
|
||||
/// <summary>
|
||||
/// Parameter1: <see cref="ValueTuple{T1, T2}"/> where T1 is <see cref="FrameworkElement"/>? and T2 is <see cref="Func{T, TResult}"/>? where T is <see cref="IProgress{T}"/>? and TResult is <see cref="Stream"/>?<br/>
|
||||
/// Parameter2: <see cref="FrameworkElement"/>?
|
||||
/// </summary>
|
||||
public XamlUICommand BookmarkCommand { get; } = "".GetCommand(FontIconSymbol.HeartEB51, VirtualKeyModifiers.Control, VirtualKey.D);
|
||||
|
||||
/// <summary>
|
||||
/// Parameter1: <see cref="ValueTuple{T1, T2}"/> where T1 is <see cref="FrameworkElement"/>? and T2 is <see cref="Func{T, TResult}"/>? where T is <see cref="IProgress{T}"/>? and TResult is <see cref="Stream"/>?<br/>
|
||||
/// Parameter2: <see cref="FrameworkElement"/>?
|
||||
@ -68,9 +72,6 @@ public partial class ThumbnailEntryViewModel<T>
|
||||
|
||||
private void InitializeCommands()
|
||||
{
|
||||
BookmarkCommand.GetBookmarkCommand(IsBookmarked);
|
||||
BookmarkCommand.ExecuteRequested += BookmarkCommandOnExecuteRequested;
|
||||
|
||||
// TODO: AddToBookmarkCommand
|
||||
AddToBookmarkCommand.CanExecuteRequested += (sender, args) => args.CanExecute = false;
|
||||
|
||||
@ -84,6 +85,9 @@ public partial class ThumbnailEntryViewModel<T>
|
||||
|
||||
ShowPixEzQrCodeCommand.ExecuteRequested += ShowPixEzQrCodeCommandOnExecuteRequested;
|
||||
|
||||
BookmarkCommand.GetBookmarkCommand(IsBookmarked);
|
||||
BookmarkCommand.ExecuteRequested += BookmarkCommandOnExecuteRequested;
|
||||
|
||||
SaveCommand.ExecuteRequested += SaveCommandOnExecuteRequested;
|
||||
|
||||
SaveAsCommand.ExecuteRequested += SaveAsCommandOnExecuteRequested;
|
||||
@ -91,8 +95,6 @@ public partial class ThumbnailEntryViewModel<T>
|
||||
CopyCommand.ExecuteRequested += CopyCommandOnExecuteRequested;
|
||||
}
|
||||
|
||||
protected abstract void BookmarkCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs e);
|
||||
|
||||
private void GenerateLinkCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args)
|
||||
{
|
||||
UiHelper.ClipboardSetText(AppUri.OriginalString);
|
||||
@ -152,11 +154,13 @@ public partial class ThumbnailEntryViewModel<T>
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void SaveCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs e);
|
||||
protected abstract void BookmarkCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args);
|
||||
|
||||
protected abstract void SaveAsCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs e);
|
||||
protected abstract void SaveCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args);
|
||||
|
||||
protected abstract void CopyCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs e);
|
||||
protected abstract void SaveAsCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args);
|
||||
|
||||
protected abstract void CopyCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args);
|
||||
|
||||
protected abstract Uri AppUri { get; }
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
||||
</Grid.RenderTransform>
|
||||
<Grid.ContextFlyout>
|
||||
<MenuFlyout>
|
||||
<MenuFlyoutItem Command="{x:Bind ViewModel.BookmarkCommand, Mode=OneWay}" />
|
||||
<MenuFlyoutItem Command="{x:Bind ViewModel.BookmarkCommand, Mode=OneWay}" CommandParameter="{x:Bind}" />
|
||||
<MenuFlyoutItem Command="{x:Bind ViewModel.AddToBookmarkCommand, Mode=OneWay}" />
|
||||
<MenuFlyoutSeparator />
|
||||
<MenuFlyoutItem Command="{x:Bind ViewModel.SaveCommand, Mode=OneWay}" CommandParameter="{x:Bind}" />
|
||||
@ -75,7 +75,8 @@
|
||||
x:Name="HeartButton"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
Command="{x:Bind ViewModel.BookmarkCommand, Mode=OneWay}" />
|
||||
Command="{x:Bind ViewModel.BookmarkCommand, Mode=OneWay}"
|
||||
CommandParameter="{x:Bind}" />
|
||||
<Grid
|
||||
Margin="10"
|
||||
VerticalAlignment="Bottom"
|
||||
|
@ -41,6 +41,8 @@ public partial class IllustrationItemViewModel
|
||||
{
|
||||
IsBookmarked = await MakoHelper.SetIllustrationBookmarkAsync(Id, !IsBookmarked);
|
||||
BookmarkCommand.GetBookmarkCommand(IsBookmarked);
|
||||
if (App.AppViewModel.AppSettings.DownloadWhenBookmarked && IsBookmarked)
|
||||
SaveCommandOnExecuteRequested(sender, args);
|
||||
}
|
||||
|
||||
protected override async void SaveCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args)
|
||||
|
@ -46,6 +46,7 @@
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
Command="{x:Bind ViewModel.BookmarkCommand, Mode=OneWay}"
|
||||
CommandParameter="{x:Bind}"
|
||||
IsTapEnabled="False" />
|
||||
<local:DockPanel
|
||||
Grid.Column="1"
|
||||
@ -160,7 +161,8 @@
|
||||
Grid.Row="0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
Command="{x:Bind ViewModel.BookmarkCommand, Mode=OneWay}">
|
||||
Command="{x:Bind ViewModel.BookmarkCommand, Mode=OneWay}"
|
||||
CommandParameter="{x:Bind}">
|
||||
<Grid.RenderTransform>
|
||||
<ScaleTransform ScaleX="1" ScaleY="1" />
|
||||
</Grid.RenderTransform>
|
||||
|
@ -27,23 +27,25 @@ namespace Pixeval.Controls;
|
||||
|
||||
public partial class NovelItemViewModel
|
||||
{
|
||||
protected override async void BookmarkCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs e)
|
||||
protected override async void BookmarkCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args)
|
||||
{
|
||||
IsBookmarked = await MakoHelper.SetNovelBookmarkAsync(Id, !IsBookmarked);
|
||||
BookmarkCommand.GetBookmarkCommand(IsBookmarked);
|
||||
if (App.AppViewModel.AppSettings.DownloadWhenBookmarked && IsBookmarked && !User.IsFollowed)
|
||||
SaveCommandOnExecuteRequested(sender, args);
|
||||
}
|
||||
|
||||
protected override void SaveCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs e)
|
||||
protected override void SaveCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void SaveAsCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs e)
|
||||
protected override void SaveAsCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void CopyCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs e)
|
||||
protected override void CopyCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -189,7 +189,10 @@
|
||||
Grid.Row="1"
|
||||
DefaultLabelPosition="Collapsed"
|
||||
OverflowButtonVisibility="Collapsed">
|
||||
<AppBarButton Width="50" Command="{x:Bind _viewModel.CurrentIllustration.BookmarkCommand, Mode=OneWay}" />
|
||||
<AppBarButton
|
||||
Width="50"
|
||||
Command="{x:Bind _viewModel.CurrentIllustration.BookmarkCommand, Mode=OneWay}"
|
||||
CommandParameter="{x:Bind _viewModel.CurrentImage.DownloadParameter, Mode=OneWay}" />
|
||||
<AppBarButton
|
||||
Width="50"
|
||||
Command="{x:Bind _viewModel.CurrentImage.RotateCounterclockwiseCommand, Mode=OneWay}"
|
||||
|
@ -28,7 +28,7 @@
|
||||
<!-- PrimaryCommands 点击后不会自动隐藏Flyout -->
|
||||
<CommandBarFlyout>
|
||||
<AppBarButton Command="{x:Bind _viewModel.PlayGifCommand}" Visibility="{x:Bind _viewModel.IllustrationViewModel.IsUgoira, Converter={StaticResource BoolToVisibilityConverter}}" />
|
||||
<AppBarButton Command="{x:Bind _viewModel.IllustrationViewModel.BookmarkCommand}" />
|
||||
<AppBarButton Command="{x:Bind _viewModel.IllustrationViewModel.BookmarkCommand}" CommandParameter="{x:Bind _viewModel.DownloadParameter}" />
|
||||
<AppBarSeparator />
|
||||
<AppBarButton Command="{x:Bind _viewModel.ZoomInCommand}" />
|
||||
<AppBarButton Command="{x:Bind _viewModel.ZoomOutCommand}" />
|
||||
|
@ -330,13 +330,13 @@ public partial class ImageViewerPageViewModel : UiObservableObject, IDisposable
|
||||
private void InitializeCommands()
|
||||
{
|
||||
SaveCommand.CanExecuteRequested += LoadingCompletedCanExecuteRequested;
|
||||
SaveCommand.ExecuteRequested += (_, _) => IllustrationViewModel.SaveCommand.Execute((FrameworkElement, (Func<IProgress<int>?, Task<Stream?>>)(p => GetOriginalImageSourceAsync(p))));
|
||||
SaveCommand.ExecuteRequested += (_, _) => IllustrationViewModel.SaveCommand.Execute(DownloadParameter);
|
||||
|
||||
SaveAsCommand.CanExecuteRequested += LoadingCompletedCanExecuteRequested;
|
||||
SaveAsCommand.ExecuteRequested += (_, _) => IllustrationViewModel.SaveAsCommand.Execute((Window, (Func<IProgress<int>?, Task<Stream?>>)(p => GetOriginalImageSourceAsync(p))));
|
||||
|
||||
CopyCommand.CanExecuteRequested += LoadingCompletedCanExecuteRequested;
|
||||
CopyCommand.ExecuteRequested += (_, _) => IllustrationViewModel.CopyCommand.Execute((FrameworkElement, (Func<IProgress<int>?, Task<Stream?>>)(p => GetOriginalImageSourceAsync(p))));
|
||||
CopyCommand.ExecuteRequested += (_, _) => IllustrationViewModel.CopyCommand.Execute(DownloadParameter);
|
||||
|
||||
PlayGifCommand.CanExecuteRequested += (_, e) => e.CanExecute = IllustrationViewModel.IsUgoira && LoadSuccessfully;
|
||||
PlayGifCommand.ExecuteRequested += PlayGifCommandOnExecuteRequested;
|
||||
@ -389,6 +389,8 @@ public partial class ImageViewerPageViewModel : UiObservableObject, IDisposable
|
||||
|
||||
private void IsNotUgoiraAndLoadingCompletedCanExecuteRequested(XamlUICommand sender, CanExecuteRequestedEventArgs args) => args.CanExecute = !IllustrationViewModel.IsUgoira && LoadSuccessfully;
|
||||
|
||||
public (FrameworkElement FrameworkElement, Func<IProgress<int>?, Task<Stream?>>) DownloadParameter => (FrameworkElement, p => GetOriginalImageSourceAsync(p));
|
||||
|
||||
public XamlUICommand SaveCommand { get; } = EntryItemResources.Save.GetCommand(
|
||||
FontIconSymbol.SaveE74E, VirtualKeyModifiers.Control, VirtualKey.S);
|
||||
|
||||
|
@ -659,6 +659,13 @@
|
||||
</controls:SettingsExpander.Items>
|
||||
</controls:SettingsExpander>
|
||||
|
||||
<controls:SettingsCard
|
||||
x:Uid="/SettingsPage/DownloadWhenBookmarkedEntry"
|
||||
HeaderIcon="{markup:FontSymbolIcon Glyph=SaveLocalE78C}"
|
||||
Tag="{x:Bind misc2:SettingEntry.DownloadWhenBookmarked}">
|
||||
<ToggleSwitch IsOn="{x:Bind ViewModel.DownloadWhenBookmarked, Mode=TwoWay}" />
|
||||
</controls:SettingsCard>
|
||||
|
||||
<TextBlock x:Uid="/SettingsPage/MiscSettingsGroup" Style="{StaticResource SettingHeaderStyle}" />
|
||||
|
||||
<controls:SettingsCard
|
||||
@ -709,16 +716,6 @@
|
||||
LosingFocus="ImageMirrorServerTextBox_OnLosingFocus"
|
||||
Text="{x:Bind ViewModel.MirrorHost, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</controls:SettingsCard>
|
||||
|
||||
<controls:SettingsCard
|
||||
x:Uid="/SettingsPage/PreloadRowsEntry"
|
||||
HeaderIcon="{markup:FontSymbolIcon Glyph=ShowResultsE8BC}"
|
||||
Tag="{x:Bind misc2:SettingEntry.PreLoadRows}">
|
||||
<Slider
|
||||
Maximum="15"
|
||||
Minimum="0"
|
||||
Value="{x:Bind ViewModel.PreLoadRows, Mode=TwoWay}" />
|
||||
</controls:SettingsCard>
|
||||
<!-- endregion -->
|
||||
<TeachingTip
|
||||
x:Name="ImageMirrorServerTextBoxTeachingTip"
|
||||
|
@ -91,8 +91,6 @@
|
||||
"OverwriteDownloadedFileEntry/Description": "The old file with same name will be overwritten once this setting is turned on",
|
||||
"OverwriteDownloadedFileEntry/Header": "Overwrite downloaded files",
|
||||
"PerformSignOutButton/Content": "Sign out",
|
||||
"PreloadRowsEntry/Description": "How many rows will be preloaded, higher value indicates fluent experience, but uses more resources",
|
||||
"PreloadRowsEntry/Header": "Preload rows",
|
||||
"RecommendationItemLimitEntry/Description": "How many works will be fetch in Recommend",
|
||||
"RecommendationItemLimitEntry/Header": "Maximum recommend work",
|
||||
"RecommendationItemLimitNumberBox/PlaceholderText": "[500, 2500]",
|
||||
|
@ -89,8 +89,6 @@
|
||||
"OverwriteDownloadedFileEntry/Description": "Если этот параметр включен, при загрузке файлы будут перезаписываться, если они уже существуют",
|
||||
"OverwriteDownloadedFileEntry/Header": "Перезаписывать скачанные файлы",
|
||||
"PerformSignOutButton/Content": "Выход из системы",
|
||||
"PreloadRowsEntry/Description": "Количество строк иллюстраций, которые будут предварительно загружены во время просмотра, чтобы улучшить плавность прокрутки, но это увеличит использование сети и ресурсов",
|
||||
"PreloadRowsEntry/Header": "Количество строк для предварительной загрузки",
|
||||
"RecommendationItemLimitEntry/Description": "Максимальное количество иллюстраций, получаемых при использовании функции ежедневных рекомендаций",
|
||||
"RecommendationItemLimitEntry/Header": "Ограничение на количество ежедневных рекомендаций",
|
||||
"RecommendationItemLimitNumberBox/PlaceholderText": "Ограничение на количество рекомендаций [500, 2500]",
|
||||
|
@ -96,8 +96,8 @@
|
||||
"OverwriteDownloadedFileEntry/Description": "开启该选项则下载文件时将会覆写之前已经下载过的文件",
|
||||
"OverwriteDownloadedFileEntry/Header": "覆写已下载文件",
|
||||
"PerformSignOutButton/Content": "执行登出",
|
||||
"PreloadRowsEntry/Description": "浏览插画时会提前加载多少行插画,提升浏览流畅度,但会增加网络与资源占用",
|
||||
"PreloadRowsEntry/Header": "预加载行数",
|
||||
"DownloadWhenBookmarkedEntry/Description": "在某作者的收藏作品后,会自动下载作品",
|
||||
"DownloadWhenBookmarkedEntry/Header": "收藏作品时下载",
|
||||
"RecommendationItemLimitEntry/Description": "使用每日推荐功能时最多会获取多少条插画",
|
||||
"RecommendationItemLimitEntry/Header": "每日推荐结果数量限制",
|
||||
"RecommendationItemLimitNumberBox/PlaceholderText": "每日推荐数量限制[500, 2500]",
|
||||
|
Loading…
Reference in New Issue
Block a user