Compare commits

...
Author SHA1 Message Date
Morris 2c0c566c81 build: 支持在 Linux/macOS 上交叉编译 Windows 前端
此前 Windows 包内不含 Flutter 界面,只能回退到内置 Avalonia 界面,
原因是 Flutter 官方不支持在非 Windows 主机上执行 flutter build windows。

实际上 Windows 嵌入层(windows/runner + cpp_client_wrapper)是纯 Win32
加标准 C++,只通过 C ABI 调用 flutter_windows.dll,因此用 mingw-w64 即可
编译。整条链路上唯一必须执行的 Windows 二进制是 AOT 快照生成器
gen_snapshot.exe,交给 wine 运行即可。全流程不需要 Windows 机器或 MSVC。

实现:
- buildsh/cross/toolchain-mingw.cmake  CMake 交叉工具链,posix 线程模型,
  静态链接 libstdc++/libgcc,产物只依赖系统 DLL 和 flutter_windows.dll
- buildsh/cross/CMakeLists.txt         只编 C++ 外壳,绕开 tool_backend.bat
  与 MSVC 专用编译参数
- buildsh/cross/build-ui-win-cross.sh  拉取引擎产物、为 gen_snapshot 装 wine
  包装、生成 AOT 快照、组装出与官方 toolchain 一致的目录结构
- build_flutter_ui_cross / build.sh    非 Windows 主机走交叉编译分支,
  x64 产物同时放进 win-amd64 与 win-arm64 两个包

顺带修掉 shell.dart 的常量求值错误:强调色改为跟随设置的动态 getter 后,
const Text 里引用 GcColors.accent 会让编译器报错。

已在 Linux 上用 wine 验证产物:Flutter 引擎正常初始化,Dart AOT 快照加载
并执行到业务代码,后端 /api/health 正常返回。
2026-11-18 13:29:53 +08:00
Morris cd44c7ecff feat(ui): 启动器接入 Flutter 前端 · 公司名统一 Morris · 模型版本 +1
- GC-BOOT 新增 FlutterShell:随包带 GC.UI.Server 与 GC-UI 时,拉起「本地后端 + Flutter 窗口」,界面退出后一起收尾;缺任一产物则回退内置 Avalonia 界面
- 构建脚本新增 publish_backend(三平台发布 UI 后端)与 build_flutter_ui(宿主平台构建 Flutter 桌面产物)
- Windows 打包由「单文件 exe」改为整目录,包含启动器、GC-SAVEDOG、UI 后端与可选 Flutter 产物
- Flutter 工程:Windows BINARY_NAME 与 macOS PRODUCT_NAME 改为 GC-UI,窗口标题 Morris GC
- 公司信息:Windows CompanyName/LegalCopyright、macOS PRODUCT_COPYRIGHT 统一为 Morris
- 模型版本末位 +1:contour-map 1.1 / earth-geography 1.9 / earth-revolution 1.7 / earth-rotation 1.7 / scale-calculator 1.6,并重算清单哈希
2026-11-18 12:36:21 +08:00
Morris 0b2f263dea chore: 彻底移除 NeoRF 标识,统一为 GC / Morris
- 命名空间 NeoRF.EarthModels / NeoRF.ContourMap / NeoRF.ScaleCalculator
  改为 GC.EarthModels / GC.ContourMap / GC.ScaleCalculator
