移动部分文件
This commit is contained in:
1 parent
0ddee422ab
commit
c95dfaf9f3
78 files changed
+102
-47
No files matched your search
@@ -0,0 +1,84 @@
|
||||
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>渲染帧率: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>默认更新仓库地址。</summary>
|
||||
public string UpdateRepository { get; set; } = "https://gitcode.com/2509_92447106/GC";
|
||||
|
||||
/// <summary>版本清单地址覆盖(留空则按 UpdateRepository 拼接)。</summary>
|
||||
public string? UpdateManifestUrl { get; set; }
|
||||
|
||||
/// <summary>本地模型源目录(离线教学场景可指向 U 盘 / 共享盘里的仓库)。</summary>
|
||||
public string? UpdateLocalRoot { get; set; }
|
||||
|
||||
/// <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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace GC.Models;
|
||||
|
||||
/// <summary>model/<id>/<id>.json 的内容。</summary>
|
||||
public sealed class ModelManifest
|
||||
{
|
||||
public int SchemaVersion { get; set; } = 1;
|
||||
public string Id { get; set; } = "";
|
||||
public string Name { get; set; } = "";
|
||||
public Dictionary<string, string>? NameI18n { get; set; }
|
||||
public string Version { get; set; } = "1.0.0";
|
||||
public string Author { get; set; } = "";
|
||||
public string Description { get; set; } = "";
|
||||
public Dictionary<string, string>? DescriptionI18n { get; set; }
|
||||
public List<string>? Tags { get; set; }
|
||||
/// <summary>相对 <id>.model 目录的入口文件,默认 scene.json</summary>
|
||||
public string? Entry { get; set; }
|
||||
/// <summary>模型自带的界面程序集(相对 <id>.model),默认 <id>.dll</summary>
|
||||
public string? Assembly { get; set; }
|
||||
/// <summary>实现 IModelFactory 的类型全名;留空则自动查找</summary>
|
||||
public string? Type { get; set; }
|
||||
/// <summary>封面图文件名,默认 preview.png</summary>
|
||||
public string? Preview { get; set; }
|
||||
/// <summary>模型契约版本</summary>
|
||||
public int ApiVersion { get; set; } = 1;
|
||||
public string? License { get; set; }
|
||||
public string? UpdatedAt { get; set; }
|
||||
public string? MinAppVersion { get; set; }
|
||||
/// <summary>模型窗口标题栏配色(模型自带,跟随模型界面风格);缺省时用深色。</summary>
|
||||
public WindowChrome? Chrome { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>模型窗口自建标题栏的颜色,由模型清单提供。</summary>
|
||||
public sealed class WindowChrome
|
||||
{
|
||||
public string? TitleBar { get; set; }
|
||||
public string? TitleBorder { get; set; }
|
||||
public string? TitleText { get; set; }
|
||||
public string? Button { get; set; }
|
||||
public string? Frame { get; set; }
|
||||
}
|
||||
|
||||
public sealed class ModelPackage
|
||||
{
|
||||
public ModelManifest Manifest { get; init; } = new();
|
||||
public string Directory { get; init; } = "";
|
||||
public long SizeBytes { get; set; }
|
||||
|
||||
public string Id => Manifest.Id;
|
||||
public string DataDirectory => System.IO.Path.Combine(Directory, Id + ".model");
|
||||
public string ScenePath
|
||||
{
|
||||
get
|
||||
{
|
||||
var entry = string.IsNullOrWhiteSpace(Manifest.Entry) ? "scene.json" : Manifest.Entry!;
|
||||
if (entry.StartsWith(Id + ".model")) return System.IO.Path.Combine(Directory, entry);
|
||||
return System.IO.Path.Combine(DataDirectory, entry);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>模型自带的界面程序集路径。</summary>
|
||||
public string AssemblyPath
|
||||
{
|
||||
get
|
||||
{
|
||||
var file = string.IsNullOrWhiteSpace(Manifest.Assembly) ? Id + ".dll" : Manifest.Assembly!;
|
||||
return System.IO.Path.IsPathRooted(file) ? file : System.IO.Path.Combine(DataDirectory, file);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>封面图路径(launcher 只显示,不渲染)。</summary>
|
||||
public string PreviewPath
|
||||
{
|
||||
get
|
||||
{
|
||||
var file = string.IsNullOrWhiteSpace(Manifest.Preview) ? "preview.png" : Manifest.Preview!;
|
||||
return System.IO.Path.IsPathRooted(file) ? file : System.IO.Path.Combine(DataDirectory, file);
|
||||
}
|
||||
}
|
||||
|
||||
public string LocalizedName => Services.L.I.Pick(Manifest.NameI18n,
|
||||
string.IsNullOrWhiteSpace(Manifest.Name) ? Id : Manifest.Name);
|
||||
|
||||
public string LocalizedDescription => Services.L.I.Pick(Manifest.DescriptionI18n, Manifest.Description);
|
||||
}
|
||||
|
||||
public sealed class RemoteModel
|
||||
{
|
||||
public ModelManifest Manifest { get; init; } = new();
|
||||
public string Directory { get; init; } = "";
|
||||
public long SizeBytes { get; init; }
|
||||
public string SourceId { get; init; } = "";
|
||||
|
||||
public string Id => Manifest.Id;
|
||||
public string LocalizedName => Services.L.I.Pick(Manifest.NameI18n,
|
||||
string.IsNullOrWhiteSpace(Manifest.Name) ? Id : Manifest.Name);
|
||||
public string LocalizedDescription => Services.L.I.Pick(Manifest.DescriptionI18n, Manifest.Description);
|
||||
}
|
||||
|
||||
public sealed class SourceIndex
|
||||
{
|
||||
public string SourceId { get; init; } = "";
|
||||
public string Root { get; init; } = "";
|
||||
public bool FromCache { get; init; }
|
||||
public List<RemoteModel> Models { get; init; } = new();
|
||||
public string? Error { get; init; }
|
||||
public string ResolvedFrom { get; init; } = "";
|
||||
}
|
||||
Reference in new issue
Block a user