108 lines
4.0 KiB
PowerShell
108 lines
4.0 KiB
PowerShell
# UTS Android calc() 兼容性批量修复脚本 v2
|
|
# 修复剩余的 calc() 函数实例
|
|
|
|
Write-Host "开始批量修复剩余的 calc() 兼容性问题..." -ForegroundColor Green
|
|
|
|
# 定义具体的替换规则
|
|
$calcReplacements = @{
|
|
# 高度相关
|
|
'calc\(100vh - 200rpx\)' = '80vh'
|
|
'calc\(100vh - 160rpx\)' = '82vh'
|
|
'calc\(100vh - 120rpx\)' = '85vh'
|
|
'calc\(90vh - 140px\)' = '75vh'
|
|
|
|
# 宽度相关 - 50%系列
|
|
'calc\(50% - 10rpx\)' = '46%'
|
|
'calc\(50% - 8rpx\)' = '47%'
|
|
'calc\(50% - 7\.5rpx\)' = '47%'
|
|
'calc\(50% - 7\.5px\)' = '47%'
|
|
'calc\(50% - 6px\)' = '47%'
|
|
'calc\(50% - 4rpx\)' = '48%'
|
|
'calc\(50% - 15rpx\)' = '45%'
|
|
|
|
# 位置相关
|
|
'calc\(50% - 90rpx\)' = '42%'
|
|
}
|
|
|
|
# 获取所有相关文件
|
|
$targetFiles = @(
|
|
'pages\eldercare\visitor\management.uvue',
|
|
'pages\user\profile.uvue',
|
|
'pages\sport\student\simple-records.uvue',
|
|
'pages\sport\student\records.uvue',
|
|
'pages\sport\student\goal-settings.uvue',
|
|
'pages\sport\teacher\project-edit.uvue',
|
|
'pages\sport\teacher\migration-tool.uvue',
|
|
'pages\sport\teacher\create-assignment.uvue',
|
|
'pages\sport\student\achievements.uvue',
|
|
'pages\eldercare\index.uvue',
|
|
'pages\eldercare\doctor\dashboard.uvue',
|
|
'pages\eldercare\family\care-records.uvue',
|
|
'pages\eldercare\elder\dashboard.uvue',
|
|
'pages\eldercare\admin\health-monitoring.uvue',
|
|
'pages\eldercare\activity\management.uvue'
|
|
)
|
|
|
|
$totalFixed = 0
|
|
$filesFixed = @()
|
|
|
|
foreach ($filePath in $targetFiles) {
|
|
if (Test-Path $filePath) {
|
|
$content = Get-Content $filePath -Raw -Encoding UTF8
|
|
$originalContent = $content
|
|
$fileFixCount = 0
|
|
|
|
foreach ($pattern in $calcReplacements.Keys) {
|
|
$replacement = $calcReplacements[$pattern]
|
|
$matches = [regex]::Matches($content, $pattern, [Text.RegularExpressions.RegexOptions]::IgnoreCase)
|
|
|
|
if ($matches.Count -gt 0) {
|
|
$content = [regex]::Replace($content, $pattern, $replacement, [Text.RegularExpressions.RegexOptions]::IgnoreCase)
|
|
$fileFixCount += $matches.Count
|
|
Write-Host " ✅ $filePath : $($matches.Count) 个 '$pattern' -> '$replacement'" -ForegroundColor Yellow
|
|
}
|
|
}
|
|
|
|
if ($fileFixCount -gt 0) {
|
|
Set-Content -Path $filePath -Value $content -Encoding UTF8
|
|
$filesFixed += $filePath
|
|
$totalFixed += $fileFixCount
|
|
Write-Host " 🔧 修复文件: $filePath ($fileFixCount 个替换)" -ForegroundColor Green
|
|
}
|
|
} else {
|
|
Write-Host " ⚠️ 文件不存在: $filePath" -ForegroundColor Yellow
|
|
}
|
|
}
|
|
|
|
Write-Host "`n修复完成!" -ForegroundColor Green
|
|
Write-Host "修复文件数: $($filesFixed.Count)" -ForegroundColor Cyan
|
|
Write-Host "总修复数: $totalFixed" -ForegroundColor Cyan
|
|
|
|
if ($filesFixed.Count -gt 0) {
|
|
Write-Host "`n修复的文件:" -ForegroundColor Yellow
|
|
$filesFixed | ForEach-Object { Write-Host " - $_" -ForegroundColor White }
|
|
}
|
|
|
|
# 最终验证
|
|
Write-Host "`n🔍 最终验证 - 检查剩余的 calc() 函数..." -ForegroundColor Yellow
|
|
$remainingFiles = @()
|
|
|
|
Get-ChildItem -Path "." -Recurse -Filter "*.uvue" | Where-Object { $_.FullName -notlike "*node_modules*" } | ForEach-Object {
|
|
$content = Get-Content $_.FullName -Raw -Encoding UTF8
|
|
$matches = [regex]::Matches($content, 'calc\(', [Text.RegularExpressions.RegexOptions]::IgnoreCase)
|
|
|
|
if ($matches.Count -gt 0) {
|
|
$remainingFiles += "$($_.Name): $($matches.Count) 个 calc()"
|
|
}
|
|
}
|
|
|
|
if ($remainingFiles.Count -eq 0) {
|
|
Write-Host "🎉 优秀! 所有 calc() 函数都已修复完成!" -ForegroundColor Green
|
|
Write-Host "🚀 项目现在完全兼容 UTS Android!" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "`n⚠️ 还有以下文件包含 calc() 函数:" -ForegroundColor Red
|
|
$remainingFiles | ForEach-Object { Write-Host " - $_" -ForegroundColor Red }
|
|
}
|
|
|
|
Write-Host "`n✅ UTS Android calc() 兼容性修复脚本执行完成!" -ForegroundColor Green
|