From 098a64a078fe0c5f2bedb04ad9f0ec79fa6c4fea Mon Sep 17 00:00:00 2001 From: zzyyyl Date: Sun, 30 Oct 2022 16:03:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E7=B1=BB=E5=88=AB?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E4=B8=8B=E6=8B=89=E6=A1=86=EF=BC=8C=E6=89=BE?= =?UTF-8?q?=E4=B8=8D=E5=88=B0OTA=E6=97=B6=E5=BC=B9=E5=87=BA=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E8=80=8C=E4=B8=8D=E6=98=AF=E9=94=99=E8=AF=AF=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resources/Localizations/en-us.xaml | 1 + .../Resources/Localizations/zh-cn.xaml | 5 ++- .../VersionUpdateSettingsUserControl.xaml | 29 +++++++------ .../ViewModels/SettingsViewModel.cs | 41 ++++++++++++------- .../ViewModels/VersionUpdateViewModel.cs | 11 ++++- 5 files changed, 56 insertions(+), 31 deletions(-) diff --git a/src/MeoAsstGui/Resources/Localizations/en-us.xaml b/src/MeoAsstGui/Resources/Localizations/en-us.xaml index 6046de1cf7..aa3a0c20b1 100644 --- a/src/MeoAsstGui/Resources/Localizations/en-us.xaml +++ b/src/MeoAsstGui/Resources/Localizations/en-us.xaml @@ -122,6 +122,7 @@ Auto check update Auto download update + Stable release Beta release Nightly release Download via aria2 diff --git a/src/MeoAsstGui/Resources/Localizations/zh-cn.xaml b/src/MeoAsstGui/Resources/Localizations/zh-cn.xaml index 3019a48f59..06df5a8059 100644 --- a/src/MeoAsstGui/Resources/Localizations/zh-cn.xaml +++ b/src/MeoAsstGui/Resources/Localizations/zh-cn.xaml @@ -122,8 +122,9 @@ 自动检查更新 自动下载更新包 - 检查测试版本更新 - 检查内测版本更新 + 稳定版 + 测试版 + 内测版 使用 aria2 进行下载 检查更新 diff --git a/src/MeoAsstGui/UserControl/VersionUpdateSettingsUserControl.xaml b/src/MeoAsstGui/UserControl/VersionUpdateSettingsUserControl.xaml index 026ec8871c..b4229607bc 100644 --- a/src/MeoAsstGui/UserControl/VersionUpdateSettingsUserControl.xaml +++ b/src/MeoAsstGui/UserControl/VersionUpdateSettingsUserControl.xaml @@ -36,20 +36,23 @@ Content="{DynamicResource UpdateAutoDownload}" IsChecked="{Binding AutoDownloadUpdatePackage}" IsEnabled="{Binding UpdateCheck}" /> - - + Orientation="Horizontal"> + + + + { + new CombData { Display = Localization.GetString("UpdateCheckStable"), Value = "Stable" }, + new CombData { Display = Localization.GetString("UpdateCheckBeta"), Value = "Beta" }, + new CombData { Display = Localization.GetString("UpdateCheckNightly"), Value = "Nightly" }, + }; + LanguageList = new List(); foreach (var pair in Localization.SupportedLanguages) { @@ -494,6 +501,11 @@ namespace MeoAsstGui /// public List InverseClearModeList { get; set; } + /// + /// Gets or sets the list of the version type. + /// + public List VersionTypeList { get; set; } + /// /// Gets or sets the language list. /// @@ -1379,34 +1391,35 @@ namespace MeoAsstGui } /* 软件更新设置 */ - private bool _updateNightly = Convert.ToBoolean(ViewStatusStorage.Get("VersionUpdate.UpdateNightly", bool.FalseString)); + private string _versionType = ViewStatusStorage.Get("VersionUpdate.VersionType", "Stable"); /// - /// Gets or sets a value indicating whether to update nightly. + /// Gets or sets the type of version to update. /// - public bool UpdateNightly + public string VersionType { - get => _updateNightly; + get => _versionType; set { - SetAndNotify(ref _updateNightly, value); - ViewStatusStorage.Set("VersionUpdate.UpdateNightly", value.ToString()); + SetAndNotify(ref _versionType, value); + ViewStatusStorage.Set("VersionUpdate.VersionType", value); } } - private bool _updateBeta = Convert.ToBoolean(ViewStatusStorage.Get("VersionUpdate.UpdateBeta", bool.FalseString)); + /// + /// Gets a value indicating whether to update nightly. + /// + public bool UpdateNightly + { + get => _versionType == "Nightly"; + } /// - /// Gets or sets a value indicating whether to update beta version. + /// Gets a value indicating whether to update beta version. /// public bool UpdateBeta { - get => _updateBeta; - set - { - SetAndNotify(ref _updateBeta, value); - ViewStatusStorage.Set("VersionUpdate.UpdateBeta", value.ToString()); - } + get => _versionType == "Beta"; } private bool _updateCheck = Convert.ToBoolean(ViewStatusStorage.Get("VersionUpdate.UpdateCheck", bool.TrueString)); diff --git a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs index 06e0f549e6..b688af5cf1 100644 --- a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs +++ b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs @@ -530,8 +530,15 @@ namespace MeoAsstGui return true; } - var errorView = new ErrorView("Download Failed", "It was not possible to find a suitable OTA file to download.", false); - errorView.ShowDialog(); + Execute.OnUIThread(() => + { + using (var toast = new ToastNotification("找不到合适的更新文件")) + { + toast.AppendContentText("新版本:" + _latestVersion) + .AppendContentText("请自行下载完整包更新!") + .ShowUpdateVersion(); + } + }); return false; } catch (Exception e)