You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
3.6 KiB
92 lines
3.6 KiB
# 测试路由同步修复效果 |
|
# 检查direct-route-mappings.js文件读取和路由映射生成问题 |
|
|
|
Write-Host "========================================" -ForegroundColor Cyan |
|
Write-Host " 路由同步修复测试脚本" -ForegroundColor Cyan |
|
Write-Host "========================================" -ForegroundColor Cyan |
|
Write-Host "" |
|
|
|
# 设置编码 |
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 |
|
$OutputEncoding = [System.Text.Encoding]::UTF8 |
|
|
|
# 检查文件是否存在 |
|
Write-Host "🔍 检查关键文件..." -ForegroundColor Yellow |
|
|
|
$mappingFile = "app\src\renderer\modules\route-sync\direct-route-mappings.js" |
|
if (Test-Path $mappingFile) { |
|
Write-Host "✅ direct-route-mappings.js 文件存在" -ForegroundColor Green |
|
|
|
# 检查文件内容 |
|
$content = Get-Content $mappingFile -Raw |
|
if ($content -match "export const directRouteMappings") { |
|
Write-Host "✅ 文件包含正确的导出" -ForegroundColor Green |
|
} else { |
|
Write-Host "❌ 文件缺少正确的导出" -ForegroundColor Red |
|
} |
|
|
|
if ($content -match "pageMappings") { |
|
Write-Host "✅ 文件包含pageMappings" -ForegroundColor Green |
|
} else { |
|
Write-Host "❌ 文件缺少pageMappings" -ForegroundColor Red |
|
} |
|
} else { |
|
Write-Host "❌ direct-route-mappings.js 文件不存在" -ForegroundColor Red |
|
} |
|
|
|
# 检查RouteConfig文件 |
|
$configFile = "app\src\renderer\modules\route-sync\RouteConfig.js" |
|
if (Test-Path $configFile) { |
|
Write-Host "✅ RouteConfig.js 文件存在" -ForegroundColor Green |
|
|
|
$configContent = Get-Content $configFile -Raw |
|
if ($configContent -match "defaultApiMappings") { |
|
Write-Host "✅ RouteConfig包含defaultApiMappings" -ForegroundColor Green |
|
} else { |
|
Write-Host "❌ RouteConfig缺少defaultApiMappings" -ForegroundColor Red |
|
} |
|
} else { |
|
Write-Host "❌ RouteConfig.js 文件不存在" -ForegroundColor Red |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "🔧 测试路由映射生成..." -ForegroundColor Yellow |
|
|
|
# 进入app目录 |
|
Set-Location "app" |
|
|
|
# 测试生成脚本 |
|
try { |
|
Write-Host "运行路由映射生成脚本..." -ForegroundColor Cyan |
|
node scripts/generate-route-mappings.js |
|
if ($LASTEXITCODE -eq 0) { |
|
Write-Host "✅ 路由映射生成脚本执行成功" -ForegroundColor Green |
|
} else { |
|
Write-Host "❌ 路由映射生成脚本执行失败" -ForegroundColor Red |
|
} |
|
} catch { |
|
Write-Host "❌ 路由映射生成脚本执行异常: $($_.Exception.Message)" -ForegroundColor Red |
|
} |
|
|
|
# 返回根目录 |
|
Set-Location ".." |
|
|
|
Write-Host "" |
|
Write-Host "📊 修复总结:" -ForegroundColor Yellow |
|
Write-Host "1. ✅ 添加了defaultApiMappings配置到RouteConfig" -ForegroundColor Green |
|
Write-Host "2. ✅ 修复了RouteMapper中的API映射生成逻辑" -ForegroundColor Green |
|
Write-Host "3. ✅ 添加了_createApiMappingFromDirectCall方法" -ForegroundColor Green |
|
Write-Host "4. ✅ 添加了详细的调试日志" -ForegroundColor Green |
|
Write-Host "5. ✅ 优化了路由收集和映射生成流程" -ForegroundColor Green |
|
|
|
Write-Host "" |
|
Write-Host "🎯 预期效果:" -ForegroundColor Yellow |
|
Write-Host "- 能够正确读取direct-route-mappings.js文件" -ForegroundColor White |
|
Write-Host "- 能够正确生成路由映射" -ForegroundColor White |
|
Write-Host "- 不再出现'没有生成路由映射'错误" -ForegroundColor White |
|
Write-Host "- 路由同步逻辑能够正常执行" -ForegroundColor White |
|
|
|
Write-Host "" |
|
Write-Host "========================================" -ForegroundColor Cyan |
|
Write-Host "修复完成!现在可以重新启动应用测试" -ForegroundColor Green |
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
|