Files
ks-app-employment-service/scale-styles.ps1
2026-03-12 17:10:34 +08:00

54 lines
1.4 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.

# 定义要处理的目录
$pagesDir = "./pages"
$packageADir = "./packageA"
# 定义要排除的文件(首页相关)
$excludePatterns = @("*index*", "*Index*", "*INDEX*")
# 函数:放大样式值
function Scale-Styles($filePath) {
Write-Host "Processing $filePath"
# 读取文件内容
$content = Get-Content -Path $filePath -Raw
# 正则表达式匹配所有数值px 或 rpx 单位)
$pattern = '([:\s])(\d+)(px|rpx)'
# 替换函数
$replacement = {
param($match)
$value = [int]$match.Groups[2].Value
$scaledValue = [math]::Round($value * 1.5)
return "$($match.Groups[1].Value)$scaledValue$($match.Groups[3].Value)"
}
# 执行替换
$newContent = [regex]::Replace($content, $pattern, $replacement)
# 写回文件
Set-Content -Path $filePath -Value $newContent -Force
}
# 处理 pages 目录
Get-ChildItem -Path $pagesDir -Recurse -Filter "*.vue" | Where-Object {
$file = $_
$exclude = $false
foreach ($pattern in $excludePatterns) {
if ($file.FullName -like "*$pattern*") {
$exclude = $true
break
}
}
!$exclude
} | ForEach-Object {
Scale-Styles $_.FullName
}
# 处理 packageA 目录
Get-ChildItem -Path $packageADir -Recurse -Filter "*.vue" | ForEach-Object {
Scale-Styles $_.FullName
}
Write-Host "Processing completed!"