#!/usr/bin/env node
/**
* tianpan 家族 px→rpx 转换(×2,375px 设计基准)
* 转换范围: 内容来隔离
const styleStart = text.search(/'
pos = styleRegex.lastIndex
}
}
result += text.slice(pos)
return { newSrc: result, count: matchCount }
}
function main() {
let totalConverted = 0
const log = []
for (const file of FILES) {
const filePath = path.join(TIANPAN_DIR, file)
if (!fs.existsSync(filePath)) {
console.warn(`跳过不存在文件: ${file}`)
continue
}
const src = fs.readFileSync(filePath, 'utf8')
const { newSrc, count } = convertPxToRpx(src)
if (count > 0) {
fs.writeFileSync(filePath, newSrc, 'utf8')
totalConverted += count
log.push(`${count.toString().padStart(3)} ${file}`)
}
}
console.log(`\n=== tianpan px→rpx 完成 ===`)
console.log(`转换次数: ${totalConverted}`)
console.log('')
log.sort((a, b) => parseInt(b.split(' ')[0]) - parseInt(a.split(' ')[0]))
for (const line of log) console.log(line)
}
main()