mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-06-22 09:50:14 +08:00
refactor:项目升级Vue3+uView Plus
- 改造入口文件、全量替换组件引入 - 过滤器迁移混入,更新忽略配置,新增迁移文档
This commit is contained in:
33
scripts/migrate-uview-components.js
Normal file
33
scripts/migrate-uview-components.js
Normal file
@@ -0,0 +1,33 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const root = path.join(__dirname, '..')
|
||||
|
||||
function walk(dir, files = []) {
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
if (['node_modules', '.git', 'scripts'].includes(entry.name)) continue
|
||||
const full = path.join(dir, entry.name)
|
||||
if (entry.isDirectory()) walk(full, files)
|
||||
else if (entry.name.endsWith('.vue')) files.push(full)
|
||||
}
|
||||
return files
|
||||
}
|
||||
|
||||
function process(content) {
|
||||
return content
|
||||
.replace(/u-verification-code/g, 'u-code')
|
||||
.replace(/<u-cell-item/g, '<u-cell')
|
||||
.replace(/<\/u-cell-item>/g, '</u-cell>')
|
||||
.replace(/:arrow="false"/g, ':isLink="false"')
|
||||
}
|
||||
|
||||
walk(root).forEach((file) => {
|
||||
const original = fs.readFileSync(file, 'utf8')
|
||||
const updated = process(original)
|
||||
if (updated !== original) {
|
||||
fs.writeFileSync(file, updated)
|
||||
console.log('updated', path.relative(root, file))
|
||||
}
|
||||
})
|
||||
|
||||
console.log('uview component aliases updated')
|
||||
Reference in New Issue
Block a user