diff --git a/client/src/main.js b/client/src/main.js index 88c3c4e..1700bd5 100644 --- a/client/src/main.js +++ b/client/src/main.js @@ -43,7 +43,12 @@ function loadConfig() { console.log(`Checking: ${configPath} - exists: ${exists}`); try { if (exists) { - const configData = fs.readFileSync(configPath, "utf-8"); + // Use utf-8 and strip BOM if present (Windows Notepad adds BOM) + let configData = fs.readFileSync(configPath, "utf-8"); + // Remove UTF-8 BOM if present + if (configData.charCodeAt(0) === 0xFEFF) { + configData = configData.slice(1); + } appConfig = JSON.parse(configData); console.log("Config loaded from:", configPath); console.log("Config content:", JSON.stringify(appConfig, null, 2)); diff --git a/scripts/build-client.bat b/scripts/build-client.bat index 5c6d9e1..b0b1fbb 100644 --- a/scripts/build-client.bat +++ b/scripts/build-client.bat @@ -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 設定失敗