feat: 添加 MirrorChyan 资源更新方式 (#11669)

Co-authored-by: MistEO <mistereo@hotmail.com>
This commit is contained in:
uye
2025-01-29 02:16:16 +08:00
committed by GitHub
parent 562da7d257
commit de138a888a
15 changed files with 252 additions and 12 deletions

View File

@@ -228,6 +228,39 @@ public class VersionUpdateSettingsUserControlModel : PropertyChangedBase
private bool _updateCheck = Convert.ToBoolean(ConfigurationHelper.GetGlobalValue(ConfigurationKeys.UpdateCheck, bool.TrueString));
public List<GenericCombinedData<string>> ResourceUpdateSourceList { get; } = [
new() { Display = "Github", Value = "Github" },
new() { Display = LocalizationHelper.GetString("MirrorChyan"), Value = "MirrorChyan" },
];
private string _resourceUpdateSource = ConfigurationHelper.GetGlobalValue(ConfigurationKeys.ResourceUpdateSource, "Github");
/// <summary>
/// Gets or sets the type of version to update.
/// </summary>
public string ResourceUpdateSource
{
get => _resourceUpdateSource;
set
{
SetAndNotify(ref _resourceUpdateSource, value);
ConfigurationHelper.SetGlobalValue(ConfigurationKeys.ResourceUpdateSource, value.ToString());
}
}
private string _mirrorChyanCdk = SimpleEncryptionHelper.Decrypt(ConfigurationHelper.GetGlobalValue(ConfigurationKeys.MirrorChyanCdk, string.Empty));
public string MirrorChyanCdk
{
get => _mirrorChyanCdk;
set
{
SetAndNotify(ref _mirrorChyanCdk, value);
value = SimpleEncryptionHelper.Encrypt(value);
ConfigurationHelper.SetGlobalValue(ConfigurationKeys.MirrorChyanCdk, value);
}
}
/// <summary>
/// Gets or sets a value indicating whether to check update.
/// </summary>
@@ -392,7 +425,26 @@ public class VersionUpdateSettingsUserControlModel : PropertyChangedBase
public async Task ManualUpdateResource()
{
IsCheckingForUpdates = true;
if (await ResourceUpdater.UpdateFromGithubAsync())
var success = false;
switch (ResourceUpdateSource)
{
case "Github":
if (await ResourceUpdater.UpdateFromGithubAsync())
{
success = true;
}
break;
case "MirrorChyan":
if (await ResourceUpdater.UpdateFromMirrorChyanAsync())
{
success = true;
}
break;
}
if (success)
{
if (AutoInstallUpdatePackage)
{