Files
Morris ecb71ad347
PR 审核 / 后端编译 (pull_request) Waiting to run
PR 审核 / 前端检查(Flutter) (pull_request) Waiting to run
PR 审核 / 安全扫描 (pull_request) Waiting to run
feat(user): 用户系统重做——人机验证、30 天签到、主题色购买与退款、人品值
存储
- 目录改为 .GC/user/<用户名>/pw.yaml(用户名、积分、sha512 口令 + 盐)
- .GC/user/user.yaml 记住当前登录(用户名 + session token),启动自动登录
- 自动迁移旧的 .GC/user/<用户名>.yaml

注册 / 登录
- 新增算术人机验证:GET /api/user/captcha(5 分钟有效、一次性、用后即焚)
- 用户名不可重复、不能含空格、1–20 字符
- 口令只存 sha512(密码 + ":" + 随机盐),不存明文
- 新增 /api/user/logout

签到
- 30 天一循环:1–6 天 +10,第 7 天 +30,8–13 +15,第 14 天 +40,
  15–20 +20,第 21 天 +50,22–27 +25,第 28 天 +60,29 天 +40,第 30 天 +100
- 断签重置连续天数;接口返回 cycle_day / next_reward / today_signed

主题色
- 默认蓝免费,预置色 50,自定义色 150(服务端算价,不信客户端)
- 购买后 1 小时内换色退 80%,record 里存 theme_paid / theme_paid_at
- 禁止充值:积分只能签到获得

前端用户页
- 账号卡片:积分、连续天数、周期进度条、一键签到、退出登录
- 注册表单内嵌验证码(换一题、失败自动刷新)
- 人品值:0–100 随机 + 评语,每天不限次数
- 二选一:两个输入框随机选一个
- 主题色:8 个预置色 + 自定义色取色(十六进制 + 预览),积分不足上锁
- 应用主题色时同步覆盖全局强调色
2026-11-21 20:26:02 +08:00

175 lines
4.5 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections.Generic;
namespace GC.UI.Server;
// ---------------------------------------------------------------------------
// 前后端之间的数据契约(HTTP + JSON,camelCase)。
// 前端(Flutter)只认这些字段,不认 .NET 类型;后端换实现不影响前端。
// ---------------------------------------------------------------------------
public sealed record HealthDto(
bool Ok,
string Version,
string Platform,
bool UiAvailable,
string? UiError,
string? SessionProof = null);
public sealed record ModelDto(
string Id,
string Name,
string Description,
string Version,
string Author,
long SizeBytes,
string SizeText,
IReadOnlyList<string> Tags,
bool HasPreview,
string PreviewUrl,
string Directory,
string DataDirectory);
public sealed record SourceDto(
string Id,
string Name,
string Url,
bool Enabled,
bool BuiltIn,
string Host);
public sealed record RemoteModelDto(
string Id,
string Name,
string Description,
string Version,
long SizeBytes,
string SizeText,
string SourceId,
bool Installed,
string? InstalledVersion);
public sealed record SourceIndexDto(
string SourceId,
string Root,
bool FromCache,
string? Error,
string ResolvedFrom,
IReadOnlyList<RemoteModelDto> Models);
public sealed record JobDto(
string Id,
string ModelId,
string Name,
string Version,
string State,
double Progress,
string StatusText,
string DetailText,
string? Error,
bool IsActive,
bool CanRetry,
bool IsDone);
public sealed record LanguageDto(string Code, string Label);
public sealed record SettingsDto(
string Language,
string Theme,
string AccentColor,
int RenderFps,
int MemoryMb,
bool MemoryAuto,
bool AutoUpdateOnStartup,
bool RequireSignedManifest,
string UpdateRepository,
string? UpdateLocalRoot,
string? ModelRootOverride,
int MemoryBudgetMb,
string MemoryUsageText,
string ModelRoot,
string DataRoot,
string SettingsFile,
string Version,
string Platform,
IReadOnlyList<SourceDto> Sources,
IReadOnlyList<LanguageDto> Languages);
/// <summary>设置补丁:只改传进来的字段,null 表示不动。</summary>
public sealed record SettingsPatch(
string? Language,
string? Theme,
string? AccentColor,
int? RenderFps,
int? MemoryMb,
bool? MemoryAuto,
bool? AutoUpdateOnStartup,
bool? RequireSignedManifest,
string? UpdateRepository,
string? UpdateLocalRoot,
string? ModelRootOverride);
public sealed record LatencyDto(string Id, string Name, long Milliseconds);
public sealed record UpdateCheckDto(
string Outcome,
string Message,
int UpdatedModels,
IReadOnlyList<string> ModelNames,
string? LauncherMessage,
string? Error,
string? LauncherLatest,
string SourceName,
IReadOnlyList<LatencyDto> Latency);
public sealed record ContributorDto(string Name, int Contributions, string? AvatarUrl);
// ---- 用户 API DTO ----
public sealed record RegisterRequest(
string Username,
string Password,
string? CaptchaId = null,
string? Captcha = null);
public sealed record LoginRequest(string Username, string Password);
/// <summary>换主题色:只传颜色,价格由服务端按预置/自定义判定。</summary>
public sealed record ThemeRequest(string Color, int? Cost = null);
public sealed record CaptchaDto(string Id, string Question);
/// <summary>「重新下载启动器」结果:State = Ready / UpToDate / Failed。</summary>
public sealed record LauncherRedownloadDto(
string State,
string Version,
string Message,
IReadOnlyList<string> Steps);
public sealed record AboutDto(
string AppName,
string Version,
string Platform,
string Repository,
IReadOnlyList<ContributorDto> Contributors,
string SourceLanguage,
string Frontend);
public sealed record LaunchResultDto(bool Ok, string Message);
/// <summary>
/// 通用错误响应。限流 / 参数校验这类与具体业务无关的失败用它,
/// 不要复用 <see cref="LaunchResultDto"/> —— 那会让前端误以为「启动模型」有结果。
/// </summary>
public sealed record ErrorDto(bool Ok, string Message)
{
public static ErrorDto Of(string message) => new(false, message);
}
public sealed record DownloadRequest(string SourceId, string ModelId);
public sealed record PathRequest(string Path);
public sealed record UrlRequest(string Url);
public sealed record ForceRequest(bool Force);