feat.增加一个是否检查更新的选项

This commit is contained in:
zzyyyl
2022-05-13 17:07:31 +08:00
parent 214d596764
commit eaa2981aa7
3 changed files with 20 additions and 3 deletions

View File

@@ -17,9 +17,10 @@
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Margin="3">
<CheckBox IsChecked="{Binding AutoDownloadUpdatePackage}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" Content="自动下载更新包 " />
<CheckBox IsChecked="{Binding UpdateBeta}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" Content="检查测试版本更新 " />
<CheckBox IsChecked="{Binding UseAria2}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" Content="使用aria2进行下载" />
<CheckBox IsChecked="{Binding UpdateCheck}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="150" Margin="10" Content="检查更新" />
<CheckBox IsChecked="{Binding AutoDownloadUpdatePackage}" IsEnabled="{Binding UpdateCheck}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="150" Margin="10" Content="自动下载更新" />
<CheckBox IsChecked="{Binding UpdateBeta}" IsEnabled="{Binding UpdateCheck}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="150" Margin="10" Content="检查测试版本更新" />
<CheckBox IsChecked="{Binding UseAria2}" IsEnabled="{Binding UpdateCheck}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="150" Margin="10" Content="使用 aria2 进行下载" />
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Margin="3">
<Grid>

View File

@@ -712,6 +712,18 @@ namespace MeoAsstGui
}
}
private bool _updateCheck = Convert.ToBoolean(ViewStatusStorage.Get("VersionUpdate.UpdateCheck", bool.TrueString));
public bool UpdateCheck
{
get { return _updateCheck; }
set
{
SetAndNotify(ref _updateCheck, value);
ViewStatusStorage.Set("VersionUpdate.UpdateCheck", value.ToString());
}
}
private string _proxy = ViewStatusStorage.Get("VersionUpdate.Proxy", string.Empty);
public string Proxy

View File

@@ -307,6 +307,10 @@ namespace MeoAsstGui
public bool CheckUpdate()
{
var settings = _container.Get<SettingsViewModel>();
if (!settings.UpdateCheck)
{
return false;
}
const int requestRetryMaxTimes = 5;
var response = RequestApi(RequestUrl);
for (int i = 0; response.Length == 0 && i >= requestRetryMaxTimes; i++)