From 80e79f8dc709da257aec96d9ae2a5f9617c78b19 Mon Sep 17 00:00:00 2001 From: JianFeeeee Date: Tue, 27 Oct 2026 00:45:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(gui):=20Windows=20=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E9=93=BE=E6=94=B9=E7=94=A8=20modelrouter=20=E5=91=BD=E5=90=8D?= =?UTF-8?q?=20+=20=E5=86=85=E5=B5=8C=E6=A0=B8=E5=BF=83=20strip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 改名在桌面打包链上漏了两处,都是"构建能过、产物不可用"的类型: 1. `dist-win-docker.sh` 仍交叉编译到 `bin/llmsproxy.exe` 并构建 `./cmd/llmsproxy`,而 package.json 的 extraResources 已指向 `bin/modelrouter.exe` —— Windows 包装完会缺内嵌核心。 同时把 npmmirror 的 electron / electron-builder-binaries 镜像传进容器: 首次构建需在容器内下载数百 MB,直连会卡满 600s 请求超时(Linux 侧已实测)。 2. `prepare-core.js` 只带 `-trimpath`,内嵌核心保留调试符号(14.4MB)。 补 `-ldflags "-s -w"`,与 `packaging/core-dist.sh` 一致,各平台安装包少约 4MB。 --- cmd/gui/scripts/dist-win-docker.sh | 6 ++++-- cmd/gui/scripts/prepare-core.js | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/gui/scripts/dist-win-docker.sh b/cmd/gui/scripts/dist-win-docker.sh index 527b000..e6bc6f1 100755 --- a/cmd/gui/scripts/dist-win-docker.sh +++ b/cmd/gui/scripts/dist-win-docker.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # One-shot Windows release build for the GUI — ENTIRELY inside docker. # -# 1) cross-compile the embedded core in docker (llmsproxy.exe + lua51.dll) +# 1) cross-compile the embedded core in docker (modelrouter.exe + lua51.dll) # 2) electron-builder NSIS packaging ALSO inside docker (wine for the # uninstaller step lives in the image — see Dockerfile). This is the fix # for the 1.3.0/1.4.0 broken installers: the host had amd64-only wine @@ -37,13 +37,15 @@ docker run --rm \ -v "$ROOT":/workspace \ -v "$CACHE_VOL":/root/.cache \ -e GOPROXY="$PROXY" \ + -e ELECTRON_MIRROR="https://npmmirror.com/mirrors/electron/" \ + -e ELECTRON_BUILDER_BINARIES_MIRROR="https://npmmirror.com/mirrors/electron-builder-binaries/" \ -w /workspace \ "$IMAGE" bash -c ' set -euo pipefail cp /opt/luajit2/src/lua51.dll /workspace/cmd/gui/bin/lua51.dll GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc \ go build -buildvcs=false -tags luajit -trimpath \ - -o /workspace/cmd/gui/bin/llmsproxy.exe ./cmd/llmsproxy + -o /workspace/cmd/gui/bin/modelrouter.exe ./cmd/modelrouter echo " -> core built" # wine needs one prefix initialization so its wow64 runtime (syswow64/ntdll) # exists — the exact thing that was missing on the broken host. Use a shared diff --git a/cmd/gui/scripts/prepare-core.js b/cmd/gui/scripts/prepare-core.js index 1accfe3..79111c6 100644 --- a/cmd/gui/scripts/prepare-core.js +++ b/cmd/gui/scripts/prepare-core.js @@ -17,7 +17,10 @@ function buildLinux() { fs.mkdirSync(binDir, { recursive: true }); execFileSync( "go", - ["build", "-tags", "luajit", "-trimpath", "-o", out, "./cmd/modelrouter"], + // -s -w: same stripping as packaging/core-dist.sh. Without it the bundled + // core carries debug info (~14.4 MB vs ~10.3 MB) and every installer pays + // for it, for a binary the user never debugs. + ["build", "-tags", "luajit", "-trimpath", "-ldflags", "-s -w", "-o", out, "./cmd/modelrouter"], { cwd: projectRoot, stdio: "inherit" }, ); return out; @@ -43,7 +46,7 @@ function buildWin() { } execFileSync( "go", - ["build", "-tags", "luajit", "-trimpath", "-o", out, "./cmd/modelrouter"], + ["build", "-tags", "luajit", "-trimpath", "-ldflags", "-s -w", "-o", out, "./cmd/modelrouter"], { cwd: projectRoot, stdio: "inherit",