changed.对启动器重构的尝试

This commit is contained in:
lincube
2026-05-28 15:14:37 +08:00
parent 1ef47c780b
commit 313d093257
51 changed files with 4509 additions and 2478 deletions

View File

@@ -0,0 +1,49 @@
using System.Text.Json;
using LanMountainDesktop.Launcher.Models;
namespace LanMountainDesktop.Launcher.Update;
internal sealed class InstallCheckpointStore(UpdateEnginePaths paths)
{
public InstallCheckpoint? Load()
{
if (!File.Exists(paths.InstallCheckpointPath))
{
return null;
}
try
{
var text = File.ReadAllText(paths.InstallCheckpointPath);
if (string.IsNullOrWhiteSpace(text))
{
return null;
}
return JsonSerializer.Deserialize(text, AppJsonContext.Default.InstallCheckpoint);
}
catch
{
return null;
}
}
public void Save(InstallCheckpoint checkpoint)
{
File.WriteAllText(paths.InstallCheckpointPath, JsonSerializer.Serialize(checkpoint, AppJsonContext.Default.InstallCheckpoint));
}
public void Delete()
{
try
{
if (File.Exists(paths.InstallCheckpointPath))
{
File.Delete(paths.InstallCheckpointPath);
}
}
catch
{
}
}
}