Files
Scoreboard/deploy/build.bat
T
AskaEth 6483acf9ad feat: 人员年龄/号码布、图片上传、多显示器菜单、Console 两栏、exe 改名等一批改动
人员与报名:
- 人员唯一标识改为「证件号 或 号码布」二选一(0013/0014 迁移 + 导入匹配/回填/冲突)
- 人员新增「年龄」(0015 迁移):表单/列表/导入模板表头 11 列;冲突比较只在两边
  都有值且不同时才算差异,旧数据不误报
- 冲突决策键改为「证件号优先 → 号码布」(前端原先只用 idCard,号码布行会互相覆盖)
- 报名选择器支持无证件号但有号码布的运动员

大屏与 Console:
- 大屏控制新增「显示器」菜单:可给指定显示器重建全屏窗口;单屏/主显示器强制窗口化,
  限制在 Console 侧判定,不信任页面传参
- Console 服务管理窗口改左右两栏,运行日志独占右栏满高;窗口默认尺寸 1280×860
- 大屏右上角时钟精确到秒(同时把刷新间隔 15s 改为 1s)

图片与配置:
- 新增图片上传 POST /api/uploads(recorder+,png/jpg/webp/gif,≤5MiB)与匿名静态
  访问 GET /uploads/{name}(防目录穿越);文件落赛事项目目录 uploads/,随赛事包
  一起导出/导入
- 「赛事信息」新增赛事会标 / 大屏会标 / 大屏背景图三个上传项
- 参赛单位 logo 输入框右侧加上传按钮

关于页与构建:
- 构建时间打通:version.BuildTime + /api/system/about 返回 + build.bat 注入
  (用 PowerShell 取时间戳,避免本地化 %DATE% 的非 ASCII 星期)

安装包:
- 主程序改名 Scoreboard_Console.exe(win.executableName;productName/显示名不变)
- 记住上次安装目录:自定义 NSIS 宏优先沿用自存路径(卸载不清除),并在 customInit
  里补写回 electron-builder 的键,避免安装模式页把 $INSTDIR 打回默认

自检:服务端 12 包全绿;前端 vue-tsc + build 通过、node --test 58/58;console 12 文件通过。
2026-09-10 09:05:06 +08:00

100 lines
4.6 KiB
Batchfile

@echo off
chcp 65001 >nul
REM Build Windows artifacts on the build machine (Meowhome).
REM Output:
REM dist\scoreboard.exe server (frontend embedded via go:embed)
REM dist\console\ Scoreboard Console installer + portable dir
REM
REM IMPORTANT: keep this file ASCII-only. cmd.exe mis-parses UTF-8 non-ASCII text
REM inside batch files (especially inside if(...) blocks). Anything that needs a
REM non-ASCII path is done by a Node script under deploy\.
setlocal
REM electron / electron-builder downloads: use mirrors so GitHub is reachable
set "ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/"
set "ELECTRON_BUILDER_BINARIES_MIRROR=https://gh-proxy.com/https://github.com/electron-userland/electron-builder-binaries/releases/download/"
set "CSC_IDENTITY_AUTO_DISCOVERY=false"
cd /d "%~dp0.."
echo === [1/4] git pull ===
git pull || exit /b 1
echo === [2/4] web deps + build ===
cd web
call pnpm install --frozen-lockfile || exit /b 1
call pnpm build || exit /b 1
cd ..
echo === [3/4] server build ===
cd server
if not exist ..\dist mkdir ..\dist
REM internal signature is injected from a machine-local file (gitignored, never in repo).
REM set /p returns empty under chcp 65001; PowerShell piping re-encodes the text and
REM corrupts non-ASCII. So a Node script normalizes it (BOM/whitespace stripped) into
REM deploy\signature.build.txt, and for /f reads that file directly (no re-encoding).
node ..\deploy\prepare-signature.mjs || exit /b 1
set "INTERNAL_SIGNATURE="
if exist "..\deploy\signature.build.txt" for /f "usebackq delims= eol=" %%A in ("..\deploy\signature.build.txt") do if not defined INTERNAL_SIGNATURE set "INTERNAL_SIGNATURE=%%A"
REM build time for the About page. Do NOT use %DATE%/%TIME%: a localized Windows
REM prints non-ASCII weekday names, which cmd mis-parses (see the header note).
set "BUILD_TIME="
for /f "usebackq delims=" %%T in (`powershell -NoProfile -Command "(Get-Date).ToString('yyyy-MM-dd HH:mm:ss')"`) do if not defined BUILD_TIME set "BUILD_TIME=%%T"
set "BUILD_TIME_LDFLAG=-X 'git.yeij.top/AskaEth/Scoreboard/server/internal/version.BuildTime=%BUILD_TIME%'"
if defined INTERNAL_SIGNATURE (
REM single quotes keep spaces inside the value intact for go's ldflags parser
go build -ldflags "-X 'git.yeij.top/AskaEth/Scoreboard/server/internal/version.InternalSignature=%INTERNAL_SIGNATURE%' %BUILD_TIME_LDFLAG%" -o ..\dist\scoreboard.exe . || exit /b 1
node ..\deploy\verify-signature.mjs || exit /b 1
echo internal signature injected
) else (
go build -ldflags "%BUILD_TIME_LDFLAG%" -o ..\dist\scoreboard.exe . || exit /b 1
echo no internal signature
)
echo build time %BUILD_TIME%
cd ..
echo === [4/4] console package (electron-builder) ===
REM win.icon is written into the PE resources by electron-builder (via rcedit);
REM it needs winCodeSign / nsis, fetched through the gh proxy above.
taskkill /im "Scoreboard_Console.exe" /f >nul 2>&1
REM builds from before the exe rename used a space in the file name - kill that too
taskkill /im "Scoreboard Console.exe" /f >nul 2>&1
taskkill /im scoreboard.exe /f >nul 2>&1
if not exist "rules" (
echo [ERROR] rules dir missing - electron-builder extraFiles needs it
exit /b 1
)
node deploy\prepare-extra.mjs || exit /b 1
cd console
REM console\pnpm-workspace.yaml uses allowBuilds so electron's install script is
REM allowed to run; do NOT add --ignore-scripts here, it makes pnpm run fail its
REM dependency check with ERR_PNPM_IGNORED_BUILDS.
REM Keep this file ASCII-only: cmd.exe mis-parses UTF-8 text inside .bat files.
call pnpm install --frozen-lockfile || exit /b 1
call :ensure_electron || exit /b 1
call pnpm run dist || exit /b 1
cd ..
echo.
echo === BUILD OK ===
echo dist\scoreboard.exe server
echo dist\console\ console installer + portable dir
dir /b dist\console
endlocal
exit /b 0
REM ---- ensure the electron runtime binary is present (fallback for mirror failures) --
:ensure_electron
REM path.txt tells the electron package where the binary is; without it
REM electron-builder tries to download the runtime and hits a Node 24 bug.
if not exist node_modules\electron\path.txt echo electron.exe> node_modules\electron\path.txt
if exist node_modules\electron\dist\electron.exe exit /b 0
set "EV=38.8.6"
echo downloading electron %EV% ...
curl -L --fail --max-time 900 -o electron-dl.zip "%ELECTRON_MIRROR%%EV%/electron-v%EV%-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 runtime ready
exit /b 0