# ============================================================================ # REQ-会话-001 v1.2 一键部署脚本 # 用途:从本地代码 commit 到 H5 生产环境上线全流程 # 用法:在 Windows Terminal(PowerShell)执行 `.\deploy-v1.2.ps1` # 前提:v2_ops.py status 显示 cache 有效,否则先跑 `login` # ============================================================================ #Requires -Version 5.1 # 配置区(按需修改) =========================================================== $WORK_DIR = "D:\资料\03-项目开发\wecom_it_smart_desk" $ASCII_COPY = "D:\dev\wecom" $FRONTEND_BUILD_DIR = "$ASCII_COPY\src\frontend-h5" $PACKAGE_DIR = "$ASCII_COPY\packages" $PYTHON_BIN = "C:\Users\simon\.workbuddy\binaries\python\versions\3.13.12\python.exe" $V2_OPS = "C:\Users\simon\.workbuddy\skills\jumpserver-V2\scripts\v2_ops.py" $DEPLOY_REMOTE_DIR = "/opt/wecom-it-desk/frontend-h5" $TMP_ZIP_NAME = "h5-dist-v1.2.zip" $H5_URL = "https://itsupport.servyou.com.cn/h5/" # ============================================================================ # Step 1:本地代码 commit # ============================================================================ Write-Host "`n[Step 1/6] 本地代码 commit..." -ForegroundColor Cyan Set-Location $WORK_DIR $gitStatus = git status --short if ([string]::IsNullOrWhiteSpace($gitStatus)) { Write-Host " ℹ️ 无新改动(可能已 commit),跳过 commit 步骤" -ForegroundColor Yellow } else { Write-Host " 待提交文件:" -ForegroundColor Gray Write-Host $gitStatus git add -A git commit -M "[REQ-会话-001] 员工结束会话 v1.2:6 态按钮 + 4 种引导语 + 顶部按钮 AI 场景互斥 + 重新打开按钮 - InputBar.vue: 6 态扩展(移除 hidden / 恢复 end / 新增 reopen) - ChatPanel.vue: 顶部按钮 v-show + 文案修订 - conversation.ts (store): showHeaderExitBtn + canReopen + reopenCurrentConversation - conversation.ts (api): ConversationInfo + resolved_at - inputBarGuideText.ts: 新增 helper(避免 P1 Bug 回归) - 测试: 23 store + 15 helper = 38 用例全 PASS QA 第 1 轮发现 P1 Bug(InputBar.vue:337 误用 'active' 而非 'ai_handling'), 抽离 helper 修复并加 2 个回归保护用例。AC1-AC11 全部 PASS(含修复后)。" if ($LASTEXITCODE -ne 0) { Write-Host " ❌ commit 失败,请检查 git 状态" -ForegroundColor Red exit 1 } Write-Host " ✅ commit 成功" -ForegroundColor Green } # ============================================================================ # Step 2:代码同步到 ASCII 副本 + 前端 build + 打包 # ============================================================================ Write-Host "`n[Step 2/6] 同步代码到 ASCII 副本 + 前端 build..." -ForegroundColor Cyan if (-not (Test-Path $ASCII_COPY)) { Write-Host " ❌ ASCII 副本路径不存在: $ASCII_COPY" -ForegroundColor Red exit 1 } # 同步 src/frontend-h5/src(排除 node_modules 和 dist) robocopy "$WORK_DIR\src\frontend-h5\src" "$FRONTEND_BUILD_DIR\src" /MIR /XD node_modules dist /NFL /NDL /NJH /NJS | Out-Null robocopy "$WORK_DIR\src\frontend-h5\package.json" "$FRONTEND_BUILD_DIR\package.json" /NFL /NDL /NJH /NJS | Out-Null # build Set-Location $FRONTEND_BUILD_DIR npm run build 2>&1 | Out-Null if ($LASTEXITCODE -ne 0) { Write-Host " ❌ npm run build 失败" -ForegroundColor Red exit 1 } Write-Host " ✅ 前端 build 成功" -ForegroundColor Green # 打包 if (-not (Test-Path $PACKAGE_DIR)) { New-Item -ItemType Directory -Path $PACKAGE_DIR -Force | Out-Null } Compress-Archive -Path "$FRONTEND_BUILD_DIR\dist" -DestinationPath "$PACKAGE_DIR\$TMP_ZIP_NAME" -Force Write-Host " ✅ 打包完成: $PACKAGE_DIR\$TMP_ZIP_NAME" -ForegroundColor Green # ============================================================================ # Step 3:上传到 SFTP 虚拟路径 /tmp # ============================================================================ Write-Host "`n[Step 3/6] 上传到 SFTP 虚拟路径..." -ForegroundColor Cyan & $PYTHON_BIN $V2_OPS upload "$PACKAGE_DIR\$TMP_ZIP_NAME" $TMP_ZIP_NAME if ($LASTEXITCODE -ne 0) { Write-Host " ❌ 上传失败" -ForegroundColor Red exit 1 } Write-Host " ✅ 上传成功" -ForegroundColor Green # ============================================================================ # Step 4:服务器侧部署 # ============================================================================ Write-Host "`n[Step 4/6] 服务器侧部署..." -ForegroundColor Cyan $deployCmdsPath = "$ASCII_COPY\deploy_cmds_v1.2.txt" if (-not (Test-Path $deployCmdsPath)) { Write-Host " ❌ 服务器命令文件不存在: $deployCmdsPath" -ForegroundColor Red Write-Host " 请先创建 deploy_cmds_v1.2.txt(参考部署清单 Step 4)" -ForegroundColor Yellow exit 1 } & $PYTHON_BIN $V2_OPS batch $deployCmdsPath if ($LASTEXITCODE -ne 0) { Write-Host " ❌ 服务器部署失败,可执行回滚" -ForegroundColor Red exit 1 } Write-Host " ✅ 服务器部署成功" -ForegroundColor Green # ============================================================================ # Step 5:验证 HTTP 200 # ============================================================================ Write-Host "`n[Step 5/6] 验证 H5 URL..." -ForegroundColor Cyan & $PYTHON_BIN $V2_OPS exec "curl -I $H5_URL" if ($LASTEXITCODE -ne 0) { Write-Host " ⚠️ HTTP 验证失败,请人工检查" -ForegroundColor Yellow } # 检查前端 dist 文件 & $PYTHON_BIN $V2_OPS exec "ls $DEPLOY_REMOTE_DIR/dist/assets/ | head -20" # ============================================================================ # Step 6:完成 # ============================================================================ Write-Host "`n[Step 6/6] 部署完成" -ForegroundColor Cyan Write-Host " 📋 请按以下清单验证业务:" -ForegroundColor Gray Write-Host " 1. H5 打开 → AI 对话 <3 轮 → 引导语'请继续描述您的问题或需求'显示 ✅" -ForegroundColor Gray Write-Host " 2. AI 对话 ≥3 轮 → 按钮'🎧 人工坐席' + 顶部红色退出按钮可见 ✅" -ForegroundColor Gray Write-Host " 3. 坐席服务中(mock)→ 操作按钮'📴 结束咨询' + 顶部按钮隐藏 ✅" -ForegroundColor Gray Write-Host " 📞 如发现问题立即回滚:" -ForegroundColor Yellow Write-Host " & $PYTHON_BIN $V2_OPS exec `"rm -rf $DEPLOY_REMOTE_DIR/dist && mv $DEPLOY_REMOTE_DIR/dist.v1.1.bak $DEPLOY_REMOTE_DIR/dist`" -ForegroundColor Yellow