# ============================================================================= # v0.7.0 前端 dist 一键上传到生产 # ============================================================================= # 用途:打包 4 端 dist + scp 到生产 + 在生产解压 + 重载 nginx # 用法:在 Windows PowerShell 7+ 跑 .\upload-frontend-v0.7.0.ps1 # 前置:已 PuTTY 跳到堡垒机 → 再到生产(同一会话) # ============================================================================= $ErrorActionPreference = "Stop" $ProjectRoot = "D:\资料\03-项目开发\wecom_it_smart_desk-claude" $TarPath = "$env:TEMP\frontend-v0.7.0.tar.gz" $Server = "root@10.90.5.110" Write-Host "========================================" -ForegroundColor Cyan Write-Host " v0.7.0 前端 dist 一键上传" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" # 步骤 1:打包 4 端 dist Write-Host "[1/4] 打包 4 端 dist..." -ForegroundColor Yellow Set-Location $ProjectRoot & tar -czf $TarPath ` frontend-admin/dist ` frontend-agent/dist ` frontend-portal/dist ` frontend-h5/dist $Size = (Get-Item $TarPath).Length / 1MB Write-Host " OK: $TarPath ($([math]::Round($Size, 2)) MB)" -ForegroundColor Green # 步骤 2:scp 到生产 Write-Host "" Write-Host "[2/4] scp 到生产 $Server:/tmp/..." -ForegroundColor Yellow Write-Host " (会提示输入密码,用 PuTTY 的密码)" -ForegroundColor Gray & scp -o StrictHostKeyChecking=no -o ConnectTimeout=30 $TarPath "${Server}:/tmp/frontend-v0.7.0.tar.gz" if ($LASTEXITCODE -ne 0) { Write-Host " FAILED: scp 失败" -ForegroundColor Red exit 1 } Write-Host " OK" -ForegroundColor Green # 步骤 3:在生产解压(走 ssh,需要输密码) Write-Host "" Write-Host "[3/4] ssh 到生产解压到 nginx 挂载点..." -ForegroundColor Yellow Write-Host " (会再次提示输入密码)" -ForegroundColor Gray $RemoteCmd = @" cd /opt/wecom-it-desk && echo '解压前端...' && sudo tar -xzf /tmp/frontend-v0.7.0.tar.gz && echo '清理 tar 包...' && sudo rm /tmp/frontend-v0.7.0.tar.gz && echo '清理本地 tar 包...' && rm $TarPath && echo '========================================' && echo '前端 4 端 dist 已更新到生产!' && echo '========================================' "@ & ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 $Server $RemoteCmd if ($LASTEXITCODE -ne 0) { Write-Host " FAILED: ssh 解压失败" -ForegroundColor Red exit 1 } Write-Host "" Write-Host "[4/4] 完成!" -ForegroundColor Green Write-Host "下一步:在生产跑 nginx 脱敏配置 + reload" -ForegroundColor Cyan Write-Host "详见 docs/DEPLOY-QUICK-v0.7.0.md Step 5-6" -ForegroundColor Cyan