mirror of
https://github.com/waynebian01/Shigure.git
synced 2026-09-03 07:15:24 +08:00
feat: 添加启动提示功能,显示版本更新信息并缓存上次显示版本
This commit is contained in:
@@ -35,6 +35,8 @@ internal static class Program
|
||||
|
||||
try
|
||||
{
|
||||
StartupNotice.ShowIfNeeded();
|
||||
|
||||
var options = AppOptions.FromArgs(args);
|
||||
var baseDirectory = AppPaths.BaseDirectory;
|
||||
var moduleStore = new ModuleStore(ModuleStore.ResolveModuleDirectory());
|
||||
|
||||
57
Infrastructure/StartupNotice.cs
Normal file
57
Infrastructure/StartupNotice.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
namespace Shigure;
|
||||
|
||||
internal static class StartupNotice
|
||||
{
|
||||
// 在这里填写首次打开或版本升级时展示的信息文本。
|
||||
private const string NoticeText = """
|
||||
1.2.1.10
|
||||
- 重要: 修改了施法时间和引导时间的比例, 1秒 = 10, 所有打断都需要修改。
|
||||
- 施法修改为:施法(倒计时), 添加了:施法(正计时)。
|
||||
- 可以监控boss的一些信息。
|
||||
- 优化了UI界面。
|
||||
|
||||
""";
|
||||
|
||||
public static void ShowIfNeeded()
|
||||
{
|
||||
try
|
||||
{
|
||||
var cache = UiCacheStore.Load();
|
||||
var currentVersion = AppInfo.Version;
|
||||
if (!ShouldShow(cache.LastShownVersion, currentVersion))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBox.Show(
|
||||
NoticeText,
|
||||
$"{AppInfo.AppName} v{currentVersion}",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
|
||||
cache.LastShownVersion = currentVersion;
|
||||
UiCacheStore.Save(cache);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 提示或缓存异常时静默跳过,避免影响应用启动。
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ShouldShow(string? cachedVersion, string currentVersion)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(cachedVersion))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (System.Version.TryParse(currentVersion, out var current)
|
||||
&& System.Version.TryParse(cachedVersion, out var cached))
|
||||
{
|
||||
return cached < current;
|
||||
}
|
||||
|
||||
// 缓存损坏或版本格式发生变化时,仅在文本不一致时重新提示一次。
|
||||
return !string.Equals(cachedVersion, currentVersion, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
@@ -99,6 +99,7 @@ internal static class UiCacheStore
|
||||
|
||||
internal sealed class UiCacheState
|
||||
{
|
||||
public string? LastShownVersion { get; set; }
|
||||
public WindowLocation? MainWindowLocation { get; set; }
|
||||
public WindowBounds? MainWindowBounds { get; set; }
|
||||
public WindowBounds? HorizontalMainWindowBounds { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user