43 lines
1.4 KiB
PowerShell
43 lines
1.4 KiB
PowerShell
# Windows 本地开发:隧道 + FastAPI + Next.js
|
||
# 用法:powershell -ExecutionPolicy Bypass -File scripts/dev-windows.ps1
|
||
|
||
$ErrorActionPreference = "Stop"
|
||
$Root = Split-Path -Parent $PSScriptRoot
|
||
Set-Location $Root
|
||
|
||
Write-Host "==> NomadCNA Windows 本地开发(连线上 nomadro.cn 服务)" -ForegroundColor Cyan
|
||
Write-Host " 1. SSH 隧道 MinIO 127.0.0.1:9100"
|
||
Write-Host " 2. FastAPI http://127.0.0.1:8000"
|
||
Write-Host " 3. Next.js http://localhost:3001"
|
||
Write-Host ""
|
||
|
||
if (-not (Test-Path "backend\.venv")) {
|
||
Write-Host "创建 Python 虚拟环境..." -ForegroundColor Yellow
|
||
python -m venv backend\.venv
|
||
& backend\.venv\Scripts\pip install -r backend\requirements.txt
|
||
}
|
||
|
||
Write-Host "启动 SSH 隧道(后台)..." -ForegroundColor Green
|
||
$tunnelJob = Start-Job -ScriptBlock {
|
||
Set-Location $using:Root
|
||
python scripts/dev-tunnel.py
|
||
}
|
||
Start-Sleep -Seconds 2
|
||
|
||
Write-Host "启动 FastAPI(后台)..." -ForegroundColor Green
|
||
$apiJob = Start-Job -ScriptBlock {
|
||
Set-Location $using:Root
|
||
& backend\.venv\Scripts\uvicorn backend.main:app --host 127.0.0.1 --port 8000 --reload
|
||
}
|
||
Start-Sleep -Seconds 2
|
||
|
||
Write-Host "启动 Next.js(前台)..." -ForegroundColor Green
|
||
try {
|
||
pnpm dev
|
||
}
|
||
finally {
|
||
Write-Host "停止后台服务..." -ForegroundColor Yellow
|
||
Stop-Job $tunnelJob, $apiJob -ErrorAction SilentlyContinue
|
||
Remove-Job $tunnelJob, $apiJob -Force -ErrorAction SilentlyContinue
|
||
}
|