- 模型清单 type 字段同步更新,五个模型 DLL 全部重新编译并替换
- 程序集 Company 由 NeoRF 改为 Morris
- 模型作者 author 统一为 Morris(原 NeoRF / Morris GC)
- macOS 包标识 cn.neorf.GC 改为 com.xhmcl.GC
- 重算 version.json 与 model/version.json 的 build / manifestSha256 / filesSha256
2026-11-18 06:55:10 +08:00
Morris a18d0ea1a8 Merge pull request '关于页开发者改为读取仓库真实提交者(身份归并 + 排除自动化账号)' (#4) from fix/about-contributors into main
Reviewed-on: Morris/GC#4
2026-11-17 22:52:38 +00:00
Morris 06eb4875a1 fix(about): 开发者改为读取仓库真实提交者
- ContributorsService 改用 /commits 分页统计,不再依赖需要登录的 /collaborators
- 同一人的多个 git 身份按别名归并(Morris_1 / 2509_92447106 / 两个邮箱)
- 自动化提交(agent@teamily.ai)不计入开发者,避免出现在关于页
- 关于页「开发者」标题标注数据来源,贡献数为真实提交数
- 结果缓存 10 分钟;接口失败时静默降级为空列表,不影响关于页其它内容
2026-11-18 00:23:48 +08:00
Morris 2b4ffc7ce5 Merge pull request 'ci(GC-UI): 夜间 alpha 构建工作流(Windows/macOS,21:00 定时,prerelease)' (#2) from gc-ui into main
Reviewed-on: Morris/GC#2
2026-11-17 16:10:36 +00:00
Morris d379902a7a ci: artifact 上传降为 v3,兼容 Gitea Actions 2026-11-17 23:55:21 +08:00
Morris 056d64a3bc Merge pull request 'UI 体验与启动优化 · 主题色 · Gitea CI/夜间预发布 · 后端安全加固' (#3) from feat/ui-perf-ci-security into main
Reviewed-on: Morris/GC#3
2026-11-17 15:53:19 +00:00
Morris fa492bbb19 docs(ci): 补充 GC-UI CI 说明(runner 标签、Flutter 自举、token)
- 说明 .gitea/workflows 与 GitHub 目录的差异、TZ= 时区前缀、prerelease 不占用 latest 的原理
- 记录 act_runner 必须注册 ubuntu-latest / windows-latest / macos-latest 三个标签,
  以及 Windows 需 MSVC、macOS 需 Xcode
2026-11-17 14:32:26 +00:00
Morris 8904230a6f feat(ci): 新增 GC-UI 夜间 alpha 构建工作流(Gitea Actions)
- 每天 21:00(Asia/Shanghai)定时触发,产出 Windows 与 macOS 的 Flutter 前端产物
- 发布为 prerelease 预览版:Gitea 的 /releases/latest 只取非草稿、非预览的发布,
  因此 alpha 不会成为 latest;publish 任务还会再断言一次
- 先审后发:两个平台都构建成功才把草稿翻成可见
- runner 未预装 Flutter 时按官方 SDK 自举;Windows 用 PowerShell,macOS 用 ditto 保真打包 .app
2026-11-17 14:30:42 +00:00
71 changed files with 1485 additions and 217 deletions

No files matched your search

+397
View File
@@ -0,0 +1,397 @@
# GC-UI 夜间 alpha 构建(Gitea Actions)
#
# 触发:每天 21:00(Asia/Shanghai)自动跑一次,产出 Windows 与 macOS 的 Flutter 前端产物,
# 发布为一个「预览版(prerelease)」Release —— 不占用 latest。
# 手动:Actions 页面点 Run workflow(Gitea 的 workflow_dispatch),用于验证 runner 是否就绪;
# 也可以从命令行调 POST /api/v1/repos/{owner}/{repo}/actions/workflows/{file}/dispatches。
#
# 为什么是 .gitea/workflows/:本仓库是自建 Gitea,不是 GitHub。Gitea Actions 语法与
# GitHub Actions 基本一致,但工作流目录是 .gitea/workflows/,API 前缀是 /api/v1,
# runner 标签必须与 act_runner 上注册的 label 一致(见 GC-UI/CI.md)。
#
# 为什么 alpha 不会变成 latest:Gitea 的 /releases/latest 按定义只返回「最近一个既非草稿
# 也非 prerelease」的发布,所以 prerelease=true 的版本永远不会被当成 latest。
# publish 任务最后还会主动断言一次,确认 latest 没有指向本次 tag。
name: GC-UI Alpha
on:
schedule:
# 每天晚上 21:00,北京时间。
# Gitea 1.23 起 Actions 的 cron 默认按 UTC 解释,这里显式带 TZ= 前缀(robfig/cron 支持的
# 时区前缀语法),这样不依赖服务器自身时区设置。
# 如果所在实例不认 TZ= 前缀,改用等效的 UTC 写法 '0 13 * * *'。
- cron: 'TZ=Asia/Shanghai 0 21 * * *'
workflow_dispatch:
inputs:
note:
description: '额外写进 Release 说明的备注(可留空)'
required: false
default: ''
# 用 github.token 往本仓库建 Release / 传附件,需要 contents 写权限
permissions:
contents: write
env:
GITEA_API: ${{ github.server_url }}/api/v1
REPO: ${{ github.repository }}
FRONTEND_DIR: GC-UI/frontend
# runner 上没预装 Flutter 时,按这个版本自举(需 >= 3.5.4,与 pubspec.yaml 的 sdk 约束对齐)
FLUTTER_VERSION: 3.24.5
jobs:
# ---------------------------------------------------------------- 1. 版本与草稿
prepare:
name: 计算 alpha 版本并创建预览版草稿
runs-on: ubuntu-latest
outputs:
version: ${{ steps.meta.outputs.version }}
base_version: ${{ steps.meta.outputs.base_version }}
tag: ${{ steps.meta.outputs.tag }}
build_number: ${{ steps.meta.outputs.build_number }}
release_id: ${{ steps.release.outputs.release_id }}
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 计算版本号
id: meta
run: |
set -euo pipefail
# 基础版本取自 version.json 的 launcher.version(例如 1.0.7),与启动器保持一致;
# alpha 后缀只表示构建通道,写在 tag / Release 标题里。
BASE=$(python3 -c "import json;print(json.load(open('version.json'))['launcher']['version'])")
if [ -z "${BASE:-}" ]; then
echo "::error::无法从 version.json 读取 launcher.version"
exit 1
fi
# 北京时间当天日期,让产物名和 tag 与「每晚 9 点」对得上
DATE=$(TZ=Asia/Shanghai date +%Y%m%d)
# 同一天重跑时用 run_number 区分,tag 不重复
VERSION="${BASE}-alpha.${DATE}.${{ github.run_number }}"
# 传给 flutter 的版本号必须是纯数字分段:
# --build-name → macOS CFBundleShortVersionString,只能是 a.b.c
# --build-number → CFBundleVersion / 文件版本号,只能是数字
# 所以 alpha 的日期与序号放在 build-number 里,不放进 build-name。
BUILD_NUMBER="${DATE}$(printf '%02d' "${{ github.run_number }}")"
{
echo "version=$VERSION"
echo "base_version=$BASE"
echo "tag=v$VERSION"
echo "build_number=$BUILD_NUMBER"
} >> "$GITHUB_OUTPUT"
echo "alpha 版本: $VERSION(build-name=$BASE, build-number=$BUILD_NUMBER)"
- name: 创建预览版草稿
id: release
env:
# 优先用仓库 Secrets 里的 RELEASE_TOKEN;没配就退回 Gitea 自动注入的 github.token。
# 某些实例上自动 token 没有 releases 写权限,那时只需在
# Settings → Actions → Secrets 加一个 RELEASE_TOKEN,不用改本文件。
TOKEN_OVERRIDE: ${{ secrets.RELEASE_TOKEN }}
TOKEN_DEFAULT: ${{ github.token }}
TAG: ${{ steps.meta.outputs.tag }}
VERSION: ${{ steps.meta.outputs.version }}
run: |
set -euo pipefail
TOKEN="${TOKEN_OVERRIDE:-$TOKEN_DEFAULT}"
if [ -z "${TOKEN:-}" ]; then
echo "::error::拿不到 Gitea token,无法创建 Release"
exit 1
fi
api="$GITEA_API/repos/$REPO"
auth=(-H "Authorization: token $TOKEN")
# 可重跑:同 tag 的旧发布先删掉(只会是同一天重跑留下的)
code=$(curl -sS -o /tmp/existing.json -w '%{http_code}' "${auth[@]}" "$api/releases/tags/$TAG")
if [ "$code" = "200" ]; then
old_id=$(python3 -c "import json;print(json.load(open('/tmp/existing.json'))['id'])")
echo "已存在同 tag 发布 id=$old_id,先删除"
curl -sS -X DELETE "${auth[@]}" "$api/releases/$old_id" >/dev/null
fi
# draft=true + prerelease=true:
# prerelease → 永不成为 latest
# draft → 两个平台都构建成功前不对外可见,由 publish 任务翻成 false
payload=$(python3 - "$TAG" "$VERSION" "${{ github.sha }}" "${{ github.server_url }}" <<'PY'
import json, sys
tag, version, sha, server = sys.argv[1:5]
short = sha[:7]
body = (
"GC-UI 夜间 alpha 构建(自动生成,**预览版 / prerelease**)。\n\n"
"- 版本:`%s`\n"
"- 提交:`%s`\n"
"- 构建来源:%s/commit/%s\n"
"- 通道:alpha —— 每晚 21:00(Asia/Shanghai)自动构建\n\n"
"产物说明:\n\n"
"| 文件 | 平台 | 内容 |\n"
"|---|---|---|\n"
"| `gc-ui-alpha-windows-x64.zip` | Windows x64 | Flutter 前端 release 目录 |\n"
"| `gc-ui-alpha-macos-<arch>.zip` | macOS | `gc_ui.app` 应用包 |\n\n"
"这是前端产物,运行时需要配合 `GC-UI/backend/GC.UI.Server` 后端(默认 `127.0.0.1:17890`)。\n"
"未做代码签名,首次运行系统可能会提示。\n\n"
"> 本发布不是 latest:prerelease 的版本不会出现在「最新版本」里。\n"
) % (version, short, server, sha)
print(json.dumps({
"tag_name": tag,
"target_commitish": sha,
"name": "GC-UI Alpha " + version,
"body": body,
"draft": True,
"prerelease": True,
}))
PY
)
resp=$(curl -sS -X POST "${auth[@]}" -H 'Content-Type: application/json' -d "$payload" "$api/releases")
rid=$(printf '%s' "$resp" | python3 -c "import json,sys;print(json.load(sys.stdin).get('id',''))" 2>/dev/null || true)
if [ -z "$rid" ]; then
echo "::error::创建 Release 失败: $resp"
exit 1
fi
echo "release_id=$rid" >> "$GITHUB_OUTPUT"
echo "已创建预览版草稿 id=$rid tag=$TAG"
# ---------------------------------------------------------------- 2. Windows
windows:
name: 构建 Windows 前端
needs: prepare
runs-on: windows-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 准备 Flutter SDK
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
if (Get-Command flutter -ErrorAction SilentlyContinue) {
Write-Host 'runner 已自带 Flutter:'
flutter --version
} else {
Write-Host "runner 上没有 Flutter,按官方 SDK $env:FLUTTER_VERSION 自举"
$url = "https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_$env:FLUTTER_VERSION-stable.zip"
$zip = Join-Path $env:RUNNER_TEMP 'flutter.zip'
curl.exe -sSL --retry 3 -o $zip $url
if ($LASTEXITCODE -ne 0) { Write-Error "下载 Flutter SDK 失败: $url"; exit 1 }
Expand-Archive -Path $zip -DestinationPath $env:RUNNER_TEMP -Force
$flutterBin = Join-Path $env:RUNNER_TEMP 'flutter\bin'
$flutterBin | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8
$env:PATH = "$flutterBin;$env:PATH"
flutter --version
}
# Windows 桌面构建依赖 VS Build Tools 的「使用 C++ 的桌面开发」工作负载
$doctor = flutter doctor -v 2>&1 | Out-String
if ($doctor -notmatch 'Visual Studio') {
Write-Host '::warning::flutter doctor 没看到 Visual Studio,Windows 构建很可能失败'
}
Write-Host "PROCESSOR_ARCHITECTURE=$env:PROCESSOR_ARCHITECTURE"
- name: 构建前端(release)
shell: pwsh
env:
VERSION: ${{ needs.prepare.outputs.base_version }}
BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }}
run: |
$ErrorActionPreference = 'Stop'
flutter config --no-analytics 2>&1 | Out-Null
Set-Location $env:FRONTEND_DIR
flutter pub get
if ($LASTEXITCODE -ne 0) { exit 1 }
flutter build windows --release --build-name=$env:VERSION --build-number=$env:BUILD_NUMBER
if ($LASTEXITCODE -ne 0) { exit 1 }
- name: 打包
id: pack
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
# x64 / arm64 的产物都在 build\windows\<arch>\runner\Release,直接找实际存在的那个
$out = Get-ChildItem "$env:FRONTEND_DIR\build\windows" -Directory -ErrorAction SilentlyContinue |
ForEach-Object { Join-Path $_.FullName 'runner\Release' } |
Where-Object { Test-Path $_ } |
Select-Object -First 1
if (-not $out) {
Write-Error "没有找到 Windows 产物目录($env:FRONTEND_DIR\build\windows\*\runner\Release)"
exit 1
}
$arch = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'arm64' } else { 'x64' }
$name = "gc-ui-alpha-windows-$arch.zip"
New-Item -ItemType Directory -Force -Path dist | Out-Null
$zip = Join-Path (Get-Location) "dist\$name"
Compress-Archive -Path (Join-Path $out '*') -DestinationPath $zip -Force
Get-Item $zip | Format-List Name, Length
"asset=$zip" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
"asset_name=$name" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
- name: 上传到预览版
shell: pwsh
env:
TOKEN_OVERRIDE: ${{ secrets.RELEASE_TOKEN }}
TOKEN_DEFAULT: ${{ github.token }}
RELEASE_ID: ${{ needs.prepare.outputs.release_id }}
ASSET: ${{ steps.pack.outputs.asset }}
ASSET_NAME: ${{ steps.pack.outputs.asset_name }}
run: |
$ErrorActionPreference = 'Stop'
$token = if ($env:TOKEN_OVERRIDE) { $env:TOKEN_OVERRIDE } else { $env:TOKEN_DEFAULT }
if (-not $token) { Write-Error '拿不到 Gitea token'; exit 1 }
$url = "$env:GITEA_API/repos/$env:REPO/releases/$env:RELEASE_ID/assets?name=$env:ASSET_NAME"
curl.exe -sS -X POST -H "Authorization: token $token" -H "Content-Type: application/octet-stream" --data-binary "@$env:ASSET" $url
if ($LASTEXITCODE -ne 0) { exit 1 }
Write-Host "`n已上传 $env:ASSET_NAME"
# ---------------------------------------------------------------- 3. macOS
macos:
name: 构建 macOS 前端
needs: prepare
runs-on: macos-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 准备 Flutter SDK
run: |
set -euo pipefail
if command -v flutter >/dev/null 2>&1; then
echo "runner 已自带 Flutter:"
flutter --version
else
echo "runner 上没有 Flutter,按官方 SDK $FLUTTER_VERSION 自举"
case "$(uname -m)" in
arm64) SUFFIX="macos_arm64" ;;
*) SUFFIX="macos" ;;
esac
URL="https://storage.googleapis.com/flutter_infra_release/releases/stable/${SUFFIX}/flutter_${SUFFIX}_${FLUTTER_VERSION}-stable.zip"
ZIP="$RUNNER_TEMP/flutter.zip"
curl -sSL --retry 3 -o "$ZIP" "$URL"
rm -rf "$RUNNER_TEMP/flutter"
unzip -q "$ZIP" -d "$RUNNER_TEMP"
echo "$RUNNER_TEMP/flutter/bin" >> "$GITHUB_PATH"
export PATH="$RUNNER_TEMP/flutter/bin:$PATH"
flutter --version
fi
xcodebuild -version || echo "::warning::没找到 xcodebuild,macOS 构建很可能失败"
- name: 构建前端(release)
env:
VERSION: ${{ needs.prepare.outputs.base_version }}
BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }}
run: |
set -euo pipefail
flutter config --no-analytics || true
cd "$FRONTEND_DIR"
flutter pub get
flutter build macos --release --build-name="$VERSION" --build-number="$BUILD_NUMBER"
- name: 打包
id: pack
run: |
set -euo pipefail
APP="$FRONTEND_DIR/build/macos/Build/Products/Release/gc_ui.app"
if [ ! -d "$APP" ]; then
echo "::error::没有找到 macOS 产物: $APP"
exit 1
fi
case "$(uname -m)" in
arm64) ARCH=arm64 ;;
*) ARCH=x64 ;;
esac
NAME="gc-ui-alpha-macos-${ARCH}.zip"
mkdir -p dist
# 用 ditto 才能保真 .app 内的符号链接与权限,zip -r 会破坏 .app 结构
ditto -c -k --sequesterRsrc --keepParent "$APP" "dist/$NAME"
ls -lh "dist/$NAME"
{
echo "asset=dist/$NAME"
echo "asset_name=$NAME"
} >> "$GITHUB_OUTPUT"
- name: 上传到预览版
env:
TOKEN_OVERRIDE: ${{ secrets.RELEASE_TOKEN }}
TOKEN_DEFAULT: ${{ github.token }}
RELEASE_ID: ${{ needs.prepare.outputs.release_id }}
run: |
set -euo pipefail
TOKEN="${TOKEN_OVERRIDE:-$TOKEN_DEFAULT}"
if [ -z "${TOKEN:-}" ]; then
echo "::error::拿不到 Gitea token"
exit 1
fi
curl -sS -X POST \
-H "Authorization: token $TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary "@${{ steps.pack.outputs.asset }}" \
"$GITEA_API/repos/$REPO/releases/$RELEASE_ID/assets?name=${{ steps.pack.outputs.asset_name }}"
echo
echo "已上传 ${{ steps.pack.outputs.asset_name }}"
# ---------------------------------------------------------------- 4. 发布预览版
publish:
name: 发布预览版(保持 prerelease,不占用 latest)
needs: [prepare, windows, macos]
runs-on: ubuntu-latest
steps:
- name: 把草稿翻成正式预览版
env:
TOKEN_OVERRIDE: ${{ secrets.RELEASE_TOKEN }}
TOKEN_DEFAULT: ${{ github.token }}
RELEASE_ID: ${{ needs.prepare.outputs.release_id }}
TAG: ${{ needs.prepare.outputs.tag }}
NOTE: ${{ github.event.inputs.note }}
run: |
set -euo pipefail
TOKEN="${TOKEN_OVERRIDE:-$TOKEN_DEFAULT}"
api="$GITEA_API/repos/$REPO"
auth=(-H "Authorization: token $TOKEN")
code=$(curl -sS -o /tmp/rel.json -w '%{http_code}' "${auth[@]}" "$api/releases/$RELEASE_ID")
if [ "$code" != "200" ]; then
echo "::error::读不到 Release $RELEASE_ID (HTTP $code)"
exit 1
fi
payload=$(python3 - /tmp/rel.json "${NOTE:-}" <<'PY'
import json, sys
rel = json.load(open(sys.argv[1]))
note = (sys.argv[2] or "").strip()
body = rel.get("body") or ""
if note:
body += "\n---\n\n备注:" + note + "\n"
print(json.dumps({
"body": body,
"draft": False, # 可见
"prerelease": True, # 关键:永不成为 latest
}))
PY
)
patched=$(curl -sS -X PATCH "${auth[@]}" -H 'Content-Type: application/json' -d "$payload" "$api/releases/$RELEASE_ID")
printf '%s' "$patched" > /tmp/patched.json
python3 - <<'PY'
import json
d = json.load(open('/tmp/patched.json'))
print('发布成功:', d.get('html_url'), '| prerelease =', d.get('prerelease'), '| draft =', d.get('draft'))
assert d.get('prerelease') is True, 'Release 没有被标记成 prerelease,会顶掉 latest'
assert d.get('draft') is False, 'Release 仍是草稿'
PY
- name: 断言 latest 未被占用
env:
TAG: ${{ needs.prepare.outputs.tag }}
run: |
set -euo pipefail
latest_tag=$(curl -sS "$GITEA_API/repos/$REPO/releases/latest" \
| python3 -c "import json,sys;print(json.load(sys.stdin).get('tag_name') or '')" || true)
echo "本次 tag: $TAG"
echo "latest 指向: ${latest_tag:-(空)}"
if [ "$latest_tag" = "$TAG" ]; then
echo "::error::本次 alpha 成了 latest,prerelease 标记失效"
exit 1
fi
echo "OK:alpha 未占用 latest"
+1 -1
View File
@@ -107,7 +107,7 @@ jobs:
- name: 保存构建产物(便于排查)
if: always()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: nightly-build
path: dist/*.zip
+1 -1
View File
@@ -23,7 +23,7 @@
<AvaloniaVersion>11.3.9</AvaloniaVersion>
<MvvmVersion>8.2.2</MvvmVersion>
<Version>1.0.7</Version>
<Company>NeoRF</Company>
<Company>Morris</Company>
<Product>GC</Product>
<NeutralLanguage>zh-Hans</NeutralLanguage>
</PropertyGroup>
+179
View File
@@ -0,0 +1,179 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace GC;
/// <summary>
/// 新界面启动壳。
///
/// 发布包同时带 <c>GC.UI.Server</c>(本地 HTTP 后端 + 模型窗口宿主)和
/// <c>GC-UI</c>(Flutter 前端)时,启动器只做三件事:
/// 1. 拉起后端并等 <c>/api/health</c> 就绪;
/// 2. 拉起 Flutter 窗口;
/// 3. 界面退出后关掉后端。
///
/// 两个产物缺任意一个就返回 <c>false</c>,由调用方回退到内置 Avalonia 界面——
/// 这样 `dotnet run`、只编了启动器的开发场景、以及交叉编译缺前端产物的包都能正常打开。
/// </summary>
internal static class FlutterShell
{
/// <summary>与 GC-UI/frontend 的默认 baseUrl 保持一致,前端不需要额外配置。</summary>
private const int Port = 17890;
private static readonly HttpClient Http = new() { Timeout = TimeSpan.FromSeconds(1.5) };
private static Process? _backend;
public static bool TryRun(string[] args)
{
var dir = AppContext.BaseDirectory;
var backendPath = FindBackend(dir);
var uiPath = FindUi(dir);
if (backendPath == null || uiPath == null) return false;
// 用户可能重复启动:已有后端在跑就直接复用,退出时也不要关掉别人的进程。
var reused = IsHealthy();
if (!reused)
{
_backend = Start(backendPath, $"--port {Port}", dir);
if (_backend == null) return false;
if (!WaitHealthy(TimeSpan.FromSeconds(25)))
{
Stop(_backend);
_backend = null;
return false;
}
}
AppDomain.CurrentDomain.ProcessExit += (_, _) => Stop(_backend);
var ui = Start(uiPath, null, dir);
if (ui == null)
{
Stop(_backend);
_backend = null;
return false;
}
ui.WaitForExit();
Stop(_backend);
_backend = null;
return true;
}
// ---------------------------------------------------------------- 产物定位
private static string? FindBackend(string dir)
{
foreach (var name in OperatingSystem.IsWindows()
? new[] { "GC.UI.Server.exe", "GC.UI.Server" }
: new[] { "GC.UI.Server", "GC.UI.Server.exe" })
{
var path = Path.Combine(dir, name);
if (File.Exists(path)) return path;
}
return null;
}
/// <summary>
/// Flutter 桌面产物。
/// macOS 是 <c>GC-UI.app/Contents/MacOS/GC-UI</c>;Windows 是 <c>GC-UI.exe</c>;
/// Linux 是 <c>GC-UI</c>。
/// </summary>
private static string? FindUi(string dir)
{
if (OperatingSystem.IsMacOS())
{
var exe = Path.Combine(dir, "GC-UI.app", "Contents", "MacOS", "GC-UI");
if (File.Exists(exe)) return exe;
}
foreach (var name in OperatingSystem.IsWindows() ? new[] { "GC-UI.exe" } : new[] { "GC-UI" })
{
var path = Path.Combine(dir, name);
if (File.Exists(path)) return path;
}
return null;
}
// ---------------------------------------------------------------- 进程管理
private static Process? Start(string fileName, string? arguments, string workingDirectory)
{
try
{
var info = new ProcessStartInfo(fileName)
{
WorkingDirectory = workingDirectory,
UseShellExecute = false,
CreateNoWindow = true,
};
if (!string.IsNullOrEmpty(arguments)) info.Arguments = arguments;
// macOS .app 内的二进制也需要可执行位;发布包由 zip 解开时可能丢失。
if (!OperatingSystem.IsWindows())
{
try { File.SetUnixFileMode(fileName, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); }
catch { /* 权限不足时交给系统判断 */ }
}
return Process.Start(info);
}
catch (Exception ex)
{
Console.Error.WriteLine($"[shell] 启动失败 {fileName}: {ex.Message}");
return null;
}
}
private static void Stop(Process? process)
{
if (process == null) return;
try
{
if (!process.HasExited) process.Kill(entireProcessTree: true);
}
catch (Exception ex)
{
Console.Error.WriteLine($"[shell] 关闭后端失败: {ex.Message}");
}
finally
{
process.Dispose();
}
}
// ---------------------------------------------------------------- 健康检查
private static bool IsHealthy()
{
try
{
using var response = Http.GetAsync($"http://127.0.0.1:{Port}/api/health")
.GetAwaiter().GetResult();
return response.IsSuccessStatusCode;
}
catch
{
return false;
}
}
private static bool WaitHealthy(TimeSpan timeout)
{
var deadline = DateTime.UtcNow + timeout;
while (DateTime.UtcNow < deadline)
{
// 后端进程已经退出就没必要再等:端口被占、依赖缺失都会走这里。
if (_backend is { HasExited: true }) return false;
if (IsHealthy()) return true;
Thread.Sleep(250);
}
return false;
}
}
+3
View File
@@ -18,6 +18,9 @@ internal static class Program
// 上次下载的启动器新版,到这次启动才应用
if (DownloadModuleHost.Factory.TryApplyPending(paths)) return;
// 发布包带 Flutter 前端时,界面交给它;没带则回退到内置 Avalonia 界面。
if (FlutterShell.TryRun(args)) return;
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}
+118
View File
@@ -0,0 +1,118 @@
# GC-UI 持续集成
夜间 alpha 构建的工作流在 [`.gitea/workflows/gc-ui-alpha.yml`](../.gitea/workflows/gc-ui-alpha.yml)。
本仓库是自建 Gitea(不是 GitHub),所以目录是 `.gitea/workflows/`,语法与 GitHub Actions 基本一致,
差异集中在 **runner 标签** 和 **API 前缀** 两处。
## 它做什么
| 任务 | 运行环境 | 产出 |
|---|---|---|
| `prepare` | `ubuntu-latest` | 算版本号,建一个 **草稿 + prerelease** 的 Release |
| `windows` | `windows-latest` | `gc-ui-alpha-windows-x64.zip`(Flutter release 目录) |
| `macos` | `macos-latest` | `gc-ui-alpha-macos-<arch>.zip`(`gc_ui.app`,用 `ditto` 打包保真) |
| `publish` | `ubuntu-latest` | 两个平台都成功后才把草稿翻成可见,并断言 latest 没被占用 |
- **定时**:每天 **21:00(Asia/Shanghai)**,cron 写作 `TZ=Asia/Shanghai 0 21 * * *`。
Gitea 1.23 起 Actions 的 cron 默认按 **UTC** 解释,所以这里显式带时区前缀;
若你的实例不认 `TZ=`,改成等效的 UTC 写法 `0 13 * * *`。
- **alpha 不占用 latest**:Gitea 的 `/releases/latest` 只返回「最近一个既非草稿、也非 prerelease」
的发布,所以 `prerelease: true` 的夜间版本永远不会成为 latest。`publish` 任务最后会再查一次
`/releases/latest`,一旦指向本次 tag 就 fail。
- **手动触发**:Actions 页面 Run workflow;或
```bash
curl -X POST -u "USER:TOKEN" \
"https://git.xhmcl.com/api/v1/repos/Morris/GC/actions/workflows/gc-ui-alpha.yml/dispatches" \
-H 'Content-Type: application/json' -d '{"ref":"gc-ui","inputs":{"note":"手动验证"}}'
```
## 前置条件(缺一不可)
### 1. 必须有 act_runner,并且带这三个标签
```bash
# 在准备当构建机的机器上(Windows / macOS 各一台,或一台 Linux 只跑 prepare/publish)
docker run -d --name gitea-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /path/to/runner-data:/data \
-e GITEA_INSTANCE_URL=https://git.xhmcl.com \
-e GITEA_RUNNER_REGISTRATION_TOKEN=<在 站点管理 → Actions → Runners 里拿> \
-e GITEA_RUNNER_LABELS=ubuntu-latest:docker://gitea/runner-images:ubuntu-latest,windows-latest:docker://<你的 windows 镜像>,macos-latest:docker://<你的 macos 镜像> \
gitea/act_runner:latest
```
关键点:**`runs-on` 的值必须和 runner 上注册的 label 完全一致**,否则任务永远排队。
Windows / macOS 的构建**不能**跑在 Linux docker 容器里(一个要 MSVC,一个要 Xcode),
所以那两个 label 需要指向真实的 Windows / macOS 机器(自托管 runner)。
### 2. Flutter SDK
工作流里有一条「准备 Flutter SDK」:机器上已有 `flutter` 就直接用;没有就按
`FLUTTER_VERSION`(默认 3.24.5,需 >= 3.5.4 以匹配 `pubspec.yaml` 的 `sdk: ^3.5.4`)从
`storage.googleapis.com` 下载官方 SDK 并写进 `PATH`。所以机器只要能上外网就够,不必预装。
网络受限时请预装 Flutter 并确保 `flutter` 在 `PATH` 里。
Windows 还需要 **VS Build Tools 的「使用 C++ 的桌面开发」工作负载**;macOS 需要 **Xcode**。
### 3. Token
优先用仓库 Secrets 里的 `RELEASE_TOKEN`(Gitea 设置 → Actions → Secrets,需 `repo` 权限的个人访问令牌);
没配就退回 Gitea 自动注入的 `github.token`。若自动 token 没有 release 权限,
创建 Release 那步会报 401/403 —— 这时配一个 `RELEASE_TOKEN` 即可,不用改工作流文件。
## 本地构建(不经 CI)
```bash
# Linux / macOS:三平台一次出齐。Windows 前端用 mingw-w64 + wine 交叉编译,
# 不需要 Windows 机器。
./build.sh build
# 只编 macOS 前端
./GC-UI/build-ui.sh macos
# Windows 主机原生构建
GC-UI\build-ui.cmd
```
### Windows 前端交叉编译
Flutter 官方不支持在非 Windows 主机上 `flutter build windows`,但 Windows 嵌入层
(`windows/runner/*.cpp` + `cpp_client_wrapper`)是纯 Win32 + 标准 C++,只通过 C ABI
调用 `flutter_windows.dll`,所以 mingw-w64 就能编译。整条链路上唯一必须执行的
Windows 二进制是 AOT 快照生成器 `gen_snapshot.exe`,交给 wine 跑即可。
```bash
# 依赖
sudo apt install mingw-w64 cmake ninja-build wine # Linux
brew install mingw-w64 cmake ninja # macOS
brew install --cask wine-stable # macOS 的 wine
# 单独构建(默认输出到 GC-UI/frontend/build/windows/x64/runner/Release)
./buildsh/cross/build-ui-win-cross.sh [输出目录]
```
产物与官方 toolchain 完全一致,可直接拷到 Windows 运行:
```
GC-UI.exe flutter_windows.dll data/{icudtl.dat, app.so, flutter_assets/}
```
实现分三层:
| 文件 | 职责 |
|---|---|
| `buildsh/cross/toolchain-mingw.cmake` | CMake 交叉工具链(posix 线程模型,静态链接 libstdc++,产物只依赖系统 DLL) |
| `buildsh/cross/CMakeLists.txt` | 只编 C++ 外壳;绕开 `tool_backend.bat` 与 MSVC 专用参数 |
| `buildsh/cross/build-ui-win-cross.sh` | 拉引擎产物、装 `gen_snapshot` 的 wine 包装、生成 AOT 快照、组装 |
两个容易踩的坑,脚本里已处理:
- `flutter_tools` 会 exec 路径为 `.../windows-x64-release/gen_snapshot`(**没有 `.exe`**)
的文件,所以脚本在原 `.exe` 旁边放一个同名 shell 脚本转调 wine。
- `Runner.rc` 在 windres 下有两处不兼容:图标用反斜杠相对路径、`VERSION_AS_STRING`
依赖命令行传 `-D` 的转义字符串。脚本生成一份路径与宏都已规整的 rc 副本再编译。
`.gitea/workflows` 里的 `windows` 任务仍然跑在 `windows-latest` 上;若手头只有 macOS/Linux
构建机,可以把该任务的 `runs-on` 换成对应标签,直接复用这套交叉编译脚本,
不再需要 VS Build Tools。
+2
View File
@@ -124,6 +124,7 @@ class I18n {
'common.error': '出错了',
'common.refresh': '刷新',
'about.developers': '开发者',
'about.contributorsHint': '来自仓库提交记录',
'about.repository': '仓库',
'about.openRepository': '打开仓库',
'about.contributions': '{0} 次提交',
@@ -248,6 +249,7 @@ class I18n {
'common.error': 'Something went wrong',
'common.refresh': 'Refresh',
'about.developers': 'Developers',
'about.contributorsHint': 'From repository commits',
'about.repository': 'Repository',
'about.openRepository': 'Open repository',
'about.contributions': '{0} commits',
+4 -1
View File
@@ -1786,7 +1786,10 @@ class _AboutPageViewState extends State<AboutPageView> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
GcSectionTitle(T('about.developers')),
GcSectionTitle(
T('about.developers'),
trailing: GcHint(T('about.contributorsHint')),
),
const SizedBox(height: 12),
if ((_about?.contributors ?? const <ContributorInfo>[]).isEmpty)
GcHint(T('about.noContributors'))
+1 -1
View File
@@ -140,7 +140,7 @@ class _Sidebar extends StatelessWidget {
borderRadius: BorderRadius.circular(8),
),
alignment: Alignment.center,
child: const Text(
child: Text(
'◎',
style: TextStyle(fontSize: 14, color: GcColors.accent),
),
@@ -5,10 +5,10 @@
// 'flutter create' template.
// The application's name. By default this is also the title of the Flutter window.
PRODUCT_NAME = gc_ui
PRODUCT_NAME = GC-UI
// The application's bundle identifier
PRODUCT_BUNDLE_IDENTIFIER = com.morris.gc.gcUi
// The copyright displayed in application information
PRODUCT_COPYRIGHT = Copyright © 2026 com.morris.gc. All rights reserved.
PRODUCT_COPYRIGHT = Copyright © 2026 Morris. All rights reserved.
+1 -1
View File
@@ -4,7 +4,7 @@ project(gc_ui LANGUAGES CXX)
# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "gc_ui")
set(BINARY_NAME "GC-UI")
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
+6 -6
View File
@@ -89,13 +89,13 @@ BEGIN
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "com.morris.gc" "\0"
VALUE "FileDescription", "gc_ui" "\0"
VALUE "CompanyName", "Morris" "\0"
VALUE "FileDescription", "GC UI" "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "gc_ui" "\0"
VALUE "LegalCopyright", "Copyright (C) 2026 com.morris.gc. All rights reserved." "\0"
VALUE "OriginalFilename", "gc_ui.exe" "\0"
VALUE "ProductName", "gc_ui" "\0"
VALUE "InternalName", "GC-UI" "\0"
VALUE "LegalCopyright", "Copyright (C) 2026 Morris. All rights reserved." "\0"
VALUE "OriginalFilename", "GC-UI.exe" "\0"
VALUE "ProductName", "Morris GC" "\0"
VALUE "ProductVersion", VERSION_AS_STRING "\0"
END
END
+1 -1
View File
@@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
FlutterWindow window(project);
Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
if (!window.Create(L"gc_ui", origin, size)) {
if (!window.Create(L"Morris GC", origin, size)) {
return EXIT_FAILURE;
}
window.SetQuitOnClose(true);
+174 -60
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text.Json;
using System.Threading;
@@ -7,25 +8,22 @@ using System.Threading.Tasks;
namespace GC.Services;
/// <summary>GitCode 仓库的一位贡献者。</summary>
/// <summary>仓库的一位贡献者(按人归并后的结果)。</summary>
public sealed class Contributor
{
public string Name { get; set; } = "";
public string? Email { get; set; }
/// <summary>提交次数(API 里的 contributions)。</summary>
/// <summary>提交次数。</summary>
public int Contributions { get; set; }
/// <summary>接口直接返回的头像地址(Gitea 的 avatar_url);为空时按邮箱哈希生成。</summary>
public string? Avatar { get; set; }
/// <summary>
/// 登录名 -> 展示名。GitCode 的 contributors 接口只返回账号登录名,
/// 不返回真实姓名,这里做一层映射,让关于页显示作者想展示的名字。
/// </summary>
private static readonly Dictionary<string, string> DisplayNames = new(StringComparer.OrdinalIgnoreCase)
{
["Morris_1"] = "Morris"
};
/// <summary>最近一次提交时间,用于贡献数相同时排序。</summary>
public DateTimeOffset? LastCommit { get; set; }
/// <summary>关于页展示的名字。</summary>
public string DisplayName => string.IsNullOrWhiteSpace(Name) ? "匿名" : Name;
/// <summary>头像地址:优先用接口返回的头像,否则按邮箱哈希拼 GitCode 头像。</summary>
public string? AvatarUrl =>
@@ -37,25 +35,43 @@ public sealed class Contributor
System.Security.Cryptography.MD5.HashData(
System.Text.Encoding.UTF8.GetBytes(Email!.Trim().ToLowerInvariant())))
.ToLowerInvariant()}";
public string DisplayName
{
get
{
if (string.IsNullOrWhiteSpace(Name)) return "匿名";
return DisplayNames.TryGetValue(Name.Trim(), out var mapped) ? mapped : Name;
}
}
}
/// <summary>
/// 读取 GitCode 仓库的贡献者列表(用于「关于」页面展示开发者)。
/// 失败时静默返回空列表,不影响关于页其它内容。
/// 读取仓库的真实贡献者:翻页拉提交记录,按作者归并统计。
///
/// 为什么不用 /collaborators:Gitea 的协同者列表要求登录,且只包含被显式
/// 添加的协作者,和「谁真的写了代码」是两回事。这里直接读 /commits,
/// 统计每个人真实的提交数,失败时静默返回空列表,不影响关于页其它内容。
/// </summary>
public static class ContributorsService
{
private const int PageSize = 50;
private const int MaxPages = 12;
private const int MaxShown = 8;
private static readonly TimeSpan CacheTtl = TimeSpan.FromMinutes(10);
private static readonly HttpClient Http = CreateHttp();
/// <summary>同一作者的多个 git 身份 -> 统一展示名。</summary>
private static readonly Dictionary<string, string> Aliases = new(StringComparer.OrdinalIgnoreCase)
{
["morris"] = "Morris",
["morris_1"] = "Morris",
["2509_92447106"] = "Morris",
["chenmoyuan1214@qq.com"] = "Morris",
["morris@xhmcl.com"] = "Morris",
};
/// <summary>自动化提交(CI / 助手账号),不计入开发者。</summary>
private static readonly HashSet<string> IgnoredEmails = new(StringComparer.OrdinalIgnoreCase)
{
"agent@teamily.ai",
};
private static readonly object Gate = new();
private static (DateTimeOffset At, string Key, List<Contributor> Items)? _cache;
private static HttpClient CreateHttp()
{
var c = new HttpClient { Timeout = TimeSpan.FromSeconds(10) };
@@ -64,74 +80,172 @@ public static class ContributorsService
return c;
}
/// <summary>按仓库地址推导贡献者接口:Xhmcl(Gitea) 与 GitCode 结构不同。</summary>
/// <summary>按仓库地址推导接口:Xhmcl(Gitea) 与 GitCode 结构不同。</summary>
public static string BuildUrl(string repository)
{
var raw = string.IsNullOrWhiteSpace(repository)
? SourcePreset.Xhmcl.HomeUrl : repository.Trim();
if (!Uri.TryCreate(raw, UriKind.Absolute, out var uri))
return "https://git.xhmcl.com/api/v1/repos/Morris/GC/collaborators";
return "https://git.xhmcl.com/api/v1/repos/Morris/GC/commits";
var parts = uri.AbsolutePath.Trim('/').Split('/', StringSplitOptions.RemoveEmptyEntries);
if (parts.Length < 2)
return "https://git.xhmcl.com/api/v1/repos/Morris/GC/collaborators";
return "https://git.xhmcl.com/api/v1/repos/Morris/GC/commits";
var repo = parts[1].EndsWith(".git", StringComparison.OrdinalIgnoreCase)
? parts[1][..^4] : parts[1];
// GitCode 代码保留,仅在仓库确实指向 GitCode 时才走它。
// GitCode 的实现在仓库仍指向 gitcode.com 时才走它。
if (uri.Host.Contains("gitcode.com", StringComparison.OrdinalIgnoreCase))
return $"https://api.gitcode.com/api/v5/repos/{parts[0]}/{repo}/contributors";
return $"https://{uri.Host}/api/v1/repos/{parts[0]}/{repo}/collaborators";
return $"https://{uri.Host}/api/v1/repos/{parts[0]}/{repo}/commits";
}
public static async Task<List<Contributor>> FetchAsync(string repository, CancellationToken ct = default)
{
var url = BuildUrl(repository);
lock (Gate)
{
if (_cache is { } hit && hit.Key == url && DateTimeOffset.UtcNow - hit.At < CacheTtl)
return hit.Items;
}
List<Contributor> list;
try
{
using var timeout = CancellationTokenSource.CreateLinkedTokenSource(ct);
timeout.CancelAfter(TimeSpan.FromSeconds(10));
timeout.CancelAfter(TimeSpan.FromSeconds(15));
var text = await Http.GetStringAsync(url, timeout.Token);
var trimmed = text.TrimStart();
if (trimmed.Length == 0 || trimmed[0] != '[') return new List<Contributor>();
using var doc = JsonDocument.Parse(text);
var list = new List<Contributor>();
foreach (var item in doc.RootElement.EnumerateArray())
{
// Gitea: login / avatar_url;GitCode: name / email / contributions。
if (item.TryGetProperty("login", out var login))
{
list.Add(new Contributor
{
Name = login.GetString() ?? "",
Avatar = item.TryGetProperty("avatar_url", out var avatar)
? avatar.GetString() : null
});
continue;
}
list.Add(new Contributor
{
Name = item.TryGetProperty("name", out var name)
? name.GetString() ?? "" : "",
Email = item.TryGetProperty("email", out var email)
? email.GetString() : null,
Contributions = item.TryGetProperty("contributions", out var c) &&
c.TryGetInt32(out var count) ? count : 0
});
}
list.Sort((a, b) => b.Contributions.CompareTo(a.Contributions));
return list;
list = url.Contains("api.gitcode.com", StringComparison.OrdinalIgnoreCase)
? await FetchFromGitCodeAsync(url, timeout.Token)
: await FetchFromCommitsAsync(url, timeout.Token);
}
catch (Exception ex)
{
Console.Error.WriteLine($"读取贡献者失败: {ex.Message}");
return new List<Contributor>();
}
lock (Gate) _cache = (DateTimeOffset.UtcNow, url, list);
return list;
}
/// <summary>Gitea:翻页读提交记录并归并作者。</summary>
private static async Task<List<Contributor>> FetchFromCommitsAsync(string commitUrl, CancellationToken ct)
{
var byKey = new Dictionary<string, Contributor>(StringComparer.OrdinalIgnoreCase);
for (var page = 1; page <= MaxPages; page++)
{
var url = $"{commitUrl}?limit={PageSize}&page={page}&stat=false";
var text = await Http.GetStringAsync(url, ct);
using var doc = JsonDocument.Parse(text);
if (doc.RootElement.ValueKind != JsonValueKind.Array) break;
var seen = 0;
foreach (var item in doc.RootElement.EnumerateArray())
{
seen++;
string? login = null, name = null, email = null, avatar = null;
DateTimeOffset? date = null;
if (item.TryGetProperty("author", out var author) &&
author.ValueKind == JsonValueKind.Object)
{
login = author.TryGetProperty("login", out var l) ? l.GetString() : null;
avatar = author.TryGetProperty("avatar_url", out var a) ? a.GetString() : null;
}
if (item.TryGetProperty("commit", out var commit) &&
commit.TryGetProperty("author", out var ca) &&
ca.ValueKind == JsonValueKind.Object)
{
name = ca.TryGetProperty("name", out var n) ? n.GetString() : null;
email = ca.TryGetProperty("email", out var e) ? e.GetString() : email;
if (ca.TryGetProperty("date", out var d) &&
DateTimeOffset.TryParse(d.GetString(), out var parsed))
date = parsed;
}
Add(byKey, login, name, email, avatar, date);
}
if (seen < PageSize) break;
}
return Sort(byKey.Values);
}
/// <summary>GitCode:contributors 接口直接返回贡献数与邮箱。</summary>
private static async Task<List<Contributor>> FetchFromGitCodeAsync(string url, CancellationToken ct)
{
var text = await Http.GetStringAsync(url, ct);
if (text.TrimStart().Length == 0 || text.TrimStart()[0] != '[')
return new List<Contributor>();
var byKey = new Dictionary<string, Contributor>(StringComparer.OrdinalIgnoreCase);
using var doc = JsonDocument.Parse(text);
foreach (var item in doc.RootElement.EnumerateArray())
{
var name = item.TryGetProperty("name", out var n) ? n.GetString() : null;
var email = item.TryGetProperty("email", out var e) ? e.GetString() : null;
var count = item.TryGetProperty("contributions", out var c) && c.TryGetInt32(out var v) ? v : 1;
var contributor = Add(byKey, null, name, email, null, null, count);
if (contributor != null) contributor.Contributions = Math.Max(contributor.Contributions, count);
}
return Sort(byKey.Values);
}
private static Contributor? Add(
Dictionary<string, Contributor> byKey,
string? login, string? name, string? email, string? avatar, DateTimeOffset? date,
int weight = 1)
{
if (!string.IsNullOrWhiteSpace(email) && IgnoredEmails.Contains(email.Trim()))
return null;
var (key, display) = Resolve(login, name, email);
if (!byKey.TryGetValue(key, out var contributor))
{
contributor = new Contributor { Name = display };
byKey[key] = contributor;
}
contributor.Contributions += weight;
if (string.IsNullOrWhiteSpace(contributor.Email) && !string.IsNullOrWhiteSpace(email))
contributor.Email = email;
if (string.IsNullOrWhiteSpace(contributor.Avatar) && !string.IsNullOrWhiteSpace(avatar))
contributor.Avatar = avatar;
if (date.HasValue && (contributor.LastCommit == null || date > contributor.LastCommit))
contributor.LastCommit = date;
return contributor;
}
/// <summary>把同一个人在不同时期的 git 身份归并到同一个展示名。</summary>
private static (string Key, string Display) Resolve(string? login, string? name, string? email)
{
foreach (var raw in new[] { login, name, email })
{
if (string.IsNullOrWhiteSpace(raw)) continue;
if (Aliases.TryGetValue(raw.Trim(), out var display))
return ("#" + display.ToLowerInvariant(), display);
}
var label = !string.IsNullOrWhiteSpace(login) ? login!
: !string.IsNullOrWhiteSpace(name) ? name!
: email!;
return (label.Trim().ToLowerInvariant(), label.Trim());
}
private static List<Contributor> Sort(IEnumerable<Contributor> items) =>
items
.OrderByDescending(c => c.Contributions)
.ThenByDescending(c => c.LastCommit ?? DateTimeOffset.MinValue)
.ThenBy(c => c.Name, StringComparer.OrdinalIgnoreCase)
.Take(MaxShown)
.ToList();
}
+1 -1
View File
@@ -275,7 +275,7 @@ function New-MacAppBundle {
<plist version="1.0"><dict>
<key>CFBundleName</key><string>GC</string>
<key>CFBundleDisplayName</key><string>GC</string>
<key>CFBundleIdentifier</key><string>cn.neorf.GC</string>
<key>CFBundleIdentifier</key><string>com.xhmcl.GC</string>
<key>CFBundleVersion</key><string>$script:BuildVersion</string>
<key>CFBundleShortVersionString</key><string>$script:BuildVersion</string>
<key>CFBundlePackageType</key><string>APPL</string>
+21
View File
@@ -39,12 +39,33 @@ bs_build() {
progress_step "编译 Mac"
_run_publish mac 90 publish_rid "osx-arm64" "dist/mac-arm64" false || return 1
publish_backend "osx-arm64" "dist/mac-arm64" || return 1
# Flutter 的 macOS 产物只能在 macOS 上编;交叉构建时跳过,包内回退内置界面
if [ "$(uname -s)" = "Darwin" ]; then
build_flutter_ui macos "dist/mac-arm64" || return 1
fi
progress_step "编译 Win-x64"
_run_publish winx64 70 publish_rid "win-x64" "dist/win-amd64" true || return 1
publish_backend "win-x64" "dist/win-amd64" || return 1
progress_step "编译 Win-arm64"
_run_publish winarm 70 publish_rid "win-arm64" "dist/win-arm64" true || return 1
publish_backend "win-arm64" "dist/win-arm64" || return 1
# Windows 前端:Windows 主机走官方 toolchain;Linux/macOS 主机用 mingw-w64 +
# wine 交叉编译(buildsh/cross)。只产出 x64 一份,两个包共用,
# ARM64 上由系统模拟 x64 进程运行前端。
case "$(uname -s)" in
MINGW*|MSYS*|CYGWIN*) build_flutter_ui windows "dist/win-flutter" || return 1 ;;
*) build_flutter_ui_cross "dist/win-flutter" ;;
esac
if [ -d "$ROOT_DIR/dist/win-flutter" ]; then
for label in win-amd64 win-arm64; do
cp -R "$ROOT_DIR/dist/win-flutter/." "$ROOT_DIR/dist/$label/"
done
rm -rf "$ROOT_DIR/dist/win-flutter"
fi
progress_step "运行骨架"; progress_tick 100
package_mac_app
+108
View File
@@ -0,0 +1,108 @@
cmake_minimum_required(VERSION 3.14)
# 交叉编译 Flutter Windows 桌面外壳。
#
# 只编译 C++ 层:runner(Win32 窗口)+ cpp_client_wrapper(Dart 互操作)。
# Dart 侧的 flutter_assets 由 flutter assemble 单独产出,最后与
# flutter_windows.dll 一起摆进同一个目录就是完整的可运行包。
#
# 与 windows/CMakeLists.txt 的区别:不调用 tool_backend.bat(它在非 Windows
# 上不可执行),也不依赖 Visual Studio 生成器。
project(gc_ui_cross LANGUAGES CXX RC)
get_filename_component(APP_DIR "${CMAKE_CURRENT_LIST_DIR}/../../GC-UI/frontend" ABSOLUTE)
set(WIN_DIR "${APP_DIR}/windows")
set(RUN_DIR "${WIN_DIR}/runner")
set(EPHEMERAL "${WIN_DIR}/flutter/ephemeral")
set(WRAPPER "${EPHEMERAL}/cpp_client_wrapper")
set(DLL_LIB "${EPHEMERAL}/flutter_windows.dll.lib")
foreach(required
"${EPHEMERAL}/flutter_windows.dll"
"${DLL_LIB}"
"${WRAPPER}/core_implementations.cc")
if(NOT EXISTS "${required}")
message(FATAL_ERROR
"缺少 Flutter Windows 引擎产物:${required}\n"
"先运行 buildsh/cross/build-ui-win-cross.sh 里的 fetch_engine 步骤。")
endif()
endforeach()
set(FLUTTER_VERSION "1.0.0" CACHE STRING "写入 exe 版本资源")
# windres 在非 Windows 主机上不按 rc 文件所在目录解析图标路径,
# 这里把 resources\\app_icon.ico 换成绝对路径再交给 windres。
# 注意只替换这一处:rc 里其它 "\0" 是字符串转义,不能动。
file(READ "${RUN_DIR}/Runner.rc" _rc_text)
string(REPLACE "resources\\\\app_icon.ico" "${RUN_DIR}/resources/app_icon.ico" _rc_text "${_rc_text}")
# windres 收到 -DFLUTTER_VERSION=\"1.0.0\" 时会把反斜杠留在宏值里,展开成非法 token。
# 直接把宏定义成字面量,绕开命令行转义。
string(REPLACE "#define VERSION_AS_STRING FLUTTER_VERSION"
"#define VERSION_AS_STRING \"${FLUTTER_VERSION}\""
_rc_text "${_rc_text}")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/Runner.cross.rc" "${_rc_text}")
add_executable(${BINARY_NAME} WIN32
"${RUN_DIR}/main.cpp"
"${RUN_DIR}/flutter_window.cpp"
"${RUN_DIR}/utils.cpp"
"${RUN_DIR}/win32_window.cpp"
"${WIN_DIR}/flutter/generated_plugin_registrant.cc"
"${WRAPPER}/core_implementations.cc"
"${WRAPPER}/standard_codec.cc"
"${WRAPPER}/plugin_registrar.cc"
"${WRAPPER}/flutter_engine.cc"
"${WRAPPER}/flutter_view_controller.cc"
"${CMAKE_CURRENT_BINARY_DIR}/Runner.cross.rc"
)
target_include_directories(${BINARY_NAME} PRIVATE
"${RUN_DIR}"
"${WIN_DIR}"
"${EPHEMERAL}"
"${EPHEMERAL}/include"
"${WRAPPER}/include"
)
target_compile_features(${BINARY_NAME} PRIVATE cxx_std_17)
# Flutter 的 C++ wrapper 需要 RTTI 与异常;线程安全相关的锁依赖 posix 线程模型。
target_compile_options(${BINARY_NAME} PRIVATE
-fexceptions
-frtti
-Wall
-Wno-unused-parameter
-Wno-missing-field-initializers
)
# Runner.rc 里的 #include "resource.h" / runner.exe.manifest 都是相对路径,
# windres 不按源文件目录解析,必须显式给 -I。
set_source_files_properties("${RUN_DIR}/Runner.rc" PROPERTIES
COMPILE_FLAGS "-I\"${RUN_DIR}\"")
target_compile_definitions(${BINARY_NAME} PRIVATE
"FLUTTER_VERSION=\"${FLUTTER_VERSION}\""
"FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}"
"FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}"
"FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}"
"FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}"
"NOMINMAX"
)
target_link_libraries(${BINARY_NAME} PRIVATE
"${DLL_LIB}"
dwmapi
ole32
uuid
)
# runner 的入口是 wWinMain(宽字符版);MSVC 自动处理,mingw 需要 -municode
# 才会链接 wWinMainCRTStartup,否则报 undefined reference to `WinMain'。
target_link_options(${BINARY_NAME} PRIVATE -municode)
set_target_properties(${BINARY_NAME} PROPERTIES
OUTPUT_NAME "GC-UI"
SUFFIX ".exe"
)
+221
View File
@@ -0,0 +1,221 @@
#!/usr/bin/env bash
#
# 在 Linux / macOS 上交叉编译 Flutter Windows 桌面界面(GC-UI)。
#
# ./buildsh/cross/build-ui-win-cross.sh [输出目录]
#
# 产物目录是可直接拷到 Windows 上运行的一整套:
# GC-UI.exe flutter_windows.dll data/{icudtl.dat,app.so,flutter_assets/}
#
# 原理:
# Flutter 的 Windows 外壳(runner + cpp_client_wrapper)是纯 Win32 + 标准 C++,
# 只通过 C ABI 调 flutter_windows.dll,所以 mingw-w64 就能编译。
# 唯一的 Windows 专属步骤是 AOT 快照生成(gen_snapshot.exe 是 PE 文件),
# 用 wine 执行即可,全流程不需要 Windows 机器或 MSVC。
#
# 依赖:
# Linux sudo apt install mingw-w64 cmake ninja-build wine unzip curl
# macOS brew install mingw-w64 cmake ninja && brew install --cask wine-stable
#
# 环境变量:
# FLUTTER_BIN flutter 可执行文件(默认 PATH 中的 flutter,要求 3.24+)
# WIN_ENGINE_MIRROR 引擎产物来源(默认官方 GCS,国内可换 storage.flutter-io.cn)
#
set -euo pipefail
ROOT_DIR=$(cd "$(dirname "$0")/../.." && pwd)
UI_DIR="$ROOT_DIR/GC-UI/frontend"
OUT_DIR="${1:-$UI_DIR/build/windows/x64/runner/Release}"
BUILD_DIR="$UI_DIR/build/windows/x64/cross"
say() { printf '\033[36m==>\033[0m %s\n' "$*"; }
warn() { printf '\033[33m!!\033[0m %s\n' "$*"; }
die() { printf '\033[31mxx\033[0m %s\n' "$*" >&2; exit 1; }
need() { command -v "$1" >/dev/null 2>&1 || die "缺少 $1($2)"; }
# ---------------------------------------------------------------- 工具链
MINGW_CXX=""
check_toolchain() {
need cmake "Linux: apt install cmake;macOS: brew install cmake"
need ninja "Linux: apt install ninja-build;macOS: brew install ninja"
need unzip "Linux: apt install unzip"
need curl "Linux: apt install curl"
for c in x86_64-w64-mingw32-g++-posix x86_64-w64-mingw32-g++; do
if command -v "$c" >/dev/null 2>&1; then MINGW_CXX="$c"; break; fi
done
[ -n "$MINGW_CXX" ] || die "缺少 mingw-w64 C++ 编译器
Linux: sudo apt install g++-mingw-w64-x86-64-posix
macOS: brew install mingw-w64"
command -v x86_64-w64-mingw32-windres >/dev/null 2>&1 || die "缺少 mingw-w64 资源编译器"
# gen_snapshot.exe 靠 wine 执行;没有 wine 就只能出 debug 版(JIT)
if command -v wine >/dev/null 2>&1 || command -v wine64 >/dev/null 2>&1; then
WINE_BIN=$(command -v wine 2>/dev/null || command -v wine64)
else
die "缺少 wine(AOT 快照需要执行 Windows 版 gen_snapshot.exe)
Linux: sudo apt install wine
macOS: brew install --cask wine-stable"
fi
}
# ---------------------------------------------------------------- Flutter
resolve_flutter() {
FLUTTER_BIN="${FLUTTER_BIN:-flutter}"
command -v "$FLUTTER_BIN" >/dev/null 2>&1 || die "未找到 flutter,可设置 FLUTTER_BIN=/path/to/flutter"
local bin_path root target
bin_path=$(command -v "$FLUTTER_BIN")
while [ -L "$bin_path" ]; do
target=$(readlink "$bin_path")
case "$target" in
/*) bin_path="$target" ;;
*) bin_path="$(cd "$(dirname "$bin_path")" && pwd)/$target" ;;
esac
done
root=$(cd "$(dirname "$bin_path")/.." && pwd)
[ -f "$root/bin/internal/engine.version" ] || die "$root 不像 Flutter SDK 根目录"
FLUTTER_ROOT="$root"
ENGINE_DIR="$root/bin/cache/artifacts/engine"
ENGINE_HASH=$(tr -d '[:space:]' < "$root/bin/internal/engine.version")
# pubspec 要求 Dart 3.5+(Flutter 3.24+),版本不对直接提醒
local dart_ver
dart_ver=$("$root/bin/cache/dart-sdk/bin/dart" --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1) || dart_ver=""
say "Flutter SDK: $root(engine ${ENGINE_HASH:0:10}${dart_ver:+, dart $dart_ver})"
}
# ---------------------------------------------------------------- 引擎产物
ENGINE_DIR="" # 由 resolve_flutter 填充
fetch_engine() {
local base="$MIRROR/flutter/$ENGINE_HASH"
local cache="${TMPDIR:-/tmp}/gc-win-engine"
mkdir -p "$cache"
# 每个条目:远端相对路径 | 落地目录 | 落地后的标志文件
local -a items=(
"windows-x64-release/windows-x64-flutter.zip|$ENGINE_DIR/windows-x64-release|flutter_windows.dll.lib"
"windows-x64/artifacts.zip|$ENGINE_DIR/windows-x64|frontend_server_aot.dart.snapshot"
"windows-x64/flutter-cpp-client-wrapper.zip|$ENGINE_DIR/windows-x64/cpp_client_wrapper|core_implementations.cc"
)
local item remote dest marker zip
for item in "${items[@]}"; do
IFS='|' read -r remote dest marker <<<"$item"
[ -f "$dest/$marker" ] && continue
zip="$cache/$(echo "$remote" | tr '/' '_')"
if [ ! -s "$zip" ]; then
say "下载 $(basename "$remote")"
curl -fL --retry 3 --retry-delay 2 -o "$zip.part" "$base/$remote" \
|| die "下载失败:$base/$remote
可设置 WIN_ENGINE_MIRROR=https://storage.flutter-io.cn/flutter_infra_release 走国内镜像"
mv "$zip.part" "$zip"
fi
mkdir -p "$dest"
unzip -oq "$zip" -d "$dest"
done
install_gen_snapshot_shim
}
# flutter_tools 会直接 exec $ENGINE_DIR/*/gen_snapshot(无 .exe 后缀)。
# 这里放一个调用 wine 的同名脚本,并给原本的 exe 加上 .win 后缀避免混淆。
install_gen_snapshot_shim() {
local dirs=("$ENGINE_DIR/windows-x64-release" "$ENGINE_DIR/windows-x64")
local dir shim
for dir in "${dirs[@]}"; do
[ -f "$dir/gen_snapshot.exe" ] || continue
[ -f "$dir/gen_snapshot.exe.win" ] || mv "$dir/gen_snapshot.exe" "$dir/gen_snapshot.exe.win"
shim="$dir/gen_snapshot"
cat > "$shim" <<EOF
#!/bin/sh
# 由 buildsh/cross/build-ui-win-cross.sh 生成:用 wine 执行 Windows 版 gen_snapshot。
export WINEPREFIX="\${WINEPREFIX:-\$HOME/.wine64}"
export WINEDEBUG=-all
exec "$WINE_BIN" "$dir/gen_snapshot.exe.win" "\$@"
EOF
chmod +x "$shim"
done
}
# ---------------------------------------------------------------- 构建
build_assets_and_aot() {
say "生成 Dart 资源与 AOT 快照"
( cd "$UI_DIR" && "$FLUTTER_BIN" --no-version-check --suppress-analytics pub get >/dev/null )
local dart="$FLUTTER_ROOT/bin/cache/dart-sdk/bin/dart"
local tool="$FLUTTER_ROOT/packages/flutter_tools/bin/tool_backend.dart"
# tool_backend 是官方 CMake 调用的同一入口:解包引擎产物到 ephemeral、
# 生成 flutter_assets、aot_elf_release。它末尾的收尾步骤在非 Windows host
# 上可能非零退出,所以只校验产物是否齐备。
( cd "$UI_DIR" && \
FLUTTER_ROOT="$FLUTTER_ROOT" \
PROJECT_DIR="$UI_DIR" \
FLUTTER_STORAGE_BASE_URL="${FLUTTER_STORAGE_BASE_URL:-$MIRROR}" \
"$dart" "$tool" windows-x64 release ) || true
[ -f "$UI_DIR/build/windows/app.so" ] || die "AOT 快照未生成(wine 执行 gen_snapshot 失败?)"
[ -d "$UI_DIR/build/flutter_assets" ] || die "flutter_assets 未生成"
say "AOT 快照 $(du -h "$UI_DIR/build/windows/app.so" | cut -f1),资源 $(du -sh "$UI_DIR/build/flutter_assets" | cut -f1)"
}
build_cpp() {
local ver major minor patch build_no
read -r major minor patch build_no <<<"$(sed -n 's/^version:[[:space:]]*//p' "$UI_DIR/pubspec.yaml" \
| head -1 | awk -F'[.+]' '{print $1+0, $2+0, $3+0, ($4==""?0:$4+0)}')"
ver="${major}.${minor}.${patch}"
say "编译 C++ 外壳($(basename "$MINGW_CXX"))"
cmake -S "$ROOT_DIR/buildsh/cross" -B "$BUILD_DIR" -G Ninja \
-DCMAKE_TOOLCHAIN_FILE="$ROOT_DIR/buildsh/cross/toolchain-mingw.cmake" \
-DCMAKE_BUILD_TYPE=Release \
-DBINARY_NAME=GC-UI \
-DFLUTTER_VERSION="$ver" \
-DFLUTTER_VERSION_MAJOR="$major" \
-DFLUTTER_VERSION_MINOR="$minor" \
-DFLUTTER_VERSION_PATCH="$patch" \
-DFLUTTER_VERSION_BUILD="$build_no" >/dev/null
cmake --build "$BUILD_DIR" -- -j "$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 4)" \
|| die "C++ 编译失败"
[ -f "$BUILD_DIR/GC-UI.exe" ] || die "未产出 GC-UI.exe"
}
stage() {
local eph="$UI_DIR/windows/flutter/ephemeral"
say "组装到 $OUT_DIR"
rm -rf "$OUT_DIR"
mkdir -p "$OUT_DIR/data"
cp "$BUILD_DIR/GC-UI.exe" "$OUT_DIR/"
cp "$eph/flutter_windows.dll" "$OUT_DIR/"
cp "$eph/icudtl.dat" "$OUT_DIR/data/"
cp "$UI_DIR/build/windows/app.so" "$OUT_DIR/data/"
cp -R "$UI_DIR/build/flutter_assets/." "$OUT_DIR/data/flutter_assets/"
say "完成:$(du -sh "$OUT_DIR" | cut -f1)"
find "$OUT_DIR" -maxdepth 2 -mindepth 1 | sed "s|$OUT_DIR| .|"
}
# ---------------------------------------------------------------- main
MIRROR="${WIN_ENGINE_MIRROR:-https://storage.googleapis.com/flutter_infra_release}"
check_toolchain
resolve_flutter
fetch_engine
build_assets_and_aot
build_cpp
stage
+36
View File
@@ -0,0 +1,36 @@
# 在 Linux / macOS 上交叉编译 Flutter Windows 桌面应用的 CMake 工具链。
#
# 原理:Flutter 的 Windows 嵌入层(windows/runner/*.cpp + cpp_client_wrapper)
# 是纯 Win32 + 标准 C++,只通过 C ABI 调用 flutter_windows.dll。因此用
# mingw-w64(GCC,posix 线程模型)即可产出与官方 toolchain 等价的 PE 产物,
# 不需要 Windows 机器,也不需要 MSVC。
#
# 用法:
# cmake -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE=.../toolchain-mingw.cmake ...
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_VERSION 10.0)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(MINGW_PREFIX "x86_64-w64-mingw32" CACHE STRING "目标三元组前缀")
# 必须用 posix 线程模型:Flutter 的 C++ wrapper 依赖 std::mutex / std::thread,
# win32 线程模型下的 libstdc++ 不提供这些类型。
find_program(MINGW_C NAMES ${MINGW_PREFIX}-gcc-posix ${MINGW_PREFIX}-gcc REQUIRED)
find_program(MINGW_CXX NAMES ${MINGW_PREFIX}-g++-posix ${MINGW_PREFIX}-g++ REQUIRED)
find_program(MINGW_RC NAMES ${MINGW_PREFIX}-windres REQUIRED)
set(CMAKE_C_COMPILER "${MINGW_C}")
set(CMAKE_CXX_COMPILER "${MINGW_CXX}")
set(CMAKE_RC_COMPILER "${MINGW_RC}")
set(CMAKE_FIND_ROOT_PATH "/usr/${MINGW_PREFIX}")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
# 静态链接 libgcc / libstdc++ / winpthread,产物只依赖 flutter_windows.dll
# 和系统 DLL,拷到干净机器上也能跑。
set(CMAKE_CXX_FLAGS_INIT "-DUNICODE -D_UNICODE -DNOMINMAX -D_HAS_EXCEPTIONS=1")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-static -static-libgcc -static-libstdc++")
+89 -9
View File
@@ -174,32 +174,112 @@ pack_models() {
# macOS: .app 必须打成 zip 才能作为单文件分发;文件名用 .app.zip,
# 这样 macOS 双击会用归档工具解压出可运行的 .app。
# 若直接命名 .app,系统会把 zip 当成应用包解析 => 报「已损坏/打不开」。
# 发布本地 UI 后端(GC.UI.Server)。启动器会拉起它并等待 /api/health,
# 模型窗口也由它承载,所以必须和启动器放在同一目录。
publish_backend() {
RID="$1"; OUT="$2"
echo "==> 编译 UI 后端 (${RID}) -> ${OUT}"
dotnet publish "$ROOT_DIR/GC-UI/backend/GC.UI.Server/GC.UI.Server.csproj" \
-c Release \
-r "$RID" \
--self-contained true \
-p:Version="$VERSION" \
-p:DebugType=none \
-p:PublishSingleFile=false \
-p:PublishTrimmed=false \
-o "$ROOT_DIR/$OUT" || return 1
}
# 当前主机原生构建 Flutter 前端(Windows 主机编 Windows,macOS 主机编 macOS)。
# macOS 版 Flutter 桌面只能在 macOS 上编;Windows 版则由 build_flutter_ui_cross
# 在 Linux/macOS 上交叉编译。
build_flutter_ui() {
PLAT="$1"; DEST="$2"
UI_SRC="$ROOT_DIR/GC-UI/frontend"
[ -d "$UI_SRC" ] || return 0
FLUTTER_BIN="${FLUTTER_BIN:-flutter}"
if ! command -v "$FLUTTER_BIN" >/dev/null 2>&1; then
echo "!! 未找到 flutter(可用 FLUTTER_BIN=<路径> 指定),本次包内不含 Flutter 界面"
return 0
fi
echo "==> 构建 Flutter 前端 (${PLAT})"
( cd "$UI_SRC" && "$FLUTTER_BIN" pub get && "$FLUTTER_BIN" build "$PLAT" --release ) || return 1
mkdir -p "$ROOT_DIR/$DEST"
case "$PLAT" in
windows)
# Release/ 里含 GC-UI.exe、flutter_windows.dll 和 data/
cp -R "$UI_SRC/build/windows/x64/runner/Release/." "$ROOT_DIR/$DEST/"
;;
macos)
rm -rf "$ROOT_DIR/$DEST/GC-UI.app"
cp -R "$UI_SRC/build/macos/Build/Products/Release/GC-UI.app" "$ROOT_DIR/$DEST/"
;;
esac
echo " -> $DEST(Flutter ${PLAT})"
}
# 在 Linux / macOS 上交叉编译 Windows 前端:mingw-w64 编 C++ 外壳,
# wine 跑 Windows 版 gen_snapshot 生成 AOT 快照,无需 Windows 机器。
# 产物布局与官方 toolchain 完全一致(GC-UI.exe + flutter_windows.dll + data/)。
build_flutter_ui_cross() {
DEST="$1"
UI_SRC="$ROOT_DIR/GC-UI/frontend"
[ -d "$UI_SRC" ] || return 0
FLUTTER_BIN="${FLUTTER_BIN:-flutter}"
if ! command -v "$FLUTTER_BIN" >/dev/null 2>&1; then
echo "!! 未找到 flutter(可用 FLUTTER_BIN=<路径> 指定),本次包内不含 Flutter 界面"
return 0
fi
mkdir -p "$ROOT_DIR/build/logs"
echo "==> 交叉编译 Windows 前端(mingw-w64 + wine)"
if ! FLUTTER_BIN="$FLUTTER_BIN" bash "$ROOT_DIR/buildsh/cross/build-ui-win-cross.sh" \
"$UI_SRC/build/windows/x64/runner/Release" \
>"$ROOT_DIR/build/logs/flutter-win-cross.log" 2>&1; then
echo "!! 交叉编译失败,本次包内不含 Flutter 界面(日志:build/logs/flutter-win-cross.log)"
return 0
fi
mkdir -p "$ROOT_DIR/$DEST"
cp -R "$UI_SRC/build/windows/x64/runner/Release/." "$ROOT_DIR/$DEST/"
echo " -> $DEST(Flutter windows,交叉编译)"
}
pack_launcher() {
echo "==> 生成启动器产物(GC-<版本>-<系统>-<架构>)"
# --- Windows:exe 单文件(连同 GC-SAVEDOG.exe 一起打进 zip)---
# --- Windows:启动器 + 守护进程 + UI 后端 + Flutter 前端,整目录打包 ---
for pair in "win-x64:win-amd64" "win-arm64:win-arm64"; do
RID="${pair%%:*}"; LABEL="${pair##*:}"
SRC="$ROOT_DIR/dist/$LABEL"
[ -d "$SRC" ] || SRC="$ROOT_DIR/dist/$RID" # 兼容旧布局
[ -d "$SRC" ] || continue
# 注意排除守护进程:GC-SAVEDOG.exe 在字典序里排在 GC.exe 前面
EXE=$(ls "$SRC"/*.exe 2>/dev/null | grep -v 'GC-SAVEDOG' | head -1)
# 启动器固定是 GC.exe;后端与前端是可选的随包产物,不能当成启动器。
EXE="$SRC/GC.exe"
[ -f "$EXE" ] || EXE=$(ls "$SRC"/*.exe 2>/dev/null | grep -v 'GC-SAVEDOG\|GC.UI.Server\|GC-UI' | head -1)
[ -n "$EXE" ] || continue
TMP="$ROOT_DIR/dist/.winpkg-$LABEL"
rm -rf "$TMP"; mkdir -p "$TMP"
cp "$EXE" "$TMP/GC-${VERSION}-${LABEL}.exe"
cp -R "$SRC"/. "$TMP"/
rm -f "$TMP"/*.zip
mv "$TMP/$(basename "$EXE")" "$TMP/GC-${VERSION}-${LABEL}.exe"
chmod +x "$TMP/GC-${VERSION}-${LABEL}.exe" 2>/dev/null || true
if [ -f "$SRC/GC-SAVEDOG.exe" ]; then
cp "$SRC/GC-SAVEDOG.exe" "$TMP/GC-SAVEDOG.exe"
else
if [ ! -f "$TMP/GC-SAVEDOG.exe" ]; then
echo " !! 缺少 GC-SAVEDOG.exe,该平台将退回旧脚本更新"
fi
if [ ! -f "$TMP/GC-UI.exe" ]; then
echo " !! 包内没有 Flutter 前端,启动器将使用内置 Avalonia 界面"
fi
ZIP="$ROOT_DIR/dist/$LABEL/GC-${VERSION}-${LABEL}.zip"
rm -f "$ZIP"
( cd "$TMP" && zip -q "$ZIP" ./* )
( cd "$TMP" && zip -qr "$ZIP" . )
rm -rf "$TMP"
echo " -> dist/$LABEL/GC-${VERSION}-${LABEL}.zip"
done
@@ -284,7 +364,7 @@ package_mac_app() {
<dict>
<key>CFBundleName</key><string>GC</string>
<key>CFBundleDisplayName</key><string>GC</string>
<key>CFBundleIdentifier</key><string>cn.neorf.GC</string>
<key>CFBundleIdentifier</key><string>com.xhmcl.GC</string>
<key>CFBundleVersion</key><string>${VERSION}</string>
<key>CFBundleShortVersionString</key><string>${VERSION}</string>
<key>CFBundlePackageType</key><string>APPL</string>
+2 -2
View File
@@ -74,10 +74,10 @@ dll / json 的哈希 —— 本地文件被替换会直接拒绝加载。
"descriptionI18n": { "zh-CN": "……", "en": "……" },
"version": "1.6",
"updatedAt": "2026-11-14T08:00:00Z",
"author": "NeoRF",
"author": "Morris",
"tags": ["astronomy", "geography"],
"assembly": "EarthRotationModel.dll",
"type": "NeoRF.EarthModels.RotationModelFactory",
"type": "GC.EarthModels.RotationModelFactory",
"preview": "preview.png",
"apiVersion": 1,
"minAppVersion": "1.0.7"
+1 -1
View File
@@ -5,7 +5,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<RootNamespace>NeoRF.EarthModels</RootNamespace>
<RootNamespace>GC.EarthModels</RootNamespace>
<AssemblyName>EarthModelPreview</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
+2 -2
View File
@@ -10,9 +10,9 @@ using Avalonia.Headless;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using GC.ModelSdk;
using NeoRF.EarthModels;
using GC.EarthModels;
namespace NeoRF.EarthModels.Preview;
namespace GC.EarthModels.Preview;
/// <summary>
/// 封面生成工具:给每个模型画一张 preview.png。
+1 -1
View File
@@ -12,7 +12,7 @@ using Avalonia.Media.Imaging;
using Avalonia.Platform;
using Avalonia.Threading;
namespace NeoRF.EarthModels;
namespace GC.EarthModels;
public enum SceneView
{
+1 -1
View File
@@ -11,7 +11,7 @@ using Avalonia.Media;
using Avalonia.Threading;
using GC.ModelSdk;
namespace NeoRF.EarthModels;
namespace GC.EarthModels;
/// <summary>
/// 模型自己的界面:画布 + 触控友好工具栏 + 课堂演示卡 + 节气定格与步进。
+1 -1
View File
@@ -2,7 +2,7 @@ using System;
using Avalonia.Controls;
using GC.ModelSdk;
namespace NeoRF.EarthModels;
namespace GC.EarthModels;
/// <summary>
/// 地球模型共享运行时:读自己目录下的 scene.json / land.json / i18n,
+1 -1
View File
@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic;
using System.Numerics;
namespace NeoRF.EarthModels;
namespace GC.EarthModels;
/// <summary>
/// 地理模型的球面几何工具:经纬度 ↔ 单位球坐标、正交投影到屏幕、
+1 -1
View File
@@ -4,7 +4,7 @@ using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace NeoRF.EarthModels;
namespace GC.EarthModels;
/// <summary>&lt;id&gt;.model/land.json —— 简化的大陆轮廓(经纬度多边形)。</summary>
public sealed class LandData
+1 -1
View File
@@ -3,7 +3,7 @@ using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace NeoRF.EarthModels;
namespace GC.EarthModels;
/// <summary>模型自己的 JSON 读写(不依赖启动器)。</summary>
public static class ModelJson
+1 -1
View File
@@ -4,7 +4,7 @@ using System.Globalization;
using System.IO;
using System.Text.Json;
namespace NeoRF.EarthModels;
namespace GC.EarthModels;
/// <summary>
/// 模型自己的一份文案。优先读模型数据目录里的 <c>i18n/&lt;language&gt;.json</c>,
+1 -1
View File
@@ -1,6 +1,6 @@
using System.Collections.Generic;
namespace NeoRF.EarthModels;
namespace GC.EarthModels;
/// <summary>&lt;id&gt;.model/scene.json —— 模型数据(可视化场景描述)。</summary>
public sealed class SceneDefinition
+1 -1
View File
@@ -2,7 +2,7 @@ using System;
using System.IO;
using Avalonia.Media;
namespace NeoRF.EarthModels;
namespace GC.EarthModels;
/// <summary>
/// 模型自己的场景运行时:场景描述 + 预烘焙地表纹理 + 调色板。
+1 -1
View File
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using Avalonia.Media;
namespace NeoRF.EarthModels;
namespace GC.EarthModels;
/// <summary>
/// 预烘焙的等经纬度地表贴图:反照率 + 高度 + 冰盖 + 云层 + 夜间灯光。
+1 -1
View File
@@ -3,7 +3,7 @@ using System.Numerics;
using System.Threading.Tasks;
using Avalonia.Media.Imaging;
namespace NeoRF.EarthModels;
namespace GC.EarthModels;
/// <summary>
/// 球体像素级渲染:正交投影 + 预烘焙地表纹理 + 地形光照 + 云层 + 夜灯 + 大气边缘光。
+4 -4
View File
@@ -16,8 +16,8 @@
"terrain"
],
"assembly": "ContourMapModel.dll",
"type": "NeoRF.ContourMap.ContourMapFactory",
"version": "1.0",
"type": "GC.ContourMap.ContourMapFactory",
"version": "1.1",
"chrome": {
"titleBar": "#0C1828",
"titleBorder": "#1B2740",
@@ -25,6 +25,6 @@
"button": "#9FB4D4",
"frame": "#0A1524"
},
"build": "e4b3f2b87e",
"updatedAt": "2026-11-14T11:34:35Z"
"build": "773ab2161d",
"updatedAt": "2026-11-18T04:35:15Z"
}
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<RootNamespace>NeoRF.ContourMap</RootNamespace>
<RootNamespace>GC.ContourMap</RootNamespace>
<AssemblyName>ContourMapModel</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>false</IsPackable>
+1 -1
View File
@@ -6,7 +6,7 @@ using Avalonia.Layout;
using Avalonia.Media;
using GC.ModelSdk;
namespace NeoRF.ContourMap;
namespace GC.ContourMap;
/// <summary>等高线模型入口(清单里的 type 指向这里)。</summary>
public sealed class ContourMapFactory : IModelFactory
+1 -1
View File
@@ -5,7 +5,7 @@ using Avalonia.Controls;
using Avalonia.Layout;
using Avalonia.Media;
namespace NeoRF.ContourMap;
namespace GC.ContourMap;
/// <summary>等高线模型的界面:顶部标题、中间双图联动、右侧判读要点、底部实时读数。</summary>
public sealed class ContourPage
+1 -1
View File
@@ -6,7 +6,7 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
namespace NeoRF.ContourMap;
namespace GC.ContourMap;
/// <summary>
/// 等高线教学画布,左右两块:
+1 -1
View File
@@ -1,6 +1,6 @@
using System.Collections.Generic;
namespace NeoRF.ContourMap;
namespace GC.ContourMap;
/// <summary>内置全量文案兜底:没有语言包也能完整显示。</summary>
internal static class DefaultTexts
+1 -1
View File
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
namespace NeoRF.ContourMap;
namespace GC.ContourMap;
/// <summary>地形部位识别结果:课本要求学生能在等高线图上认出这五种部位。</summary>
public enum TerrainFeature
+1 -1
View File
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
namespace NeoRF.ContourMap;
namespace GC.ContourMap;
/// <summary>五种基本地形类型(教科书分类)。</summary>
public enum TerrainKind
+4 -4
View File
@@ -9,7 +9,7 @@
"en": "Climate zones, continent/ocean outlines, plates and borders — clean line art."
},
"assembly": "EarthGeographyModel.dll",
"type": "NeoRF.EarthModels.GeographyModelFactory",
"type": "GC.EarthModels.GeographyModelFactory",
"author": "Morris GC",
"tags": [
"geography",
@@ -17,7 +17,7 @@
"atlas"
],
"dataDir": "earth-geography.model",
"version": "1.8",
"version": "1.9",
"chrome": {
"titleBar": "#0C1828",
"titleBorder": "#1B2740",
@@ -25,6 +25,6 @@
"button": "#9FB4D4",
"frame": "#0A1524"
},
"build": "3b645c45c2",
"updatedAt": "2026-11-14T11:34:35Z"
"build": "cc68b8863b",
"updatedAt": "2026-11-18T04:35:15Z"
}
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<RootNamespace>NeoRF.EarthModels</RootNamespace>
<RootNamespace>GC.EarthModels</RootNamespace>
<AssemblyName>EarthGeographyModel</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>false</IsPackable>
+1 -1
View File
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace NeoRF.EarthModels;
namespace GC.EarthModels;
/// <summary>地球地理模型的数据文件:全部是经纬度折线,只有轮廓没有填色。</summary>
public sealed class GeoData
@@ -7,7 +7,7 @@ using Avalonia.Layout;
using Avalonia.Media;
using GC.ModelSdk;
namespace NeoRF.EarthModels;
namespace GC.EarthModels;
/// <summary>
/// 地球地理模型:五带划分 + 七大洲四大洋轮廓 + 六大板块与洲界,纯线稿。
+1 -1
View File
@@ -8,7 +8,7 @@ using Avalonia.Input;
using Avalonia.Media;
using GC.ModelSdk;
namespace NeoRF.EarthModels;
namespace GC.EarthModels;
public enum GeoMode { Sphere3D, Flat2D }
+5 -5
View File
@@ -6,7 +6,7 @@
"zh-CN": "地球公转",
"en": "Earth Revolution"
},
"author": "NeoRF",
"author": "Morris",
"description": "四季更替、黄赤交角与二分二至",
"descriptionI18n": {
"zh-CN": "地球绕太阳公转一年:地轴指向不变,太阳直射点南北往返,形成四季。",
@@ -20,10 +20,10 @@
"entry": "scene.json",
"license": "MIT",
"assembly": "EarthRevolutionModel.dll",
"type": "NeoRF.EarthModels.RevolutionModelFactory",
"type": "GC.EarthModels.RevolutionModelFactory",
"preview": "preview.png",
"apiVersion": 1,
"version": "1.6",
"version": "1.7",
"chrome": {
"titleBar": "#0C1828",
"titleBorder": "#1B2740",
@@ -31,6 +31,6 @@
"button": "#9FB4D4",
"frame": "#0A1524"
},
"build": "947efa36bb",
"updatedAt": "2026-11-14T11:34:35Z"
"build": "53b7a0fbc3",
"updatedAt": "2026-11-18T04:35:15Z"
}
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<RootNamespace>NeoRF.EarthModels</RootNamespace>
<RootNamespace>GC.EarthModels</RootNamespace>
<AssemblyName>EarthRevolutionModel</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>false</IsPackable>
@@ -1,6 +1,6 @@
using GC.ModelSdk;
namespace NeoRF.EarthModels;
namespace GC.EarthModels;
/// <summary>地球公转模型入口(清单里的 type 指向这里)。</summary>
public sealed class RevolutionModelFactory : IModelFactory
+5 -5
View File
@@ -6,7 +6,7 @@
"zh-CN": "地球自转",
"en": "Earth Rotation"
},
"author": "NeoRF",
"author": "Morris",
"description": "昼夜交替、晨昏线与太阳直射点",
"descriptionI18n": {
"zh-CN": "观察自转中的地球:昼夜半球、晨昏线与太阳直射点位置。",
@@ -20,10 +20,10 @@
"entry": "scene.json",
"license": "MIT",
"assembly": "EarthRotationModel.dll",
"type": "NeoRF.EarthModels.RotationModelFactory",
"type": "GC.EarthModels.RotationModelFactory",
"preview": "preview.png",
"apiVersion": 1,
"version": "1.6",
"version": "1.7",
"chrome": {
"titleBar": "#0C1828",
"titleBorder": "#1B2740",
@@ -31,6 +31,6 @@
"button": "#9FB4D4",
"frame": "#0A1524"
},
"build": "a803d9c020",
"updatedAt": "2026-11-14T11:34:35Z"
"build": "ecd52665f9",
"updatedAt": "2026-11-18T04:35:15Z"
}
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<RootNamespace>NeoRF.EarthModels</RootNamespace>
<RootNamespace>GC.EarthModels</RootNamespace>
<AssemblyName>EarthRotationModel</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>false</IsPackable>
@@ -1,6 +1,6 @@
using GC.ModelSdk;
namespace NeoRF.EarthModels;
namespace GC.EarthModels;
/// <summary>地球自转模型入口(清单里的 type 指向这里)。</summary>
public sealed class RotationModelFactory : IModelFactory
+4 -4
View File
@@ -21,10 +21,10 @@
"entry": "scales.json",
"license": "MIT",
"assembly": "ScaleCalculatorModel.dll",
"type": "NeoRF.ScaleCalculator.ScaleCalculatorFactory",
"type": "GC.ScaleCalculator.ScaleCalculatorFactory",
"preview": "preview.png",
"apiVersion": 1,
"version": "1.5",
"version": "1.6",
"chrome": {
"titleBar": "#FFFFFF",
"titleBorder": "#E3E8F3",
@@ -32,6 +32,6 @@
"button": "#5B6A86",
"frame": "#F4F6FB"
},
"build": "02a555272a",
"updatedAt": "2026-11-14T11:34:35Z"
"build": "105653737d",
"updatedAt": "2026-11-18T04:35:15Z"
}
+1 -1
View File
@@ -1,6 +1,6 @@
using System.Collections.Generic;
namespace NeoRF.ScaleCalculator;
namespace GC.ScaleCalculator;
/// <summary>内置全量文案兜底:即使模型包里没有语言包也能完整显示。</summary>
internal static class DefaultTexts
@@ -1,6 +1,6 @@
using GC.ModelSdk;
namespace NeoRF.ScaleCalculator;
namespace GC.ScaleCalculator;
/// <summary>比例尺计算器模型入口(清单里的 type 指向这里)。</summary>
public sealed class ScaleCalculatorFactory : IModelFactory
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<RootNamespace>NeoRF.ScaleCalculator</RootNamespace>
<RootNamespace>GC.ScaleCalculator</RootNamespace>
<AssemblyName>ScaleCalculatorModel</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>false</IsPackable>
@@ -5,7 +5,7 @@ using System.Text.Json;
using Avalonia.Controls;
using GC.ModelSdk;
namespace NeoRF.ScaleCalculator;
namespace GC.ScaleCalculator;
/// <summary>
/// 比例尺计算器运行时。Prepare 在后台线程读数据/语言包,CreateView 在 UI 线程构建界面。
@@ -5,7 +5,7 @@ using Avalonia.Controls.Primitives;
using Avalonia.Layout;
using Avalonia.Media;
namespace NeoRF.ScaleCalculator;
namespace GC.ScaleCalculator;
public sealed partial class ScaleCalculatorView
{
@@ -5,7 +5,7 @@ using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Media;
namespace NeoRF.ScaleCalculator;
namespace GC.ScaleCalculator;
public sealed partial class ScaleCalculatorView
{
@@ -8,7 +8,7 @@ using Avalonia.Input;
using Avalonia.Layout;
using Avalonia.Media;
namespace NeoRF.ScaleCalculator;
namespace GC.ScaleCalculator;
/// <summary>
/// 比例尺计算器主界面。三栏(已知量 / 可视化标尺 / 三种写法与判读)+ 底部实地尺与练习。
+1 -1
View File
@@ -4,7 +4,7 @@ using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace NeoRF.ScaleCalculator;
namespace GC.ScaleCalculator;
public sealed class PresetItem
{
+1 -1
View File
@@ -1,7 +1,7 @@
using System;
using System.Globalization;
namespace NeoRF.ScaleCalculator;
namespace GC.ScaleCalculator;
/// <summary>三种求解模式:待求的量。</summary>
public enum SolveMode
+1 -1
View File
@@ -4,7 +4,7 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
namespace NeoRF.ScaleCalculator;
namespace GC.ScaleCalculator;
/// <summary>
/// 自绘可视化标尺:上条「图上距离」按真实厘米画,下条「实地距离」按同一比例尺压缩,
+28 -35
View File
@@ -1,6 +1,6 @@
{
"schema": 1,
"generated": "2026-11-14T11:34:35Z",
"generated": "2026-11-18T04:35:15Z",
"repository": "https://gitcode.com/Morris_1/GC",
"branch": "main",
"modelDir": "model",
@@ -13,24 +13,24 @@
"dir": "dist/win-amd64",
"name": "GC-1.0.7-win-amd64.zip",
"url": "https://gitcode.com/Morris_1/GC/releases/download/v1.0.7/GC-1.0.7-win-amd64.zip",
"sha256": "f90ff51ac6b041ae238cbeb4672622b0d029142a9d8b0705f08e654336512308",
"size": 46363183
"sha256": "e9e0794206c6a0dfb8449ac30390ed788da72a5661d362af9f9a6e489cad0aad",
"size": 102382195
},
"win-arm64": {
"path": "dist/win-arm64/GC-1.0.7-win-arm64.zip",
"dir": "dist/win-arm64",
"name": "GC-1.0.7-win-arm64.zip",
"url": "https://gitcode.com/Morris_1/GC/releases/download/v1.0.7/GC-1.0.7-win-arm64.zip",
"sha256": "0b2bab2c3ac7e6223d8dd0b0faf9a0994319fa5ad13826addf7b402619b812e0",
"size": 44390354
"sha256": "11dd6aea480b7eb9d5d0e40c6e8ac7733b83756e37ec924cb98f5e46a531def1",
"size": 98435968
},
"osx-arm64": {
"path": "dist/mac-arm64/GC-1.0.7-mac-arm64.zip",
"dir": "dist/mac-arm64",
"name": "GC-1.0.7-mac-arm64.zip",
"url": "https://gitcode.com/Morris_1/GC/releases/download/v1.0.7/GC-1.0.7-mac-arm64.zip",
"sha256": "e5fd355bace68dc0794eb3e049cbef63c952a60a765ab3806adaf1199e1b09ab",
"size": 9178314
"sha256": "b085ffabf764ab57cc69a0192b47069479170f9494fb9f447230e74028794982",
"size": 60065859
},
"osx-x64": {
"path": "dist/mac-x64/GC-1.0.7-mac-x64.zip",
@@ -49,55 +49,48 @@
"models": [
{
"id": "contour-map",
"version": "1.0",
"build": "e4b3f2b87e",
"manifestSha256": "ee0897d46ee85126fbfd0d07f5ca3111950d0c36f9b8a80e4eb6ae85d226da4f",
"filesSha256": "b1f323fb41dec4f45992a30ff8726f3307f83b564127aff99bcb3d044c79d2bd",
"version": "1.1",
"build": "773ab2161d",
"manifestSha256": "c71ea15b519feb47a4fd33288fb92f2dcd40202fb2ce0a771fa408f9b4fbaf41",
"filesSha256": "a6bdf9b4273aabee50c3c94ceab4d0abee15f0df1af90c58bdbb796e0d2d5699",
"files": 5,
"dir": "model/contour-map"
},
{
"id": "earth-geography",
"version": "1.8",
"build": "3b645c45c2",
"manifestSha256": "a9f30fd4a1dd0aeccb88c892579c93bf32a92379d7b3f545b28f6cac612f9871",
"filesSha256": "0e55d2f9bacc3e0ff42f5c45d9e7c265864df9784b1609c09dcb32d21b4addfc",
"version": "1.9",
"build": "cc68b8863b",
"manifestSha256": "ae64033c7b46c51eb9c5f3dfb70a5491068c6cd608dec953eb34311cb8045d60",
"filesSha256": "c018ba481831e23d3183a38ac47251f19754c7464baa5d85b47cea7a49fcfa95",
"files": 11,
"dir": "model/earth-geography"
},
{
"id": "earth-revolution",
"version": "1.6",
"build": "947efa36bb",
"manifestSha256": "feb715cde8ad5da9ecfb48785a95e6fc82930cc92c668514b328915366c2f57a",
"filesSha256": "a37e0b493c78bb0a04a276512b612be3f8e7a178ed1a7fc72acb5353aa57f7c5",
"version": "1.7",
"build": "53b7a0fbc3",
"manifestSha256": "88e6f2f1bd2f7654d169745b96fa85aaea37671b6cdf8ed4fc05f7f259ae90bc",
"filesSha256": "4cd45b0324a77574a0da3a939c2a6faebc785c5a24cb50136d62a78a6ea2e9b1",
"files": 7,
"dir": "model/earth-revolution"
},
{
"id": "earth-rotation",
"version": "1.6",
"build": "a803d9c020",
"manifestSha256": "56ed397cbc008bd9ec8bea0ee34a94a28ab29ce39a8b096b0629e529883b4dff",
"filesSha256": "4e4428812d18d15a99105e73c027b99f3197033f0138d643ba69c15fabc9d8f6",
"version": "1.7",
"build": "ecd52665f9",
"manifestSha256": "9ac0050f65eedc833dd8daa8eb3b18400540269fd1a4b764ef771a357fb1cf0a",
"filesSha256": "594b005a6a9f36cd0b5d4e4a7a0b1ab42d53c8032832545b71c3915493d56c8e",
"files": 7,
"dir": "model/earth-rotation"
},
{
"id": "scale-calculator",
"version": "1.5",
"build": "02a555272a",
"manifestSha256": "d00034888d9b9da03338b7f394d1bdf33f73b1fbdd7e8f154d85b9080318ab13",
"filesSha256": "4a5fbf898df1d98eddf68b5d3929ae7b25cd7bcdfdfa36b5ad0ed72d9941d049",
"version": "1.6",
"build": "105653737d",
"manifestSha256": "05dcb4ec0a4a0cda66dbb633b8ea58e4f4f2de47b5c9557799ac317de874f2af",
"filesSha256": "732dd26406e0f1e836970499d7ea644def332ce909d7f8aa0a403bbe7337e604",
"files": 6,
"dir": "model/scale-calculator"
}
],
"signature": {
"alg": "ECDSA-P256-SHA256",
"keyId": "gc-2026-11",
"value": "LHaF2bw+IZeWUw2qLQM1IQHoNXsHNko38dyjP45Jy41KtlyhvJhhFaNh+THKhAU+6jSzV1eFHgbwasboYBOa5w==",
"contentSha256": "749055593bf9839837428d900d523b3363486556970cbf4e2daa25001ab174c8",
"signedAt": "2026-11-14T11:36:03Z"
}
]
}
+28 -35
View File
@@ -1,6 +1,6 @@
{
"schema": 1,
"generated": "2026-11-14T11:34:35Z",
"generated": "2026-11-18T04:35:15Z",
"repository": "https://gitcode.com/Morris_1/GC",
"branch": "main",
"modelDir": "model",
@@ -13,24 +13,24 @@
"dir": "dist/win-amd64",
"name": "GC-1.0.7-win-amd64.zip",
"url": "https://gitcode.com/Morris_1/GC/releases/download/v1.0.7/GC-1.0.7-win-amd64.zip",
"sha256": "f90ff51ac6b041ae238cbeb4672622b0d029142a9d8b0705f08e654336512308",
"size": 46363183
"sha256": "e9e0794206c6a0dfb8449ac30390ed788da72a5661d362af9f9a6e489cad0aad",
"size": 102382195
},
"win-arm64": {
"path": "dist/win-arm64/GC-1.0.7-win-arm64.zip",
"dir": "dist/win-arm64",
"name": "GC-1.0.7-win-arm64.zip",
"url": "https://gitcode.com/Morris_1/GC/releases/download/v1.0.7/GC-1.0.7-win-arm64.zip",
"sha256": "0b2bab2c3ac7e6223d8dd0b0faf9a0994319fa5ad13826addf7b402619b812e0",
"size": 44390354
"sha256": "11dd6aea480b7eb9d5d0e40c6e8ac7733b83756e37ec924cb98f5e46a531def1",
"size": 98435968
},
"osx-arm64": {
"path": "dist/mac-arm64/GC-1.0.7-mac-arm64.zip",
"dir": "dist/mac-arm64",
"name": "GC-1.0.7-mac-arm64.zip",
"url": "https://gitcode.com/Morris_1/GC/releases/download/v1.0.7/GC-1.0.7-mac-arm64.zip",
"sha256": "e5fd355bace68dc0794eb3e049cbef63c952a60a765ab3806adaf1199e1b09ab",
"size": 9178314
"sha256": "b085ffabf764ab57cc69a0192b47069479170f9494fb9f447230e74028794982",
"size": 60065859
},
"osx-x64": {
"path": "dist/mac-x64/GC-1.0.7-mac-x64.zip",
@@ -49,55 +49,48 @@
"models": [
{
"id": "contour-map",
"version": "1.0",
"build": "e4b3f2b87e",
"manifestSha256": "ee0897d46ee85126fbfd0d07f5ca3111950d0c36f9b8a80e4eb6ae85d226da4f",
"filesSha256": "b1f323fb41dec4f45992a30ff8726f3307f83b564127aff99bcb3d044c79d2bd",
"version": "1.1",
"build": "773ab2161d",
"manifestSha256": "c71ea15b519feb47a4fd33288fb92f2dcd40202fb2ce0a771fa408f9b4fbaf41",
"filesSha256": "a6bdf9b4273aabee50c3c94ceab4d0abee15f0df1af90c58bdbb796e0d2d5699",
"files": 5,
"dir": "model/contour-map"
},
{
"id": "earth-geography",
"version": "1.8",
"build": "3b645c45c2",
"manifestSha256": "a9f30fd4a1dd0aeccb88c892579c93bf32a92379d7b3f545b28f6cac612f9871",
"filesSha256": "0e55d2f9bacc3e0ff42f5c45d9e7c265864df9784b1609c09dcb32d21b4addfc",
"version": "1.9",
"build": "cc68b8863b",
"manifestSha256": "ae64033c7b46c51eb9c5f3dfb70a5491068c6cd608dec953eb34311cb8045d60",
"filesSha256": "c018ba481831e23d3183a38ac47251f19754c7464baa5d85b47cea7a49fcfa95",
"files": 11,
"dir": "model/earth-geography"
},
{
"id": "earth-revolution",
"version": "1.6",
"build": "947efa36bb",
"manifestSha256": "feb715cde8ad5da9ecfb48785a95e6fc82930cc92c668514b328915366c2f57a",
"filesSha256": "a37e0b493c78bb0a04a276512b612be3f8e7a178ed1a7fc72acb5353aa57f7c5",
"version": "1.7",
"build": "53b7a0fbc3",
"manifestSha256": "88e6f2f1bd2f7654d169745b96fa85aaea37671b6cdf8ed4fc05f7f259ae90bc",
"filesSha256": "4cd45b0324a77574a0da3a939c2a6faebc785c5a24cb50136d62a78a6ea2e9b1",
"files": 7,
"dir": "model/earth-revolution"
},
{
"id": "earth-rotation",
"version": "1.6",
"build": "a803d9c020",
"manifestSha256": "56ed397cbc008bd9ec8bea0ee34a94a28ab29ce39a8b096b0629e529883b4dff",
"filesSha256": "4e4428812d18d15a99105e73c027b99f3197033f0138d643ba69c15fabc9d8f6",
"version": "1.7",
"build": "ecd52665f9",
"manifestSha256": "9ac0050f65eedc833dd8daa8eb3b18400540269fd1a4b764ef771a357fb1cf0a",
"filesSha256": "594b005a6a9f36cd0b5d4e4a7a0b1ab42d53c8032832545b71c3915493d56c8e",
"files": 7,
"dir": "model/earth-rotation"
},
{
"id": "scale-calculator",
"version": "1.5",
"build": "02a555272a",
"manifestSha256": "d00034888d9b9da03338b7f394d1bdf33f73b1fbdd7e8f154d85b9080318ab13",
"filesSha256": "4a5fbf898df1d98eddf68b5d3929ae7b25cd7bcdfdfa36b5ad0ed72d9941d049",
"version": "1.6",
"build": "105653737d",
"manifestSha256": "05dcb4ec0a4a0cda66dbb633b8ea58e4f4f2de47b5c9557799ac317de874f2af",
"filesSha256": "732dd26406e0f1e836970499d7ea644def332ce909d7f8aa0a403bbe7337e604",
"files": 6,
"dir": "model/scale-calculator"
}
],
"signature": {
"alg": "ECDSA-P256-SHA256",
"keyId": "gc-2026-11",
"value": "LHaF2bw+IZeWUw2qLQM1IQHoNXsHNko38dyjP45Jy41KtlyhvJhhFaNh+THKhAU+6jSzV1eFHgbwasboYBOa5w==",
"contentSha256": "749055593bf9839837428d900d523b3363486556970cbf4e2daa25001ab174c8",
"signedAt": "2026-11-14T11:36:03Z"
}
]
}