feat: 优化一下重复下载提醒,可以在设置中设置每次询问、总是重复下载或者跳过 #976 #957 #942 #939

pull/965/head
yaobiao 2 years ago
parent 2789488733
commit c7655ee66b

@ -308,6 +308,7 @@
<Compile Include="Settings\Models\VideoContentSettings.cs" />
<Compile Include="Settings\OrderFormat.cs" />
<Compile Include="Settings\ParseScope.cs" />
<Compile Include="Settings\RepeatDownloadStrategy.cs" />
<Compile Include="Settings\SettingsManager.Video.cs" />
<Compile Include="Settings\SettingsManager.Basic.cs" />
<Compile Include="Settings\SettingsManager.Network.cs" />

@ -11,5 +11,6 @@
public ParseScope ParseScope { get; set; } = ParseScope.NOT_SET;
public AllowStatus IsAutoDownloadAll { get; set; } = AllowStatus.NONE;
public DownloadFinishedSort DownloadFinishedSort { get; set; } = DownloadFinishedSort.NOT_SET;
public RepeatDownloadStrategy RepeatDownloadStrategy { get; set; } = RepeatDownloadStrategy.Ask;
}
}

@ -0,0 +1,9 @@
namespace DownKyi.Core.Settings
{
public enum RepeatDownloadStrategy
{
Ask,
ReDownload,
JumpOver
}
}

@ -19,6 +19,9 @@
// 下载完成列表排序
private readonly DownloadFinishedSort finishedSort = DownloadFinishedSort.DOWNLOAD;
// 重复下载策略
private readonly RepeatDownloadStrategy _repeatDownloadStrategy = RepeatDownloadStrategy.Ask;
/// <summary>
/// 获取下载完成后的操作
@ -182,5 +185,32 @@
return SetSettings();
}
/// <summary>
/// 获取重复下载策略
/// </summary>
/// <returns></returns>
public RepeatDownloadStrategy GetRepeatDownloadStrategy()
{
appSettings = GetSettings();
if (appSettings.Basic.RepeatDownloadStrategy == RepeatDownloadStrategy.Ask)
{
// 第一次获取,先设置默认值
SetRepeatDownloadStrategy(_repeatDownloadStrategy);
return _repeatDownloadStrategy;
}
return appSettings.Basic.RepeatDownloadStrategy;
}
/// <summary>
/// 设置重复下载策略
/// </summary>
/// <param name="repeatDownloadStrategy"></param>
/// <returns></returns>
public bool SetRepeatDownloadStrategy(RepeatDownloadStrategy repeatDownloadStrategy)
{
appSettings.Basic.RepeatDownloadStrategy = repeatDownloadStrategy;
return SetSettings();
}
}
}

@ -116,6 +116,7 @@
<Compile Include="Models\Downloading.cs" />
<Compile Include="Models\DownloadStatus.cs" />
<Compile Include="Models\OrderFormatDisplay.cs" />
<Compile Include="Models\RepeatDownloadStrategyDisplay.cs" />
<Compile Include="Services\AlertService.cs" />
<Compile Include="Services\Download\AddToDownloadService.cs" />
<Compile Include="Services\Download\CustomAriaDownloadService.cs" />

@ -195,6 +195,10 @@
<system:String x:Key="ListenClipboard">监听剪贴板</system:String>
<system:String x:Key="VideoAutoParse">视频自动解析</system:String>
<system:String x:Key="VideoParseScope">视频解析范围:</system:String>
<system:String x:Key="RepeatDownloadStrategy">重复下载策略:</system:String>
<system:String x:Key="RepeatDownloadAsk">每次询问</system:String>
<system:String x:Key="RepeatDownloadReDownload">重新下载</system:String>
<system:String x:Key="RepeatDownloadReJumpOver">跳过重复项</system:String>
<system:String x:Key="AutoDownloadAll">解析后自动下载已解析视频</system:String>
<system:String x:Key="Network">网络</system:String>

@ -0,0 +1,10 @@
using DownKyi.Core.Settings;
namespace DownKyi.Models
{
public class RepeatDownloadStrategyDisplay
{
public string Name { get; set; }
public RepeatDownloadStrategy RepeatDownloadStrategy { get; set; }
}
}

@ -279,21 +279,37 @@ namespace DownKyi.Services.Download
{
//eventAggregator.GetEvent<MessageEvent>().Publish($"{page.Name}{DictionaryResource.GetString("TipAlreadyToAddDownloaded")}");
//isDownloaded = true;
AlertService alertService = new AlertService(dialogService);
ButtonResult result = alertService.ShowInfo(DictionaryResource.GetString("TipAlreadyToAddDownloaded2"));
if (result == ButtonResult.OK)
var repeatDownloadStrategy = SettingsManager.GetInstance().GetRepeatDownloadStrategy();
switch (repeatDownloadStrategy)
{
App.PropertyChangeAsync(() =>
case RepeatDownloadStrategy.Ask:
{
App.DownloadedList.Remove(item);
});
isDownloaded = false;
}
else
{
isDownloaded = true;
AlertService alertService = new AlertService(dialogService);
ButtonResult result = alertService.ShowInfo(DictionaryResource.GetString("TipAlreadyToAddDownloaded2"));
if (result == ButtonResult.OK)
{
App.PropertyChangeAsync(() =>
{
App.DownloadedList.Remove(item);
});
isDownloaded = false;
}
else
{
isDownloaded = true;
}
break;
}
case RepeatDownloadStrategy.ReDownload:
isDownloaded = false;
break;
case RepeatDownloadStrategy.JumpOver:
isDownloaded = true;
break;
default:
isDownloaded = true;
break;
}
break;

