# 跨部门工时管理系统 - 一键安装脚本 (Windows PowerShell)

Write-Host "===========================================" -ForegroundColor Cyan
Write-Host "  跨部门工时管理与项目协同系统 - 安装脚本" -ForegroundColor Cyan
Write-Host "===========================================" -ForegroundColor Cyan

# Check Node.js
try {
    $nodeVersion = node -v
    Write-Host "✅ Node.js $nodeVersion" -ForegroundColor Green
} catch {
    Write-Host "❌ 请先安装 Node.js (>=16): https://nodejs.org" -ForegroundColor Red
    exit 1
}

# Install backend
Write-Host ""
Write-Host "📦 安装后端依赖..." -ForegroundColor Yellow
Push-Location server
npm install --production
Pop-Location

# Install frontend & build
Write-Host ""
Write-Host "📦 安装前端依赖..." -ForegroundColor Yellow
Push-Location client
npm install
Write-Host ""
Write-Host "🔨 构建前端..." -ForegroundColor Yellow
npm run build
Pop-Location

Write-Host ""
Write-Host "===========================================" -ForegroundColor Cyan
Write-Host "  ✅ 安装完成！" -ForegroundColor Green
Write-Host "===========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "启动命令:  cd server; node app.js" -ForegroundColor White
Write-Host "访问地址:  http://localhost:3000" -ForegroundColor White
Write-Host "默认账号:  admin / admin123" -ForegroundColor White
Write-Host ""
