fix: Handle UTF-8 BOM in config loading and build script
- main.js: Strip UTF-8 BOM when reading config.json - build-client.bat: Write config.json without BOM using [System.Text.UTF8Encoding]::new($false) PowerShell's -Encoding UTF8 writes BOM by default, which can cause JSON parsing issues in Node.js. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -313,8 +313,8 @@ if not exist "%CONFIG_FILE%" (
|
||||
goto :eof
|
||||
)
|
||||
|
||||
REM 使用 PowerShell 更新 backend.embedded = true
|
||||
powershell -Command "$config = Get-Content '%CONFIG_FILE%' -Raw | ConvertFrom-Json; if (-not $config.backend) { $config | Add-Member -NotePropertyName 'backend' -NotePropertyValue @{} }; $config.backend.embedded = $true; $config | ConvertTo-Json -Depth 10 | Set-Content '%CONFIG_FILE%' -Encoding UTF8"
|
||||
REM 使用 PowerShell 更新 backend.embedded = true (使用 UTF8 without BOM)
|
||||
powershell -Command "$config = Get-Content '%CONFIG_FILE%' -Raw | ConvertFrom-Json; if (-not $config.backend) { $config | Add-Member -NotePropertyName 'backend' -NotePropertyValue @{} }; $config.backend.embedded = $true; $json = $config | ConvertTo-Json -Depth 10; [System.IO.File]::WriteAllText('%CONFIG_FILE%', $json, [System.Text.UTF8Encoding]::new($false))"
|
||||
|
||||
if errorlevel 1 (
|
||||
echo %RED%[ERROR]%NC% 更新 config.json embedded 設定失敗
|
||||
|
||||
Reference in New Issue
Block a user