@ -73,6 +73,22 @@ namespace DownKyi.ViewModels.Settings
get => autoDownloadAll;
set => SetProperty(ref autoDownloadAll, value);
}
private List<RepeatDownloadStrategyDisplay> _repeatDownloadStrategy;
public List<RepeatDownloadStrategyDisplay> RepeatDownloadStrategy
{
get => _repeatDownloadStrategy;
set => SetProperty(ref _repeatDownloadStrategy, value);
}
private RepeatDownloadStrategyDisplay _selectedRepeatDownloadStrategy;
public RepeatDownloadStrategyDisplay SelectedRepeatDownloadStrategy
{
get => _selectedRepeatDownloadStrategy;
set => SetProperty(ref _selectedRepeatDownloadStrategy, value);
}
#endregion
@ -89,6 +105,14 @@ namespace DownKyi.ViewModels.Settings
new ParseScopeDisplay{ Name = DictionaryResource.GetString("ParseCurrentSection"), ParseScope = ParseScope.CURRENT_SECTION },
new ParseScopeDisplay{ Name = DictionaryResource.GetString("ParseAll"), ParseScope = ParseScope.ALL }
};
// 重复下载策略
RepeatDownloadStrategy = new List<RepeatDownloadStrategyDisplay>
{
new RepeatDownloadStrategyDisplay { Name = DictionaryResource.GetString("RepeatDownloadAsk"), RepeatDownloadStrategy = Core.Settings.RepeatDownloadStrategy.Ask },
new RepeatDownloadStrategyDisplay { Name = DictionaryResource.GetString("RepeatDownloadReDownload"), RepeatDownloadStrategy = Core.Settings.RepeatDownloadStrategy.ReDownload },
new RepeatDownloadStrategyDisplay { Name = DictionaryResource.GetString("RepeatDownloadReJumpOver"), RepeatDownloadStrategy = Core.Settings.RepeatDownloadStrategy.JumpOver }
};
#endregion
@ -123,6 +147,10 @@ namespace DownKyi.ViewModels.Settings
// 解析后是否自动下载解析视频
AllowStatus isAutoDownloadAll = SettingsManager.GetInstance().IsAutoDownloadAll();
AutoDownloadAll = isAutoDownloadAll == AllowStatus.YES;
// 重复下载策略
var repeatDownloadStrategy = SettingsManager.GetInstance().GetRepeatDownloadStrategy();
SelectedRepeatDownloadStrategy = RepeatDownloadStrategy.FirstOrDefault(t => t.RepeatDownloadStrategy == repeatDownloadStrategy);
isOnNavigatedTo = false;
}
@ -218,6 +246,26 @@ namespace DownKyi.ViewModels.Settings
bool isSucceed = SettingsManager.GetInstance().IsAutoDownloadAll(isAutoDownloadAll);
PublishTip(isSucceed);
}
// 解析范围事件
private DelegateCommand<object> _repeatDownloadStrategyCommand;
public DelegateCommand<object> RepeatDownloadStrategyCommand => _repeatDownloadStrategyCommand ?? (_repeatDownloadStrategyCommand = new DelegateCommand<object>(ExecuteRepeatDownloadStrategyCommand));
/// <summary>
/// 解析范围事件
/// </summary>
/// <param name="parameter"></param>
private void ExecuteRepeatDownloadStrategyCommand(object parameter)
{
if (!(parameter is RepeatDownloadStrategyDisplay repeatDownloadStrategy))
{
return;
}
var isSucceed = SettingsManager.GetInstance().SetRepeatDownloadStrategy(repeatDownloadStrategy.RepeatDownloadStrategy);
PublishTip(isSucceed);
}
#endregion

@ -112,7 +112,27 @@
Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding AutoDownloadAll, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" />
<StackPanel Margin="0,20,0,0" Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
FontSize="12"
Foreground="{DynamicResource BrushTextDark}"
Text="{DynamicResource RepeatDownloadStrategy}" />
<ComboBox
Name="NameRepeatDownloadStrategy"
Width="120"
VerticalContentAlignment="Center"
DisplayMemberPath=" Name"
ItemsSource="{Binding RepeatDownloadStrategy}"
SelectedItem="{Binding SelectedRepeatDownloadStrategy}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding RepeatDownloadStrategyCommand}" CommandParameter="{Binding ElementName=NameRepeatDownloadStrategy, Path=SelectedItem}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
<StackPanel Margin="10" />
</StackPanel>
</ScrollViewer>

Loading…
Cancel
Save