Merge pull request #496 from zzyyyl/feat/update-check

feat.优化检查更新的UI
This commit is contained in:
MistEO
2022-05-13 19:53:18 +08:00
committed by GitHub
4 changed files with 29 additions and 9 deletions

View File

@@ -24,7 +24,7 @@
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="1" VerticalAlignment="Center">
<CheckBox IsChecked="{Binding UseStone}" IsHitTestVisible="{Binding Idle}" Content="吃石头 " Margin="10" />
<CheckBox IsChecked="{Binding UseStone}" IsHitTestVisible="{Binding Idle}" Content="吃石头 " Margin="10" />
<TextBox Text="{Binding StoneNumber}" IsReadOnly="{c:Binding Path=!Idle}" TextWrapping="Wrap" Margin="10"
Width="50" InputMethod.IsInputMethodEnabled="False" />
<TextBlock Style="{StaticResource TextBlockDefault}" Text="颗" />

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++)
@@ -322,14 +326,17 @@ namespace MeoAsstGui
{
var releaseArray = JsonConvert.DeserializeObject(response) as JArray;
for (int i = 0; i <= releaseArray.Count; i++)
for (int i = 0; i < releaseArray.Count; i++)
{
if (((bool)releaseArray[i]["prerelease"]) && settings.UpdateBeta)
if ((bool)releaseArray[i]["prerelease"])
{
_lastestJson = releaseArray[i] as JObject;
break;
if (settings.UpdateBeta)
{
_lastestJson = releaseArray[i] as JObject;
break;
}
}
else if ((!(bool)releaseArray[i]["prerelease"]) && (!settings.UpdateBeta))
else
{
_lastestJson = releaseArray[i] as JObject;
break;