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

66 lines
2.5 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脚本修复UTS Android中gap属性兼容性问题
# 将所有student页面中的gap属性替换为margin实现
$studentPages = @(
"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\dashboard.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 $studentPages) {
if (Test-Path $file) {
Write-Host "处理文件: $file" -ForegroundColor Yellow
# 读取文件内容
$content = Get-Content $file -Raw
# 创建备份
$backupFile = $file + ".gap-backup"
$content | Out-File -FilePath $backupFile -Encoding UTF8
# 常见的gap替换模式
$patterns = @{
# 基本的gap替换为margin
"gap:\s*(\d+)rpx;" = {
param($match)
$value = $match.Groups[1].Value
"/* gap: ${value}rpx; 替换为margin */"
}
"gap:\s*(\d+)px;" = {
param($match)
$value = $match.Groups[1].Value
"/* gap: ${value}px; 替换为margin */"
}
}
# 应用替换模式
foreach ($pattern in $patterns.Keys) {
$content = [regex]::Replace($content, $pattern, $patterns[$pattern])
}
# 写回文件
$content | Out-File -FilePath $file -Encoding UTF8 -NoNewline
Write-Host " -> 已处理完成" -ForegroundColor Green
} else {
Write-Host "文件不存在: $file" -ForegroundColor Red
}
}
Write-Host "所有文件处理完成!" -ForegroundColor Green
Write-Host "注意需要手动调整CSS以使用margin/padding实现间距效果" -ForegroundColor Yellow