- 启动:健康检查与设置并行请求,页面按需构建并 Offstage 保活,封面按展示尺寸解码 - UI:模型卡片增加悬停动效、封面渐变遮罩、版本/作者/标签胶囊,空简介占位 - 主题:设置页新增主色调选择(预设 + 自定义 #RRGGBB),前后端持久化并实时生效 - CI:新增 PR 审核流水线(后端编译/自检、Flutter 分析测试、漏洞与密钥扫描、汇总门禁) - CI:新增每晚 21:00(UTC 13:00)预发布流水线,prerelease 且不设为 Latest,先删旧再建新 - 安全:后端新增安全响应头、Host/Origin 校验、写入限流、请求体上限、ID 与设置白名单、错误信息脱敏 - 源:暂时只启用 Xhmcl;GitCode 实现保留但不再调用,旧配置自动迁移
94 lines
3.7 KiB
C#
94 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace GC.Models;
|
|
|
|
/// <summary>应用设置,持久化到 data/settings.json。</summary>
|
|
public sealed class AppSettings
|
|
{
|
|
/// <summary>auto | zh-CN | en</summary>
|
|
public string Language { get; set; } = "auto";
|
|
|
|
/// <summary>light | dark</summary>
|
|
public string Theme { get; set; } = "light";
|
|
|
|
/// <summary>主题强调色(#RRGGBB),由设置页自定义并持久化。</summary>
|
|
public string AccentColor { get; set; } = "#8FB6FF";
|
|
|
|
/// <summary>渲染帧率:24 / 30 / 60 / 90 / 120(上限 120,关闭 VSync 同步)</summary>
|
|
public int RenderFps { get; set; } = 120;
|
|
|
|
/// <summary>启动时运行内存分配(MB)——决定场景缓存/纹理预算。</summary>
|
|
public int MemoryMb { get; set; } = 2048;
|
|
|
|
/// <summary>自动模式:根据设备可用内存自动计算预算(忽略 MemoryMb)。</summary>
|
|
public bool MemoryAuto { get; set; } = true;
|
|
|
|
/// <summary>启动时检查模型源更新。</summary>
|
|
public bool CheckSourceOnStartup { get; set; }
|
|
|
|
/// <summary>模型库目录覆盖(留空则自动探测)。</summary>
|
|
public string? ModelRootOverride { get; set; }
|
|
|
|
public List<ModelSource> Sources { get; set; } = new();
|
|
|
|
public List<string> RecentModels { get; set; } = new();
|
|
|
|
// ---- 自动更新 ----------------------------------------------------------
|
|
|
|
/// <summary>启动时检查模型 / 启动器是否为最新版。</summary>
|
|
public bool AutoUpdateOnStartup { get; set; } = true;
|
|
|
|
/// <summary>默认更新仓库地址(暂时只使用 Xhmcl,GitCode 实现保留但不再调用)。</summary>
|
|
public string UpdateRepository { get; set; } = "https://git.xhmcl.com/Morris/GC";
|
|
|
|
/// <summary>版本清单地址覆盖(留空则按 UpdateRepository 拼接)。</summary>
|
|
public string? UpdateManifestUrl { get; set; }
|
|
|
|
/// <summary>本地模型源目录(离线教学场景可指向 U 盘 / 共享盘里的仓库)。</summary>
|
|
public string? UpdateLocalRoot { get; set; }
|
|
|
|
/// <summary>
|
|
/// 要求版本清单必须带**有效签名**。默认开启:关闭后只警告不拦截,
|
|
/// 等于放弃「清单被篡改」的防护,只建议在自建私有构建里临时关闭。
|
|
/// </summary>
|
|
public bool RequireSignedManifest { get; set; } = true;
|
|
|
|
/// <summary>已安装的模型版本:id -> version.json 里的版本。</summary>
|
|
public Dictionary<string, string> InstalledModelVersions { get; set; } = new();
|
|
|
|
/// <summary>当前已经应用过的启动器版本。</summary>
|
|
public string? LauncherVersion { get; set; }
|
|
|
|
/// <summary>已下载、等待下次启动应用的启动器版本。</summary>
|
|
public string? PendingLauncherVersion { get; set; }
|
|
|
|
/// <summary>最近一次更新检查时间(ISO 8601)。</summary>
|
|
public string? LastUpdateCheck { get; set; }
|
|
}
|
|
|
|
/// <summary>模型源:一个满足 Earth Model 规范的 git 仓库 / zip / 本地目录。</summary>
|
|
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;
|
|
}
|
|
}
|
|
}
|