feat: 全面迁移到 Flutter + 新增 GitHub 源与 CI 流水线
前端
- 移除全部 Avalonia 依赖,模型渲染与界面统一改用 Flutter
- 新增用户页:登录/注册(SHA-512 + 盐)、签到积分(30 天一循环)、
主题色积分购买、二选一随机、今日人品
- 新增百宝箱页、模型内嵌渲染页、自绘标题栏(最小化/最大化/关闭)
- 下载页显示模型下载进度条,下载源读取加速
- 关于页新增「重新下载启动器」并在下载后做 sha256 完整性校验
- 修复浅色主题下标题栏不跟随主题色、无法连接后端等问题
后端
- 新增 UserService:.GC/user/<用户名>.yaml 存用户名/积分/SHA-512 口令,
登录返回 session token,本地 .GC/user/user.yaml 保存登录态
- 新增 /api/user/{register,login,me,signin,theme} 接口
- 去掉 Avalonia 窗口宿主,后端只提供 HTTP API
下载源
- 新增 GitHub 镜像源(Morris-morris-cloud/GC),与 Xhmcl 并发测速
- 单源探测超时收紧到 2 秒,取最快且可用的源;GitHub 复用 GiteaRemote
(contents 带 ref、releases 带 per_page=100)
构建与 CI
- macOS 上默认只出 macOS 包,Windows 交给原生 Windows 构建
- 修复 Windows 交叉编译中 flutter-cpp-client-wrapper 双层目录嵌套
- 新增 GitHub Actions:
· nightly-prerelease:每天 21:00 编译三平台,发布 nightly 预发布
· build-bot:Issue/PR 评论 @build-bot build <mac|win-amd|win-arm|all>,
发布 ip-prerelease 预发布
· pr-review:检查能否编译、静态分析、合并冲突、是否落后 main
- 忽略 79MB 课件产物等高线.html 与工具链临时备份
This commit is contained in:
1 parent
b9cb56cb8b
commit
ea1fa6b6d1
134 files changed
+4309
-16614
No files matched your search
@@ -0,0 +1,164 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'theme.dart';
|
||||
|
||||
/// 自绘窗口按钮的通道(macOS 侧在 macos/Runner/MainFlutterWindow.swift 实现)。
|
||||
///
|
||||
/// 系统标题栏已去掉(titleVisibility = .hidden + fullSizeContentView),
|
||||
/// 最小化 / 最大化 / 关闭 全部由 Flutter 画,外观跟界面统一。
|
||||
class GcWindow {
|
||||
GcWindow._();
|
||||
|
||||
static const MethodChannel _channel = MethodChannel('gc/window');
|
||||
|
||||
/// 只有 macOS 走了自绘标题栏;其它平台保留系统标题栏,不显示自绘按钮。
|
||||
static bool get supported => !kIsWeb && Platform.isMacOS;
|
||||
|
||||
static Future<void> minimize() => _invoke('minimize');
|
||||
static Future<void> close() => _invoke('close');
|
||||
static Future<void> toggleMaximize() => _invoke('toggleMaximize');
|
||||
|
||||
/// 开始拖拽窗口。用原生 performDrag,比在 Flutter 里模拟位置更跟手。
|
||||
static Future<void> beginDrag() => _invoke('beginDrag');
|
||||
|
||||
static Future<bool> isMaximized() async {
|
||||
if (!supported) return false;
|
||||
try {
|
||||
return await _channel.invokeMethod<bool>('isMaximized') ?? false;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> _invoke(String method) async {
|
||||
if (!supported) return;
|
||||
try {
|
||||
await _channel.invokeMethod<void>(method);
|
||||
} catch (_) {
|
||||
// 通道不可用(例如截图测试环境)时静默忽略
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 顶部标题栏:左侧应用名 + 右侧自绘的最小化 / 最大化 / 关闭。
|
||||
///
|
||||
/// 只在 macOS 显示;其它平台系统标题栏还在,这里返回零高度占位。
|
||||
class GcTitleBar extends StatelessWidget {
|
||||
const GcTitleBar({super.key, this.title = 'Morris GC'});
|
||||
|
||||
final String title;
|
||||
|
||||
static const double height = 38;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!GcWindow.supported) return const SizedBox.shrink();
|
||||
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onPanStart: (_) => GcWindow.beginDrag(),
|
||||
child: Container(
|
||||
height: height,
|
||||
// 与主题底色保持一致:浅色主题是纯白,深色主题是深色面板色。
|
||||
// 不叠强调色 —— 标题栏属于窗口底色,染色会显得和内容区不是一套。
|
||||
decoration: BoxDecoration(
|
||||
color: GcColors.sideBg,
|
||||
border: Border(bottom: BorderSide(color: GcColors.line)),
|
||||
),
|
||||
padding: const EdgeInsets.only(left: GcSpace.xl, right: GcSpace.sm),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 12.5,
|
||||
height: 1.2,
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: 0.2,
|
||||
color: GcColors.faint,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
_WindowButton(
|
||||
icon: Icons.remove_rounded,
|
||||
tooltip: '最小化',
|
||||
onTap: GcWindow.minimize,
|
||||
),
|
||||
_WindowButton(
|
||||
icon: Icons.crop_square_rounded,
|
||||
tooltip: '最大化',
|
||||
onTap: GcWindow.toggleMaximize,
|
||||
),
|
||||
_WindowButton(
|
||||
icon: Icons.close_rounded,
|
||||
tooltip: '关闭',
|
||||
danger: true,
|
||||
onTap: GcWindow.close,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _WindowButton extends StatefulWidget {
|
||||
const _WindowButton({
|
||||
required this.icon,
|
||||
required this.tooltip,
|
||||
required this.onTap,
|
||||
this.danger = false,
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final String tooltip;
|
||||
final Future<void> Function() onTap;
|
||||
final bool danger;
|
||||
|
||||
@override
|
||||
State<_WindowButton> createState() => _WindowButtonState();
|
||||
}
|
||||
|
||||
class _WindowButtonState extends State<_WindowButton> {
|
||||
bool _hover = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Color bg = _hover
|
||||
? (widget.danger
|
||||
? GcColors.danger.withOpacity(0.16)
|
||||
: GcColors.surfaceHover)
|
||||
: Colors.transparent;
|
||||
|
||||
return Tooltip(
|
||||
message: widget.tooltip,
|
||||
waitDuration: const Duration(milliseconds: 500),
|
||||
child: MouseRegion(
|
||||
cursor: SystemMouseCursors.basic,
|
||||
onEnter: (_) => setState(() => _hover = true),
|
||||
onExit: (_) => setState(() => _hover = false),
|
||||
child: GestureDetector(
|
||||
onTap: () => widget.onTap(),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 110),
|
||||
width: 40,
|
||||
height: GcTitleBar.height,
|
||||
alignment: Alignment.center,
|
||||
color: bg,
|
||||
child: Icon(
|
||||
widget.icon,
|
||||
size: 15,
|
||||
color: _hover
|
||||
? (widget.danger ? GcColors.danger : GcColors.ink)
|
||||
: GcColors.faint,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user