Files
akmon/doc_zhipao/fix_all_gaps.ps1
2026-01-20 08:04:15 +08:00

75 lines
3.1 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# PowerShell script to fix gap compatibility issues in UTS Android
# This script will create a comprehensive fix for all gap properties
$ErrorActionPreference = "Stop"
# Define the files to fix
$files = @(
"h:\blews\akmon\pages\sport\student\achievements.uvue",
"h:\blews\akmon\pages\sport\student\assignment-detail.uvue",
"h:\blews\akmon\pages\sport\student\assignments.uvue",
"h:\blews\akmon\pages\sport\student\device-management.uvue",
"h:\blews\akmon\pages\sport\student\favorite-exercises.uvue",
"h:\blews\akmon\pages\sport\student\goal-settings.uvue",
"h:\blews\akmon\pages\sport\student\preferences-analytics.uvue",
"h:\blews\akmon\pages\sport\student\profile.uvue",
"h:\blews\akmon\pages\sport\student\progress.uvue",
"h:\blews\akmon\pages\sport\student\records.uvue",
"h:\blews\akmon\pages\sport\student\record-detail.uvue",
"h:\blews\akmon\pages\sport\student\reminder-settings.uvue",
"h:\blews\akmon\pages\sport\student\simple-records.uvue"
)
Write-Host "开始修复 gap 属性兼容性问题..." -ForegroundColor Green
foreach ($file in $files) {
if (Test-Path $file) {
Write-Host "处理文件: $file" -ForegroundColor Yellow
# 读取文件内容
$content = Get-Content $file -Raw -Encoding UTF8
# 创建备份
$backupFile = $file + ".pre-gap-fix"
if (-not (Test-Path $backupFile)) {
$content | Set-Content -Path $backupFile -Encoding UTF8
Write-Host " 备份已创建: $backupFile" -ForegroundColor Cyan
}
# 统计修改数量
$gapCount = ([regex]::Matches($content, "gap:\s*\d+(?:rpx|px)")).Count
if ($gapCount -gt 0) {
Write-Host " 发现 $gapCount 个 gap 属性需要修复" -ForegroundColor Red
# 注释掉所有 gap 属性,添加 TODO 标记
$content = $content -replace "(\s*)(gap:\s*(\d+)(?:rpx|px));", "`$1/* TODO: Fix gap compatibility - was: gap: `$3 */ /* `$2 */"
# 写回文件
$content | Set-Content -Path $file -Encoding UTF8
Write-Host " 已注释 $gapCount 个 gap 属性,需要手动修复" -ForegroundColor Yellow
} else {
Write-Host " 没有找到 gap 属性" -ForegroundColor Green
}
} else {
Write-Host "文件不存在: $file" -ForegroundColor Red
}
}
Write-Host "`n修复完成!" -ForegroundColor Green
Write-Host "注意gap 属性已被注释,需要手动替换为 margin 实现" -ForegroundColor Yellow
Write-Host "请参考 UTS_ANDROID_GAP_FIX_GUIDE.md 文档进行手动修复" -ForegroundColor Yellow
# 显示需要手动修复的文件列表
Write-Host "`n需要手动修复的文件:" -ForegroundColor Cyan
foreach ($file in $files) {
if (Test-Path $file) {
$content = Get-Content $file -Raw -Encoding UTF8
$todoCount = ([regex]::Matches($content, "TODO: Fix gap compatibility")).Count
if ($todoCount -gt 0) {
Write-Host " $file - $todoCount 处需要修复" -ForegroundColor White
}
}
}