交互原型大版本
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# EPEEKit 内网穿透启动脚本
|
||||
# EPEEKit 内网穿透启动脚本
|
||||
# 使用 Cloudflare Quick Tunnel(无需账号,免费)
|
||||
# 用法:在 PowerShell 中执行 .\start-tunnel.ps1
|
||||
|
||||
@@ -9,6 +9,12 @@ param(
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# 优先使用与本脚本同目录的 cloudflared.exe(避免未安装 / 未加入 PATH)
|
||||
$LocalCf = Join-Path $PSScriptRoot "cloudflared.exe"
|
||||
if (Test-Path -LiteralPath $LocalCf) {
|
||||
$env:Path = "$PSScriptRoot;$env:Path"
|
||||
}
|
||||
|
||||
# 检查 cloudflared 是否可用
|
||||
try {
|
||||
$null = Get-Command cloudflared -ErrorAction Stop
|
||||
@@ -52,14 +58,15 @@ if (-not $backendUrl) {
|
||||
|
||||
Write-Host " 后端穿透地址: $backendUrl" -ForegroundColor Green
|
||||
|
||||
# 更新前端环境变量
|
||||
# 更新前端环境变量(避免 PS5.1 对 UTF-8 here-string 解析问题,改用 WriteAllLines)
|
||||
$envFile = Join-Path $PSScriptRoot "frontend\.env.local"
|
||||
@"
|
||||
# 后端 API 地址(由 start-tunnel.ps1 自动更新)
|
||||
NEXT_PUBLIC_API_URL=$backendUrl
|
||||
"@ | Set-Content $envFile -Encoding UTF8
|
||||
$envLines = @(
|
||||
"# Backend API URL (updated by start-tunnel.ps1)"
|
||||
"NEXT_PUBLIC_API_URL=$backendUrl"
|
||||
)
|
||||
[System.IO.File]::WriteAllLines($envFile, $envLines, [System.Text.UTF8Encoding]::new($false))
|
||||
|
||||
Write-Host " 已更新 frontend\.env.local" -ForegroundColor Green
|
||||
Write-Host " Updated frontend\.env.local" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
# 启动前端穿透
|
||||
@@ -123,11 +130,12 @@ try {
|
||||
Stop-Process -Id $frontendTunnel.Id -Force -ErrorAction SilentlyContinue
|
||||
|
||||
# 恢复 .env.local 为 localhost
|
||||
@"
|
||||
# 后端 API 地址
|
||||
NEXT_PUBLIC_API_URL=http://localhost:8000
|
||||
"@ | Set-Content $envFile -Encoding UTF8
|
||||
$restoreLines = @(
|
||||
"# Backend API URL"
|
||||
"NEXT_PUBLIC_API_URL=http://localhost:8000"
|
||||
)
|
||||
[System.IO.File]::WriteAllLines($envFile, $restoreLines, [System.Text.UTF8Encoding]::new($false))
|
||||
|
||||
Write-Host "已恢复 .env.local 为 localhost" -ForegroundColor Green
|
||||
Write-Host "Restored .env.local to localhost" -ForegroundColor Green
|
||||
Write-Host "隧道已关闭" -ForegroundColor Green
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user