Skip to content

Commit

Permalink
upgrade prompt to add options that will no longer be prompted
Browse files Browse the repository at this point in the history
  • Loading branch information
huiyadanli committed Nov 25, 2023
1 parent 775619b commit 4a255ac
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
5 changes: 5 additions & 0 deletions BetterGenshinImpact/Core/Config/AllConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public partial class AllConfig : ObservableObject
/// </summary>
[ObservableProperty] private int _triggerInterval = 50;

/// <summary>
/// 不展示新版本提示的最新版本
/// </summary>
[ObservableProperty] private string _notShowNewVersionNoticeEndVersion = "";

/// <summary>
/// 遮罩窗口配置
/// </summary>
Expand Down
13 changes: 9 additions & 4 deletions BetterGenshinImpact/Core/Config/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
15 changes: 14 additions & 1 deletion BetterGenshinImpact/ViewModel/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MainWindowViewModel>();
}

Expand Down Expand Up @@ -69,13 +72,20 @@ 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
{
Title = "更新提示",
Content = $"存在最新版本 {notice.Version},点击确定前往下载页面下载最新版本",
PrimaryButtonText = "确定",
SecondaryButtonText = "不再提示",
CloseButtonText = "取消",
};

Expand All @@ -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;
}
});
}
}
Expand All @@ -97,6 +111,5 @@ private void OnClosed()
Debug.WriteLine("MainWindowViewModel Closed");
Application.Current.Shutdown();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4a255ac

Please sign in to comment.