feat: 添加启动提示功能,显示版本更新信息并缓存上次显示版本

This commit is contained in:
waynebian01
2026-08-25 00:45:55 +08:00
parent 86ba7238d9
commit b549a56edd
3 changed files with 60 additions and 0 deletions

View File

@@ -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());

View 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);
}
}

View File

@@ -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; }