fix: Improve Windows build scripts to properly execute electron-builder

- build-client.bat: Use node_modules\.bin\electron-builder.cmd directly
- build-all.ps1: Use direct path to electron-builder instead of npm run
- setup-backend.bat: Add UTF-8 support and use python -m pip

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
egg
2025-12-16 20:40:52 +08:00
parent 7d4fc69071
commit c19b4e8292
3 changed files with 605 additions and 567 deletions

View File

@@ -217,10 +217,20 @@ function Build-Electron {
exit 1
}
# 安裝依賴
if (-not (Test-Path "node_modules")) {
Write-Host " 安裝 npm 依賴..." -ForegroundColor Gray
npm install
# 總是執行 npm install 確保依賴完整
Write-Host " 安裝 npm 依賴..." -ForegroundColor Gray
npm install
if ($LASTEXITCODE -ne 0) {
Write-Err "npm install 失敗"
exit 1
}
# 確認 electron-builder 已安裝
$electronBuilderPath = Join-Path $ClientDir "node_modules\.bin\electron-builder.cmd"
if (-not (Test-Path $electronBuilderPath)) {
Write-Err "electron-builder 未安裝"
Write-Warn "請確認 package.json 中的 devDependencies 包含 electron-builder"
exit 1
}
# 建立 .env 如果不存在
@@ -230,12 +240,19 @@ function Build-Electron {
}
Write-Host " 執行 electron-builder..." -ForegroundColor Gray
npm run build -- --win
# 直接執行 node_modules 中的 electron-builder
& $electronBuilderPath --win
if ($LASTEXITCODE -ne 0) {
Write-Err "electron-builder 執行失敗"
exit 1
}
if (Test-Path "dist\*.exe") {
Write-OK "Electron 打包完成"
} else {
Write-Err "Electron 打包失敗"
Write-Err "Electron 打包失敗 - dist 目錄中找不到 exe 檔案"
exit 1
}
}