diff --git a/src/MaaWpfGui/Constants/ConfigurationKeys.cs b/src/MaaWpfGui/Constants/ConfigurationKeys.cs index 9b95d39299..5f04258717 100644 --- a/src/MaaWpfGui/Constants/ConfigurationKeys.cs +++ b/src/MaaWpfGui/Constants/ConfigurationKeys.cs @@ -241,6 +241,7 @@ namespace MaaWpfGui.Constants public const string VersionUpdateBody = "VersionUpdate.body"; public const string VersionUpdateIsFirstBoot = "VersionUpdate.isfirstboot"; public const string VersionUpdatePackage = "VersionUpdate.package"; + public const string VersionUpdateDoNotShowUpdate = "VersionUpdate.doNotShowUpdate"; public const string OperBoxData = "OperBox.Data"; @@ -254,5 +255,6 @@ namespace MaaWpfGui.Constants public const string AnnouncementInfo = "Announcement.AnnouncementInfo"; public const string DoNotRemindThisAnnouncementAgain = "Announcement.DoNotRemindThisAnnouncementAgain"; + public const string DoNotShowAnnouncement = "Announcement.DoNotShowAnnouncement"; } } diff --git a/src/MaaWpfGui/ViewModels/UI/AnnouncementViewModel.cs b/src/MaaWpfGui/ViewModels/UI/AnnouncementViewModel.cs index b041b6cf44..eeeb6ee553 100644 --- a/src/MaaWpfGui/ViewModels/UI/AnnouncementViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/AnnouncementViewModel.cs @@ -54,6 +54,21 @@ namespace MaaWpfGui.ViewModels.UI } } + private bool _doNotShowAnnouncement = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.DoNotShowAnnouncement, bool.FalseString)); + + /// + /// Gets or sets a value indicating whether to show the update. + /// + public bool DoNotShowAnnouncement + { + get => _doNotShowAnnouncement; + set + { + SetAndNotify(ref _doNotShowAnnouncement, value); + ConfigurationHelper.SetValue(ConfigurationKeys.DoNotShowAnnouncement, value.ToString()); + } + } + /// /// 检查更新 /// diff --git a/src/MaaWpfGui/ViewModels/UI/RootViewModel.cs b/src/MaaWpfGui/ViewModels/UI/RootViewModel.cs index 8ea506e954..809c827388 100644 --- a/src/MaaWpfGui/ViewModels/UI/RootViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/RootViewModel.cs @@ -47,6 +47,11 @@ namespace MaaWpfGui.ViewModels.UI return; } + if (Instances.AnnouncementViewModel.DoNotShowAnnouncement) + { + return; + } + _ = Execute.OnUIThreadAsync(() => Instances.WindowManager.ShowWindow(Instances.AnnouncementViewModel)); }); Instances.VersionUpdateViewModel.ShowUpdateOrDownload(); diff --git a/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs b/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs index d79143f0f8..0f28fff093 100644 --- a/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs @@ -404,6 +404,21 @@ namespace MaaWpfGui.ViewModels.UI Native, } + private bool _doNotShowUpdate = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.VersionUpdateDoNotShowUpdate, bool.FalseString)); + + /// + /// Gets or sets a value indicating whether to show the update. + /// + public bool DoNotShowUpdate + { + get => _doNotShowUpdate; + set + { + SetAndNotify(ref _doNotShowUpdate, value); + ConfigurationHelper.SetValue(ConfigurationKeys.VersionUpdateDoNotShowUpdate, value.ToString()); + } + } + /// /// 如果是在更新后第一次启动,显示ReleaseNote弹窗,否则检查更新并下载更新包。 /// @@ -412,7 +427,10 @@ namespace MaaWpfGui.ViewModels.UI if (IsFirstBootAfterUpdate) { IsFirstBootAfterUpdate = false; - Instances.WindowManager.ShowWindow(this); + if (!DoNotShowUpdate) + { + Instances.WindowManager.ShowWindow(this); + } } else {