From e47251658bcb920b151e77616282193368734d92 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Wed, 9 Sep 2026 19:15:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(console):=20=E9=BB=98=E8=AE=A4=E7=AB=AF?= =?UTF-8?q?=E5=8F=A3=E6=94=B9=2019540=EF=BC=9B=E6=89=93=E5=8C=85=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E6=89=8B=E5=8A=A8=E7=BB=84=E8=A3=85=E4=BE=BF=E6=90=BA?= =?UTF-8?q?=E7=89=88=EF=BC=88=E4=B8=8D=E4=BE=9D=E8=B5=96=20GitHub=20?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- console/main/config.js | 2 +- deploy/build.bat | 59 +++++++++++++++++++++++++++++++++++++----- 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/console/main/config.js b/console/main/config.js index 4b5e886..14dc685 100644 --- a/console/main/config.js +++ b/console/main/config.js @@ -10,7 +10,7 @@ const DEFAULTS = { exe: 'scoreboard.exe', args: ['-config', 'config.yaml'], host: '127.0.0.1', - port: 8080, + port: 19540, autoStart: true, healthIntervalMs: 5000, restartDelayMs: 3000, diff --git a/deploy/build.bat b/deploy/build.bat index b8c1e21..8d96fa4 100644 --- a/deploy/build.bat +++ b/deploy/build.bat @@ -1,28 +1,73 @@ @echo off REM 在 Windows 构建机(Meowhome)上一键构建 Windows 产物。 -REM 产物:dist\scoreboard.exe(前端已由 go:embed 内嵌) +REM 产物: +REM dist\scoreboard.exe 服务端(前端已 go:embed 内嵌) +REM dist\console\ScoreboardConsole\ 便携版 GUI 管理器(双击即用,免安装) +REM +REM 说明:不用 electron-builder 的 NSIS 打包,因为它会从 GitHub 下载签名工具, +REM 离线/受限网络下必失败。改为手动组装便携版:Electron 运行时 + resources\app。 setlocal +REM Electron 版本必须与 console\package.json 的 devDependencies.electron 一致(锁在 console\pnpm-lock.yaml) +set "ELECTRON_VERSION=38.8.6" +set "ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron" +set "CONSOLE_OUT=dist\console\ScoreboardConsole" + cd /d "%~dp0.." -echo === [1/4] git pull === +echo === [1/5] git pull === git pull || exit /b 1 -echo === [2/4] pnpm install === +echo === [2/5] 前端依赖与构建 === cd web call pnpm install --frozen-lockfile || exit /b 1 - -echo === [3/4] 前端构建(输出到 server\internal\webui\assets) === call pnpm build || exit /b 1 cd .. -echo === [4/4] go build === +echo === [3/5] 服务端构建 === cd server if not exist ..\dist mkdir ..\dist go build -o ..\dist\scoreboard.exe . || exit /b 1 cd .. +echo === [4/5] Console 依赖 + Electron 二进制 === +cd console +call pnpm install --frozen-lockfile || exit /b 1 +call :ensure_electron || exit /b 1 +cd .. + +echo === [5/5] 组装便携版 Console === +rmdir /s /q "%CONSOLE_OUT%" 2>nul +mkdir "%CONSOLE_OUT%" || exit /b 1 +xcopy /e /i /y "console\node_modules\electron\dist" "%CONSOLE_OUT%" >nul || exit /b 1 +mkdir "%CONSOLE_OUT%\resources\app" 2>nul +xcopy /e /i /y "console\main" "%CONSOLE_OUT%\resources\app\main" >nul || exit /b 1 +xcopy /e /i /y "console\renderer" "%CONSOLE_OUT%\resources\app\renderer" >nul || exit /b 1 +copy /y "console\package.json" "%CONSOLE_OUT%\resources\app\package.json" >nul || exit /b 1 +REM config.json 必须放在 exe 同级(Console 按 exe 目录解析配置) +copy /y "console\config.json" "%CONSOLE_OUT%\config.json" >nul || exit /b 1 +copy /y "dist\scoreboard.exe" "%CONSOLE_OUT%\scoreboard.exe" >nul || exit /b 1 +copy /y "config.yaml" "%CONSOLE_OUT%\config.yaml" >nul || exit /b 1 +ren "%CONSOLE_OUT%\electron.exe" "Scoreboard Console.exe" || exit /b 1 + echo. echo === 构建完成 === -dir dist +echo dist\scoreboard.exe 服务端 +echo %CONSOLE_OUT%\Scoreboard Console.exe GUI 管理器(双击运行) +dir "%CONSOLE_OUT%" endlocal +exit /b 0 + +REM ---- 确保 Electron 二进制就位(pnpm 默认跳过 postinstall) ------------------- +:ensure_electron +if exist node_modules\electron\dist\electron.exe ( + echo Electron 二进制已就绪 + exit /b 0 +) +echo 下载 Electron %ELECTRON_VERSION% ... +curl -L --fail --max-time 900 -o electron-dl.zip "%ELECTRON_MIRROR%/%ELECTRON_VERSION%/electron-v%ELECTRON_VERSION%-win32-x64.zip" || exit /b 1 +powershell -NoProfile -Command "Expand-Archive -LiteralPath 'electron-dl.zip' -DestinationPath 'node_modules/electron/dist' -Force" || exit /b 1 +del /q electron-dl.zip +echo electron.exe> node_modules\electron\path.txt +echo Electron 二进制已放置 +exit /b 0