mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-06-21 17:40:25 +08:00
升级Vue3,iView替换ElementPlus
- 删除babel配置、更新依赖与入口初始化 - 全量替换UI组件、样式适配,新增迁移文档与标签/过滤器自动化替换脚本
This commit is contained in:
55
buyer/scripts/fix-runtime-compat.js
Normal file
55
buyer/scripts/fix-runtime-compat.js
Normal file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env node
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const ROOT = path.join(__dirname, "..");
|
||||
|
||||
function walkDir(dir, files = []) {
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const full = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) walkDir(full, files);
|
||||
else if (entry.name.endsWith(".vue")) files.push(full);
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
function fix(content) {
|
||||
let c = content;
|
||||
|
||||
c = c.replace(/<el-pagination\b/g, "<Page");
|
||||
c = c.replace(/<\/el-pagination>/g, "</Page>");
|
||||
|
||||
c = c.replace(
|
||||
/<Icon([^>]*)\s+#prepend\s*>\s*<\/Icon>/g,
|
||||
"<template #prepend><Icon$1></Icon></template>"
|
||||
);
|
||||
c = c.replace(
|
||||
/<Icon([^>]*)\s+#prepend\s*>\s*<\/Icon>/g,
|
||||
"<template #prepend><Icon$1></Icon></template>"
|
||||
);
|
||||
c = c.replace(
|
||||
/<template #prepend><Icon([^>]*)\s*\/>/g,
|
||||
"<template #prepend><Icon$1></Icon></template>"
|
||||
);
|
||||
|
||||
c = c.replace(/@keyup\.enter\.native/g, "@keyup.enter");
|
||||
c = c.replace(/slot="append"/g, "#append");
|
||||
c = c.replace(/(<div[^>]*)\s+#append/g, "<template #append>$1");
|
||||
|
||||
c = c.replace(/(<el-button[^>]*)\slong/g, '$1 style="width:100%"');
|
||||
c = c.replace(/@on-select/g, "@select");
|
||||
c = c.replace(/@on-click/g, "@click");
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
let count = 0;
|
||||
for (const file of walkDir(path.join(ROOT, "src"))) {
|
||||
const original = fs.readFileSync(file, "utf8");
|
||||
const fixed = fix(original);
|
||||
if (fixed !== original) {
|
||||
fs.writeFileSync(file, fixed);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
console.log(`Runtime compat fixes in ${count} files`);
|
||||
Reference in New Issue
Block a user