#!/usr/bin/env pwsh # Gap fix script for UTS Android compatibility # Replaces CSS gap properties with margin/padding alternatives Write-Host "开始修复 UTS Android gap 兼容性问题..." -ForegroundColor Green # 定义需要修复的文件列表(不包括已经修复的 assignments.uvue) $filesToFix = @( "pages\eldercare\index.uvue", "pages\eldercare\caregiver\elder-details.uvue", "pages\sport\student\profile.uvue", "pages\sport\student\assignment-detail.uvue", "pages\sport\student\device-management.uvue", "pages\sport\index.uvue", "pages\user\login.uvue" ) foreach ($file in $filesToFix) { $fullPath = "h:\blews\akmon\$file" if (Test-Path $fullPath) { Write-Host "处理文件: $file" -ForegroundColor Yellow # 读取文件内容 $content = Get-Content $fullPath -Raw -Encoding UTF8 # 记录修改次数 $changes = 0 # 通用替换规则 # 1. display: flex; gap: Xpx/rpx; -> display: flex; + margin-right for children # 2. 针对不同的gap值进行替换 # 替换 gap: 15px; if ($content -match "gap:\s*15px;") { $content = $content -replace "(\s+)gap:\s*15px;", "" $changes++ Write-Host " - 移除 gap: 15px" -ForegroundColor Cyan } # 替换 gap: 10px; if ($content -match "gap:\s*10px;") { $content = $content -replace "(\s+)gap:\s*10px;", "" $changes++ Write-Host " - 移除 gap: 10px" -ForegroundColor Cyan } # 替换各种 rpx 值的 gap $gapPattern = "gap:\s*(\d+)rpx;" $matches = [regex]::Matches($content, $gapPattern) foreach ($match in $matches) { $gapValue = $match.Groups[1].Value $content = $content -replace "(\s+)gap:\s*${gapValue}rpx;", "" $changes++ Write-Host " - 移除 gap: ${gapValue}rpx" -ForegroundColor Cyan } # 如果有修改,保存文件 if ($changes -gt 0) { Set-Content $fullPath -Value $content -Encoding UTF8 -NoNewline Write-Host " ✓ 文件已更新 ($changes 处修改)" -ForegroundColor Green } else { Write-Host " - 无需修改" -ForegroundColor Gray } } else { Write-Host " × 文件不存在: $fullPath" -ForegroundColor Red } } Write-Host "`n修复完成!请手动检查并添加适当的 margin 样式。" -ForegroundColor Green Write-Host "建议的修复方式:" -ForegroundColor Yellow Write-Host "1. 对于横向排列的元素:添加 margin-right,最后一个元素使用 :last-child { margin-right: 0; }" -ForegroundColor White Write-Host "2. 对于纵向排列的元素:添加 margin-bottom,最后一个元素使用 :last-child { margin-bottom: 0; }" -ForegroundColor White Write-Host "3. 对于网格布局:考虑使用 margin 或 padding 的组合" -ForegroundColor White