using System; using System.Collections.Generic; using System.Text.Json.Serialization; namespace GC.Models; /// 应用设置,持久化到 data/settings.json。 public sealed class AppSettings { /// auto | zh-CN | en public string Language { get; set; } = "auto"; /// light | dark public string Theme { get; set; } = "light"; /// 渲染帧率:24 / 30 / 60 / 90 / 120(上限 120,关闭 VSync 同步) public int RenderFps { get; set; } = 120; /// 启动时运行内存分配(MB)——决定场景缓存/纹理预算。 public int MemoryMb { get; set; } = 2048; /// 自动模式:根据设备可用内存自动计算预算(忽略 MemoryMb)。 public bool MemoryAuto { get; set; } = true; /// 启动时检查模型源更新。 public bool CheckSourceOnStartup { get; set; } /// 模型库目录覆盖(留空则自动探测)。 public string? ModelRootOverride { get; set; } public List Sources { get; set; } = new(); public List RecentModels { get; set; } = new(); // ---- 自动更新 ---------------------------------------------------------- /// 启动时检查模型 / 启动器是否为最新版。 public bool AutoUpdateOnStartup { get; set; } = true; /// 默认更新仓库地址。 public string UpdateRepository { get; set; } = "https://gitcode.com/2509_92447106/GC"; /// 版本清单地址覆盖(留空则按 UpdateRepository 拼接)。 public string? UpdateManifestUrl { get; set; } /// 本地模型源目录(离线教学场景可指向 U 盘 / 共享盘里的仓库)。 public string? UpdateLocalRoot { get; set; } /// 已安装的模型版本:id -> version.json 里的版本。 public Dictionary InstalledModelVersions { get; set; } = new(); /// 当前已经应用过的启动器版本。 public string? LauncherVersion { get; set; } /// 已下载、等待下次启动应用的启动器版本。 public string? PendingLauncherVersion { get; set; } /// 最近一次更新检查时间(ISO 8601)。 public string? LastUpdateCheck { get; set; } } /// 模型源:一个满足 Earth Model 规范的 git 仓库 / zip / 本地目录。 public sealed class ModelSource { public string Id { get; set; } = Guid.NewGuid().ToString("N")[..8]; public string Name { get; set; } = ""; public string Url { get; set; } = ""; public string? Branch { get; set; } public bool Enabled { get; set; } = true; public bool BuiltIn { get; set; } public string? LastSynced { get; set; } [JsonIgnore] public string DisplayHost { get { if (string.IsNullOrWhiteSpace(Url)) return ""; if (Url.StartsWith("file:", StringComparison.OrdinalIgnoreCase) || System.IO.Path.IsPathRooted(Url)) return "local"; return Uri.TryCreate(Url, UriKind.Absolute, out var u) ? u.Host : Url; } } }