46 lines
1.4 KiB
PowerShell
46 lines
1.4 KiB
PowerShell
# 结伴客后台管理系统部署脚本 (PowerShell)
|
|
Write-Host "开始部署结伴客后台管理系统..." -ForegroundColor Green
|
|
|
|
# 检查Node.js是否安装
|
|
if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
|
|
Write-Host "错误: Node.js 未安装,请先安装 Node.js" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
# 检查npm是否安装
|
|
if (-not (Get-Command npm -ErrorAction SilentlyContinue)) {
|
|
Write-Host "错误: npm 未安装,请先安装 npm" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
# 安装依赖
|
|
Write-Host "安装项目依赖..." -ForegroundColor Yellow
|
|
npm install
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "依赖安装失败,请检查错误信息" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
# 构建项目
|
|
Write-Host "构建项目..." -ForegroundColor Yellow
|
|
npm run build
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "构建失败,请检查错误信息" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "构建成功!" -ForegroundColor Green
|
|
|
|
# 创建生产环境配置文件
|
|
Write-Host "创建生产环境配置..." -ForegroundColor Yellow
|
|
@"
|
|
VITE_APP_TITLE=结伴客后台管理系统
|
|
VITE_API_BASE_URL=https://api.jiebanke.com
|
|
VITE_APP_VERSION=v1.0.0
|
|
"@ | Out-File -FilePath .env.production -Encoding UTF8
|
|
|
|
Write-Host "部署完成!" -ForegroundColor Green
|
|
Write-Host "运行 'npm run preview' 预览生产版本" -ForegroundColor Cyan
|
|
Write-Host "或运行 'npm run dev' 启动开发服务器" -ForegroundColor Cyan |