run_frontend.ps1 775 B

1234567891011121314151617181920212223242526272829303132
  1. Param(
  2. [string]$ApiBaseUrl = "http://localhost:8000",
  3. [int]$Port = 5173
  4. )
  5. Set-Location -Path $PSScriptRoot
  6. Write-Host "========================================"
  7. Write-Host "启动 AI Swap 前端 (PowerShell)"
  8. Write-Host "DIR: $PSScriptRoot"
  9. Write-Host "VITE_API_BASE_URL: $ApiBaseUrl"
  10. Write-Host "PORT: $Port"
  11. Write-Host "========================================"
  12. # 写入/更新 .env.local
  13. Set-Content -Path ".env.local" -Value "VITE_API_BASE_URL=$ApiBaseUrl"
  14. # 安装依赖并构建(如已构建可跳过)
  15. # try {
  16. # npm ci | Out-Host
  17. # } catch {
  18. # yarn install | Out-Host
  19. # }
  20. # npm run build | Out-Host
  21. # 0.0.0.0:$Port 预览
  22. npm run preview
  23. # 运行本脚本命令
  24. # ./frontend/run_frontend.ps1 -ApiBaseUrl http://ai-swap.local:8000 -Port 5173