|
|
# 修复构建问题的脚本 |
|
|
param( |
|
|
[switch]$Clean, |
|
|
[switch]$Rebuild |
|
|
) |
|
|
|
|
|
# 设置控制台编码为 UTF-8 |
|
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 |
|
|
[Console]::InputEncoding = [System.Text.Encoding]::UTF8 |
|
|
$OutputEncoding = [System.Text.Encoding]::UTF8 |
|
|
|
|
|
Write-Host "🔧 修复 GoFaster 构建问题..." -ForegroundColor Cyan |
|
|
Write-Host "" |
|
|
|
|
|
# 检查依赖 |
|
|
Write-Host "📦 检查依赖..." -ForegroundColor Yellow |
|
|
if (-not (Test-Path "node_modules")) { |
|
|
Write-Host "⚠️ 依赖未安装,正在安装..." -ForegroundColor Yellow |
|
|
npm install |
|
|
if ($LASTEXITCODE -ne 0) { |
|
|
Write-Host "❌ 依赖安装失败" -ForegroundColor Red |
|
|
exit 1 |
|
|
} |
|
|
} |
|
|
|
|
|
# 清理构建文件 |
|
|
if ($Clean -or $Rebuild) { |
|
|
Write-Host "🧹 清理构建文件..." -ForegroundColor Yellow |
|
|
if (Test-Path "dist") { |
|
|
Remove-Item -Recurse -Force "dist" |
|
|
Write-Host "✅ 构建文件已清理" -ForegroundColor Green |
|
|
} |
|
|
} |
|
|
|
|
|
# 重新构建 |
|
|
Write-Host "🔨 重新构建项目..." -ForegroundColor Yellow |
|
|
npm run build:vue |
|
|
|
|
|
if ($LASTEXITCODE -eq 0) { |
|
|
Write-Host "✅ 构建成功!" -ForegroundColor Green |
|
|
|
|
|
# 检查构建文件 |
|
|
Write-Host "📁 检查构建文件..." -ForegroundColor Yellow |
|
|
$indexHtml = "dist/renderer/index.html" |
|
|
$indexJs = "dist/renderer/js/index.js" |
|
|
$vendorsJs = "dist/renderer/js/vendors.js" |
|
|
|
|
|
if (Test-Path $indexHtml) { |
|
|
Write-Host "✅ index.html 存在" -ForegroundColor Green |
|
|
} else { |
|
|
Write-Host "❌ index.html 不存在" -ForegroundColor Red |
|
|
} |
|
|
|
|
|
if (Test-Path $indexJs) { |
|
|
Write-Host "✅ index.js 存在" -ForegroundColor Green |
|
|
} else { |
|
|
Write-Host "❌ index.js 不存在" -ForegroundColor Red |
|
|
} |
|
|
|
|
|
if (Test-Path $vendorsJs) { |
|
|
Write-Host "✅ vendors.js 存在" -ForegroundColor Green |
|
|
} else { |
|
|
Write-Host "❌ vendors.js 不存在" -ForegroundColor Red |
|
|
} |
|
|
|
|
|
Write-Host "" |
|
|
Write-Host "🚀 现在可以启动应用了!" -ForegroundColor Cyan |
|
|
Write-Host " 使用: npm run dev:enhanced" -ForegroundColor White |
|
|
} else { |
|
|
Write-Host "❌ 构建失败" -ForegroundColor Red |
|
|
exit 1 |
|
|
}
|
|
|
|