UI 体验与启动优化 · 主题色 · Gitea CI/夜间预发布 · 后端安全加固

- 启动:健康检查与设置并行请求,页面按需构建并 Offstage 保活,封面按展示尺寸解码
- UI:模型卡片增加悬停动效、封面渐变遮罩、版本/作者/标签胶囊,空简介占位
- 主题:设置页新增主色调选择(预设 + 自定义 #RRGGBB),前后端持久化并实时生效
- CI:新增 PR 审核流水线(后端编译/自检、Flutter 分析测试、漏洞与密钥扫描、汇总门禁)
- CI:新增每晚 21:00(UTC 13:00)预发布流水线,prerelease 且不设为 Latest,先删旧再建新
- 安全:后端新增安全响应头、Host/Origin 校验、写入限流、请求体上限、ID 与设置白名单、错误信息脱敏
- 源:暂时只启用 Xhmcl;GitCode 实现保留但不再调用,旧配置自动迁移
This commit is contained in:
Morris committed 2026-11-17 23:50:54 +08:00
1 parent 3480cbaa5f
commit ae73eca2c4
15 files changed
+1007 -153

No files matched your search

+77 -10
View File
@@ -1,5 +1,58 @@
import 'package:flutter/material.dart';
/// 主题强调色(可在设置页自定义,并持久化到后端 settings.accentColor)。
///
/// 用 [ValueNotifier] 持有当前颜色:设置页改色后,`main.dart` 监听到变化
/// 会重建 `MaterialApp.theme`,所有引用 [GcColors.accent] 的组件随之换色。
class GcPalette {
GcPalette._();
/// 默认强调色,与 Avalonia 启动器一致。
static const Color defaultAccent = Color(0xFF8FB6FF);
static final ValueNotifier<Color> accent =
ValueNotifier<Color>(defaultAccent);
/// 设置页可选的预设色板。
static const List<Color> presets = <Color>[
Color(0xFF8FB6FF), // 极光蓝(默认)
Color(0xFF7C6CFF), // 星云紫
Color(0xFF4FD1C5), // 湖水青
Color(0xFF6BE3A2), // 极光绿
Color(0xFFFFC46B), // 暖阳橙
Color(0xFFFF8FB1), // 樱粉
Color(0xFFFF7A7A), // 珊瑚红
Color(0xFFB0BEC5), // 石墨灰
];
/// 把 `#RRGGBB` / `RRGGBB` 解析为颜色;非法返回 null。
static Color? parseHex(String? value) {
if (value == null) return null;
var hex = value.trim();
if (hex.startsWith('#')) hex = hex.substring(1);
if (hex.length == 8) hex = hex.substring(2); // 忽略 alpha
if (hex.length != 6) return null;
final parsed = int.tryParse(hex, radix: 16);
if (parsed == null) return null;
return Color(0xFF000000 | parsed);
}
/// 颜色转 `#RRGGBB`。
static String toHex(Color color) {
// ignore: deprecated_member_use
final rgb = color.value & 0xFFFFFF;
return '#${rgb.toRadixString(16).padLeft(6, '0').toUpperCase()}';
}
/// 应用颜色(来自后端设置或用户点选)。
static void apply(String? hex) {
final color = parseHex(hex);
if (color == null) return;
// ignore: deprecated_member_use
if (accent.value.value != color.value) accent.value = color;
}
}
/// 与 Avalonia 启动器一致的深色配色。
class GcColors {
GcColors._();
@@ -9,23 +62,37 @@ class GcColors {
static const Color surface = Color(0xFF111C33);
static const Color surfaceAlt = Color(0xFF16233C);
static const Color line = Color(0xFF1B2740);
static const Color accent = Color(0xFF8FB6FF);
static const Color accentStrong = Color(0xFF4C7DFF);
static const Color ink = Color(0xFFF2F6FF);
static const Color muted = Color(0xFFA9B8D4);
static const Color faint = Color(0xFF7C90B4);
static const Color warn = Color(0xFFFFC46B);
static const Color danger = Color(0xFFFF7A7A);
static const Color ok = Color(0xFF6BE3A2);
/// 当前强调色(动态,跟随设置)。
static Color get accent => GcPalette.accent.value;
/// 强调色的加深版本,用于主按钮 / 轨道。
static Color get accentStrong => _strongen(accent);
static Color _strongen(Color color) {
final hsl = HSLColor.fromColor(color);
return hsl
.withSaturation((hsl.saturation + 0.12).clamp(0.0, 1.0))
.withLightness((hsl.lightness - 0.10).clamp(0.0, 1.0))
.toColor();
}
}
ThemeData buildGcTheme() {
final base = ThemeData.dark(useMaterial3: true);
final accent = GcColors.accent;
final accentStrong = GcColors.accentStrong;
return base.copyWith(
scaffoldBackgroundColor: GcColors.appBg,
colorScheme: base.colorScheme.copyWith(
primary: GcColors.accentStrong,
secondary: GcColors.accent,
primary: accentStrong,
secondary: accent,
surface: GcColors.surface,
error: GcColors.danger,
),
@@ -40,24 +107,24 @@ ThemeData buildGcTheme() {
margin: EdgeInsets.zero,
),
sliderTheme: base.sliderTheme.copyWith(
activeTrackColor: GcColors.accentStrong,
thumbColor: GcColors.accent,
activeTrackColor: accentStrong,
thumbColor: accent,
inactiveTrackColor: GcColors.line,
),
switchTheme: SwitchThemeData(
thumbColor: WidgetStateProperty.resolveWith(
(states) => states.contains(WidgetState.selected)
? GcColors.accent
? accent
: GcColors.faint,
),
trackColor: WidgetStateProperty.resolveWith(
(states) => states.contains(WidgetState.selected)
? GcColors.accentStrong.withOpacity(0.45)
? accentStrong.withOpacity(0.45)
: GcColors.line,
),
),
progressIndicatorTheme: const ProgressIndicatorThemeData(
color: GcColors.accent,
progressIndicatorTheme: ProgressIndicatorThemeData(
color: accent,
linearTrackColor: GcColors.line,
),
tooltipTheme: const TooltipThemeData(