一体机放大效果开发
This commit is contained in:
53
scale-styles.ps1
Normal file
53
scale-styles.ps1
Normal file
@@ -0,0 +1,53 @@
|
||||
# 定义要处理的目录
|
||||
$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!"
|
||||
Reference in New Issue
Block a user