# UTS Android Display Block Compatibility Fix # This script removes display: block properties that are not supported in UTS Android Write-Host "开始修复 UTS Android display: block 兼容性问题..." -ForegroundColor Green # Define the files that need fixing $filesToFix = @( "pages\sport\student\record-detail.uvue", "pages\sport\student\reminder-settings.uvue", "pages\sport\student\goal-settings.uvue", "pages\sport\student\favorite-exercises.uvue", "pages\sport\student\device-management.uvue", "pages\sport\teacher\project-edit.uvue", "pages\sport\teacher\project-detail.uvue", "pages\sport\teacher\project-create.uvue" ) $totalChanges = 0 foreach ($file in $filesToFix) { $fullPath = "h:\blews\akmon\$file" if (Test-Path $fullPath) { Write-Host "处理文件: $file" -ForegroundColor Yellow # Read file content $content = Get-Content $fullPath -Raw -Encoding UTF8 $originalContent = $content # Remove display: block; properties # Pattern 1: display: block; (with semicolon) $content = $content -replace '\s*display:\s*block\s*;\s*\r?\n?', "`n" # Pattern 2: display: block (without semicolon, typically at end of rule) $content = $content -replace '\s*display:\s*block\s*\r?\n', "`n" # Clean up extra blank lines that might be created $content = $content -replace '\n\s*\n\s*\n', "`n`n" if ($content -ne $originalContent) { Set-Content $fullPath -Value $content -Encoding UTF8 -NoNewline $changes = ($originalContent.Split([Environment]::NewLine) | Measure-Object).Count - ($content.Split([Environment]::NewLine) | Measure-Object).Count $totalChanges += $changes Write-Host " ✓ 文件已更新 (移除了 display: block 属性)" -ForegroundColor Green } else { Write-Host " - 无需修改" -ForegroundColor Gray } } else { Write-Host " × 文件不存在: $fullPath" -ForegroundColor Red } } Write-Host "`n修复完成!" -ForegroundColor Green Write-Host "总计处理了 $totalChanges 处修改" -ForegroundColor Cyan Write-Host "`n说明:" -ForegroundColor Yellow Write-Host "UTS Android 只支持 display: flex 和 display: none" -ForegroundColor White Write-Host "移除 display: block 通常不会影响布局,因为这是默认行为" -ForegroundColor White Write-Host "`n建议下一步:" -ForegroundColor Yellow Write-Host "1. 测试修复后的页面确保布局正常" -ForegroundColor White Write-Host "2. 如果某些元素需要块级显示,考虑使用 flex 布局" -ForegroundColor White Write-Host "3. 检查是否还有其他 CSS 兼容性问题" -ForegroundColor White