# 开发启动:后端 + Electron(端口见 .env 的 API_PORT) $Root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path) Set-Location $Root $port = & (Join-Path $Root "scripts\read-port.ps1") -Root $Root $py = Join-Path $Root ".venv\Scripts\python.exe" if (-not (Test-Path $py)) { $py = "python" } Write-Host "Starting backend on http://127.0.0.1:$port ..." Start-Process -FilePath $py -ArgumentList "backend\main.py" -WorkingDirectory $Root -WindowStyle Normal $deadline = (Get-Date).AddSeconds(30) while ((Get-Date) -lt $deadline) { try { $r = Invoke-RestMethod -Uri "http://127.0.0.1:$port/api/health" -TimeoutSec 2 if ($r.status -eq "ok") { break } } catch { Start-Sleep -Milliseconds 500 } } Write-Host "Starting Electron..." npm run electron