69 lines
2.8 KiB
PowerShell
69 lines
2.8 KiB
PowerShell
|
|
# ngrok外网访问启动脚本
|
|||
|
|
|
|||
|
|
Write-Host "🚀 正在启动ngrok外网访问服务..." -ForegroundColor Green
|
|||
|
|
Write-Host ""
|
|||
|
|
|
|||
|
|
# 检查ngrok是否存在
|
|||
|
|
if (-not (Test-Path "ngrok.exe")) {
|
|||
|
|
Write-Host "❌ 错误:ngrok.exe 不存在,请先下载ngrok" -ForegroundColor Red
|
|||
|
|
Read-Host "按任意键退出"
|
|||
|
|
exit 1
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Write-Host "请确保您已经:" -ForegroundColor Yellow
|
|||
|
|
Write-Host "1. 注册了ngrok账号" -ForegroundColor White
|
|||
|
|
Write-Host "2. 获取了authtoken" -ForegroundColor White
|
|||
|
|
Write-Host "3. 运行了:ngrok authtoken YOUR_AUTH_TOKEN" -ForegroundColor White
|
|||
|
|
Write-Host ""
|
|||
|
|
|
|||
|
|
Write-Host "选择要启动的服务:" -ForegroundColor Cyan
|
|||
|
|
Write-Host "1. 前端服务 (端口5300)" -ForegroundColor White
|
|||
|
|
Write-Host "2. 后端服务 (端口5350)" -ForegroundColor White
|
|||
|
|
Write-Host "3. 同时启动前端和后端" -ForegroundColor White
|
|||
|
|
Write-Host "4. 检查当前服务状态" -ForegroundColor White
|
|||
|
|
Write-Host ""
|
|||
|
|
|
|||
|
|
$choice = Read-Host "请输入选择 (1-4)"
|
|||
|
|
|
|||
|
|
switch ($choice) {
|
|||
|
|
"1" {
|
|||
|
|
Write-Host "启动前端服务穿透..." -ForegroundColor Green
|
|||
|
|
Write-Host "访问地址将在新窗口中显示" -ForegroundColor Yellow
|
|||
|
|
Start-Process -FilePath ".\ngrok.exe" -ArgumentList "http", "5300"
|
|||
|
|
}
|
|||
|
|
"2" {
|
|||
|
|
Write-Host "启动后端服务穿透..." -ForegroundColor Green
|
|||
|
|
Write-Host "访问地址将在新窗口中显示" -ForegroundColor Yellow
|
|||
|
|
Start-Process -FilePath ".\ngrok.exe" -ArgumentList "http", "5350"
|
|||
|
|
}
|
|||
|
|
"3" {
|
|||
|
|
Write-Host "启动前端服务穿透..." -ForegroundColor Green
|
|||
|
|
Start-Process -FilePath ".\ngrok.exe" -ArgumentList "http", "5300"
|
|||
|
|
Start-Sleep -Seconds 3
|
|||
|
|
Write-Host "启动后端服务穿透..." -ForegroundColor Green
|
|||
|
|
Start-Process -FilePath ".\ngrok.exe" -ArgumentList "http", "5350"
|
|||
|
|
Write-Host ""
|
|||
|
|
Write-Host "✅ 两个服务都已启动,请查看各自的窗口获取访问地址" -ForegroundColor Green
|
|||
|
|
}
|
|||
|
|
"4" {
|
|||
|
|
Write-Host "检查当前服务状态..." -ForegroundColor Cyan
|
|||
|
|
Write-Host "前端服务 (端口5300):" -ForegroundColor Yellow
|
|||
|
|
netstat -ano | findstr :5300
|
|||
|
|
Write-Host ""
|
|||
|
|
Write-Host "后端服务 (端口5350):" -ForegroundColor Yellow
|
|||
|
|
netstat -ano | findstr :5350
|
|||
|
|
}
|
|||
|
|
default {
|
|||
|
|
Write-Host "❌ 无效选择,请重新运行脚本" -ForegroundColor Red
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Write-Host ""
|
|||
|
|
Write-Host "💡 提示:" -ForegroundColor Cyan
|
|||
|
|
Write-Host "- 前端访问地址格式:https://xxxxx.ngrok.io" -ForegroundColor White
|
|||
|
|
Write-Host "- 后端访问地址格式:https://yyyyy.ngrok.io" -ForegroundColor White
|
|||
|
|
Write-Host "- API文档地址:https://yyyyy.ngrok.io/api-docs" -ForegroundColor White
|
|||
|
|
Write-Host ""
|
|||
|
|
|
|||
|
|
Read-Host "按任意键退出"
|