84 lines
2.8 KiB
PowerShell
84 lines
2.8 KiB
PowerShell
run# 考试信息管理系统 - 快速启动脚本 (PowerShell)
|
||
# 使用方法:.\start.ps1
|
||
|
||
Write-Host "========================================" -ForegroundColor Cyan
|
||
Write-Host " 考试信息管理系统 - 快速启动" -ForegroundColor Cyan
|
||
Write-Host "========================================" -ForegroundColor Cyan
|
||
Write-Host ""
|
||
|
||
# 检查 Go 环境
|
||
Write-Host "[1/5] 检查 Go 环境..." -ForegroundColor Yellow
|
||
try {
|
||
$goVersion = go version
|
||
Write-Host "✓ Go 已安装:$goVersion" -ForegroundColor Green
|
||
} catch {
|
||
Write-Host "✗ Go 未安装,请先安装 Go 1.21+" -ForegroundColor Red
|
||
exit 1
|
||
}
|
||
|
||
# 检查 Node.js 环境
|
||
Write-Host "[2/5] 检查 Node.js 环境..." -ForegroundColor Yellow
|
||
try {
|
||
$nodeVersion = node --version
|
||
Write-Host "✓ Node.js 已安装:$nodeVersion" -ForegroundColor Green
|
||
} catch {
|
||
Write-Host "✗ Node.js 未安装,请先安装 Node.js 18+" -ForegroundColor Red
|
||
exit 1
|
||
}
|
||
|
||
# 构建前端
|
||
Write-Host "[3/5] 构建前端..." -ForegroundColor Yellow
|
||
Set-Location frontend
|
||
|
||
if (-not (Test-Path "node_modules")) {
|
||
Write-Host " 安装依赖..." -ForegroundColor Cyan
|
||
npm install
|
||
if ($LASTEXITCODE -ne 0) {
|
||
Write-Host "✗ 依赖安装失败" -ForegroundColor Red
|
||
exit 1
|
||
}
|
||
} else {
|
||
Write-Host " 依赖已存在,跳过安装" -ForegroundColor Green
|
||
}
|
||
|
||
Write-Host " 构建生产版本..." -ForegroundColor Cyan
|
||
npm run build
|
||
if ($LASTEXITCODE -ne 0) {
|
||
Write-Host "✗ 前端构建失败" -ForegroundColor Red
|
||
Set-Location ..
|
||
exit 1
|
||
}
|
||
|
||
Write-Host "✓ 前端构建完成" -ForegroundColor Green
|
||
Set-Location ..
|
||
|
||
# 检查配置文件
|
||
Write-Host "[4/5] 检查配置文件..." -ForegroundColor Yellow
|
||
if (Test-Path "config\config.yaml") {
|
||
Write-Host "✓ 配置文件存在" -ForegroundColor Green
|
||
Write-Host "⚠️ 请确保 config/config.yaml 中的数据库密码已修改" -ForegroundColor Yellow
|
||
} else {
|
||
Write-Host "✗ 配置文件不存在:config\config.yaml" -ForegroundColor Red
|
||
exit 1
|
||
}
|
||
|
||
# 启动后端服务
|
||
Write-Host "[5/5] 启动后端服务..." -ForegroundColor Yellow
|
||
Write-Host ""
|
||
Write-Host "========================================" -ForegroundColor Cyan
|
||
Write-Host " 服务器即将启动..." -ForegroundColor Cyan
|
||
Write-Host "========================================" -ForegroundColor Cyan
|
||
Write-Host ""
|
||
Write-Host "访问地址:" -ForegroundColor White
|
||
Write-Host " 前端:http://localhost:8080" -ForegroundColor Blue
|
||
Write-Host " API: http://localhost:8080/api" -ForegroundColor Blue
|
||
Write-Host ""
|
||
Write-Host "默认登录账号:" -ForegroundColor White
|
||
Write-Host " 用户名:admin" -ForegroundColor Blue
|
||
Write-Host " 密码:admin123" -ForegroundColor Blue
|
||
Write-Host ""
|
||
Write-Host "按 Ctrl+C 停止服务" -ForegroundColor Yellow
|
||
Write-Host ""
|
||
|
||
go run cmd/main.go
|