GC-UI:前后端分离,前端改用 Flutter(Windows/macOS)

- 新增 GC-UI/:backend(.NET 8 本地 HTTP API + 模型窗口宿主)与 frontend(Flutter 桌面应用)
- 前端一套 Dart 代码 + windows/macos 两个原生 runner,共享全部界面逻辑
- 「关于」页新增「源码语言:C#」「前端:Flutter」两行,字段由 /api/about 下发
- 截图脚本覆盖首页/下载/设置/关于/外壳,需要真实后端时用 runAsync 等待请求
- README 补充平台选型理由、接口列表与截图用法
This commit is contained in:
Frontend Developer committed 2026-11-17 13:48:17 +00:00
1 parent 2f3a8682c9
commit 9ca99a1fe1
68 files changed
+7400

No files matched your search

+85
View File
@@ -0,0 +1,85 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:gc_ui/api_client.dart';
import 'package:gc_ui/i18n.dart';
import 'package:gc_ui/theme.dart';
void main() {
group('I18n', () {
test('resolves auto to a supported language', () {
expect(I18n.supported.contains(I18n.resolve('auto')), isTrue);
expect(I18n.resolve('en-US'), 'en');
expect(I18n.resolve('zh-CN'), 'zh-CN');
});
test('translates keys and fills placeholders', () {
I18n.language.value = 'zh-CN';
expect(T('nav.home'), '主页');
expect(T('home.count', <Object?>[3]), '3 个模型');
I18n.language.value = 'en';
expect(T('nav.home'), 'Home');
expect(T('home.count', <Object?>[3]), '3 models');
});
test('falls back to the key for unknown entries', () {
expect(T('does.not.exist'), 'does.not.exist');
});
});
group('SettingsPatch', () {
test('only serialises the fields that were set', () {
const patch = SettingsPatch(renderFps: 60, memoryAuto: false);
expect(patch.toJson(), <String, dynamic>{
'renderFps': 60,
'memoryAuto': false,
});
});
test('empty patch serialises to an empty map', () {
expect(const SettingsPatch().toJson(), isEmpty);
});
});
group('GcApi', () {
test('builds model preview urls from the base url', () {
final api = GcApi(baseUrl: 'http://127.0.0.1:17890');
final model = ModelInfo.fromJson(<String, dynamic>{
'id': 'solar-system',
'name': '太阳系',
'previewUrl': '/api/models/solar-system/preview',
});
expect(api.previewUrl(model),
'http://127.0.0.1:17890/api/models/solar-system/preview');
});
test('parses a model payload', () {
final model = ModelInfo.fromJson(<String, dynamic>{
'id': 'earth',
'name': '地球',
'version': '1.2.0',
'sizeBytes': 1048576,
'sizeText': '1.0 MB',
'tags': <dynamic>['天文', '地球'],
'hasPreview': true,
});
expect(model.id, 'earth');
expect(model.tags, <String>['天文', '地球']);
expect(model.metaText, 'v1.2.0 · 1.0 MB');
});
});
group('theme', () {
testWidgets('renders a card with its child', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: buildGcTheme(),
home: const Scaffold(
body: GcCard(child: Text('hello')),
),
),
);
expect(find.text('hello'), findsOneWidget);
});
});
}