# 智裁云前端部署脚本(PowerShell) # 使用方法: .\deploy.ps1 -Env production param( [Parameter(Mandatory=$false)] [ValidateSet("development", "production")] [string]$Env = "production" ) Write-Host "开始构建智裁云前端项目..." -ForegroundColor Green # 检查pnpm是否安装 if (!(Get-Command pnpm -ErrorAction SilentlyContinue)) { Write-Host "错误: pnpm未安装,请先运行 npm install -g pnpm" -ForegroundColor Red exit 1 } # 安装依赖 Write-Host "安装依赖..." -ForegroundColor Yellow pnpm install # 构建所有应用 Write-Host "构建所有应用..." -ForegroundColor Yellow pnpm build:all # 检查构建产物 $apps = @("platform-app", "factory-app", "worker-app") foreach ($app in $apps) { $distPath = "apps\$app\dist" if (Test-Path $distPath) { Write-Host "✓ $app 构建成功" -ForegroundColor Green } else { Write-Host "✗ $app 构建失败" -ForegroundColor Red exit 1 } } # 创建部署目录 $deployDir = "dist" if (Test-Path $deployDir) { Remove-Item $deployDir -Recurse -Force } New-Item -ItemType Directory -Path $deployDir -Force | Out-Null # 复制构建产物 foreach ($app in $apps) { $srcPath = "apps\$app\dist" $destPath = "$deployDir\$app" Copy-Item -Path $srcPath -Destination $destPath -Recurse Write-Host "✓ 已复制 $app 到 $destPath" -ForegroundColor Green } # 复制Nginx配置 Copy-Item -Path "deploy\nginx.conf" -Destination "$deployDir\nginx.conf" Write-Host "✓ 已复制Nginx配置" -ForegroundColor Green Write-Host "" Write-Host "==========================================" -ForegroundColor Cyan Write-Host "构建完成!" -ForegroundColor Green Write-Host "==========================================" -ForegroundColor Cyan Write-Host "" Write-Host "部署目录: $deployPath" -ForegroundColor Yellow Write-Host "" Write-Host "部署步骤:" -ForegroundColor Yellow Write-Host "1. 将 $deployDir 目录上传到服务器" -ForegroundColor White Write-Host "2. 复制 nginx.conf 到 /etc/nginx/conf.d/" -ForegroundColor White Write-Host "3. 重启Nginx: sudo nginx -s reload" -ForegroundColor White Write-Host "" Write-Host "应用访问地址:" -ForegroundColor Yellow Write-Host " 系统管理后台: https://smartcut.example.com/platform" -ForegroundColor White Write-Host " 工厂管理后台: https://smartcut.example.com/factory" -ForegroundColor White Write-Host " 工人端: https://smartcut.example.com/worker" -ForegroundColor White