diff --git a/src/MaaWpfGui/Constants/ConfigurationKeys.cs b/src/MaaWpfGui/Constants/ConfigurationKeys.cs index 29afc4e42a..5ee825ba97 100644 --- a/src/MaaWpfGui/Constants/ConfigurationKeys.cs +++ b/src/MaaWpfGui/Constants/ConfigurationKeys.cs @@ -137,6 +137,7 @@ namespace MaaWpfGui.Constants public const string UpdatAutoCheck = "VersionUpdate.ScheduledUpdateCheck"; public const string UseAria2 = "VersionUpdate.UseAria2"; public const string AutoDownloadUpdatePackage = "VersionUpdate.AutoDownloadUpdatePackage"; + public const string AutoInstallUpdatePackage = "VersionUpdate.AutoInstallUpdatePackage"; public const string PenguinId = "Penguin.Id"; public const string IsDrGrandet = "Penguin.IsDrGrandet"; diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml index 8e3afb7a69..43846a514e 100644 --- a/src/MaaWpfGui/Res/Localizations/en-us.xaml +++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml @@ -144,6 +144,7 @@ Startup Update Check Scheduled Update Check Auto Download Update + Auto Install Update Stable Release Beta Release Nightly Release diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml index 6059a9c72d..119b0185a3 100644 --- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml +++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml @@ -144,6 +144,7 @@ 起動時の更新チェック 定期的な更新チェック 自動アップデート + 自動インストール更新 安定版 ベータ版 内部テスト版 diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml index cf9bfa90f5..fefd7979ff 100644 --- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml +++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml @@ -144,6 +144,7 @@ 시작시 업데이트 확인 일정 시간마다 업데이트 확인 자동으로 업데이트 + 자동 설치 업데이트 패키지 안정 버전 베타 버전 개발 버전 diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml index 6c1996f40b..dfa151d718 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml @@ -144,6 +144,7 @@ 自动检查更新 定时检查更新 自动下载更新包 + 自动安装更新包 稳定版 公测版 内测版 diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml index 18a907cadc..9060f62349 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml @@ -144,6 +144,7 @@ 啟動時檢查更新 定時檢查更新 自動下載更新包 + 自動安裝更新包 穩定版 公測版 內測版 diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index 67ac2d451f..69682bba73 100644 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -1984,7 +1984,7 @@ namespace MaaWpfGui.ViewModels.UI } } - private bool _updateAutoCheck = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UpdatAutoCheck, bool.TrueString)); + private bool _updateAutoCheck = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UpdatAutoCheck, bool.FalseString)); /// /// Gets or sets a value indicating whether to check update. @@ -2043,6 +2043,21 @@ namespace MaaWpfGui.ViewModels.UI } } + private bool _autoInstallUpdatePackage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.AutoInstallUpdatePackage, bool.FalseString)); + + /// + /// Gets or sets a value indicating whether to auto install update package. + /// + public bool AutoInstallUpdatePackage + { + get => _autoInstallUpdatePackage; + set + { + SetAndNotify(ref _autoInstallUpdatePackage, value); + ConfigurationHelper.SetValue(ConfigurationKeys.AutoInstallUpdatePackage, value.ToString()); + } + } + /// /// Updates manually. /// diff --git a/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs b/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs index d0c588b126..32df3e129c 100644 --- a/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs @@ -20,6 +20,7 @@ using System.IO.Compression; using System.Linq; using System.Runtime.InteropServices; using System.Text.RegularExpressions; +using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Documents; @@ -556,6 +557,18 @@ namespace MaaWpfGui.ViewModels.UI public void AskToRestart() { + if (Instances.SettingsViewModel.AutoInstallUpdatePackage) + { + while (!(Instances.TaskQueueViewModel.Idle && Instances.CopilotViewModel.Idle)) + { + Thread.Sleep(60000); + } + + Application.Current.Shutdown(); + Bootstrapper.RestartApplication(); + return; + } + var result = MessageBoxHelper.Show( LocalizationHelper.GetString("NewVersionDownloadCompletedDesc"), LocalizationHelper.GetString("NewVersionDownloadCompletedTitle"), diff --git a/src/MaaWpfGui/Views/UserControl/VersionUpdateSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/VersionUpdateSettingsUserControl.xaml index b8572ace90..1a793c634b 100644 --- a/src/MaaWpfGui/Views/UserControl/VersionUpdateSettingsUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/VersionUpdateSettingsUserControl.xaml @@ -48,6 +48,13 @@ Content="{DynamicResource UpdateAutoDownload}" IsChecked="{Binding AutoDownloadUpdatePackage}" IsEnabled="{Binding UpdateCheck}" /> +