From 4a255ac1bd921cfd67ee762ba3f839d135383d8a Mon Sep 17 00:00:00 2001 From: huiyadanli Date: Sat, 25 Nov 2023 23:47:39 +0800 Subject: [PATCH] upgrade prompt to add options that will no longer be prompted --- BetterGenshinImpact/Core/Config/AllConfig.cs | 5 +++++ BetterGenshinImpact/Core/Config/Global.cs | 13 +++++++++---- .../ViewModel/MainWindowViewModel.cs | 15 ++++++++++++++- .../ViewModel/Pages/TaskSettingsPageViewModel.cs | 2 +- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/BetterGenshinImpact/Core/Config/AllConfig.cs b/BetterGenshinImpact/Core/Config/AllConfig.cs index 0a1fee99..2e179c0a 100644 --- a/BetterGenshinImpact/Core/Config/AllConfig.cs +++ b/BetterGenshinImpact/Core/Config/AllConfig.cs @@ -33,6 +33,11 @@ public partial class AllConfig : ObservableObject /// [ObservableProperty] private int _triggerInterval = 50; + /// + /// 不展示新版本提示的最新版本 + /// + [ObservableProperty] private string _notShowNewVersionNoticeEndVersion = ""; + /// /// 遮罩窗口配置 /// diff --git a/BetterGenshinImpact/Core/Config/Global.cs b/BetterGenshinImpact/Core/Config/Global.cs index 54cc98d0..c419893c 100644 --- a/BetterGenshinImpact/Core/Config/Global.cs +++ b/BetterGenshinImpact/Core/Config/Global.cs @@ -5,7 +5,7 @@ namespace BetterGenshinImpact.Core.Config; public class Global { - public static string Version = "0.16.0"; + public static string Version = "0.13.0"; public static string StartUpPath { get; private set; } = AppContext.BaseDirectory; @@ -26,10 +26,15 @@ public static string Absolute(string relativePath) return null; } - public static bool IsNewVersion(string version) + public static bool IsNewVersion(string currentVersion) { - var currentVersionArr =Version.Split('.'); - var newVersionArr = version.Split('.'); + return IsNewVersion(Version, currentVersion); + } + + public static bool IsNewVersion(string oldVersion, string currentVersion) + { + var currentVersionArr = oldVersion.Split('.'); + var newVersionArr = currentVersion.Split('.'); if (currentVersionArr.Length != newVersionArr.Length) { return false; diff --git a/BetterGenshinImpact/ViewModel/MainWindowViewModel.cs b/BetterGenshinImpact/ViewModel/MainWindowViewModel.cs index 44edb39b..1529a9af 100644 --- a/BetterGenshinImpact/ViewModel/MainWindowViewModel.cs +++ b/BetterGenshinImpact/ViewModel/MainWindowViewModel.cs @@ -25,9 +25,12 @@ public partial class MainWindowViewModel : ObservableObject private readonly IConfigService _configService; public string Title => $"BetterGI · 更好的原神 · {Global.Version}"; + public AllConfig Config { get; set; } + public MainWindowViewModel(INavigationService navigationService, IConfigService configService) { _configService = configService; + Config = configService.Get(); _logger = App.GetLogger(); } @@ -69,6 +72,12 @@ private async void GetNewestInfo() { if (Global.IsNewVersion(notice.Version)) { + if (!string.IsNullOrEmpty(Config.NotShowNewVersionNoticeEndVersion) + && !Global.IsNewVersion(Config.NotShowNewVersionNoticeEndVersion, notice.Version)) + { + return; + } + await UIDispatcherHelper.Invoke(async () => { var uiMessageBox = new Wpf.Ui.Controls.MessageBox @@ -76,6 +85,7 @@ await UIDispatcherHelper.Invoke(async () => Title = "更新提示", Content = $"存在最新版本 {notice.Version},点击确定前往下载页面下载最新版本", PrimaryButtonText = "确定", + SecondaryButtonText = "不再提示", CloseButtonText = "取消", }; @@ -84,6 +94,10 @@ await UIDispatcherHelper.Invoke(async () => { Process.Start(new ProcessStartInfo("https://bgi.huiyadan.com/download.html") { UseShellExecute = true }); } + else if (result == Wpf.Ui.Controls.MessageBoxResult.Secondary) + { + Config.NotShowNewVersionNoticeEndVersion = notice.Version; + } }); } } @@ -97,6 +111,5 @@ private void OnClosed() Debug.WriteLine("MainWindowViewModel Closed"); Application.Current.Shutdown(); } - } } \ No newline at end of file diff --git a/BetterGenshinImpact/ViewModel/Pages/TaskSettingsPageViewModel.cs b/BetterGenshinImpact/ViewModel/Pages/TaskSettingsPageViewModel.cs index 31714041..b0cc6f68 100644 --- a/BetterGenshinImpact/ViewModel/Pages/TaskSettingsPageViewModel.cs +++ b/BetterGenshinImpact/ViewModel/Pages/TaskSettingsPageViewModel.cs @@ -150,7 +150,7 @@ public void OnSwitchAutoWood() [RelayCommand] public void OnGoToAutoWoodUrl() { - Process.Start(new ProcessStartInfo("https://bgi.huiyadan.com/doc.html#%E8%87%AA%E5%8A%A8%E4%B8%83%E5%9C%A3%E5%8F%AC%E5%94%A4") { UseShellExecute = true }); + Process.Start(new ProcessStartInfo("https://bgi.huiyadan.com/doc.html#%E8%87%AA%E5%8A%A8%E4%BC%90%E6%9C%A8") { UseShellExecute = true }); } public static void SetSwitchAutoGeniusInvokationButtonText(bool running)