修改小程序bug
This commit is contained in:
45
scripts/switch-pages.js
Normal file
45
scripts/switch-pages.js
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 切换 pages.json 在「完整模式」和「商家端专属模式」之间
|
||||
*
|
||||
* 用法:
|
||||
* npm run pages:merchant → 仅编译 merchant 相关页面(大幅缩短编译时间)
|
||||
* npm run pages:full → 恢复完整 pages.json
|
||||
*/
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const root = path.resolve(__dirname, "..");
|
||||
const pagesJson = path.join(root, "pages.json");
|
||||
const pagesFull = path.join(root, "pages.full.json");
|
||||
const pagesMerchant = path.join(root, "pages.merchant.json");
|
||||
|
||||
const mode = process.argv[2]; // 'merchant' | 'full'
|
||||
|
||||
if (mode === "merchant") {
|
||||
if (!fs.existsSync(pagesMerchant)) {
|
||||
console.error("❌ pages.merchant.json 不存在,请先创建该文件。");
|
||||
process.exit(1);
|
||||
}
|
||||
// 备份当前 pages.json(仅在未备份时执行,避免覆盖真正的完整版本)
|
||||
if (!fs.existsSync(pagesFull)) {
|
||||
fs.copyFileSync(pagesJson, pagesFull);
|
||||
console.log("📦 已备份 pages.json → pages.full.json");
|
||||
}
|
||||
fs.copyFileSync(pagesMerchant, pagesJson);
|
||||
console.log("✅ 已切换为【商家端专属编译模式】");
|
||||
console.log(" 仅包含 merchant 页面,差量编译速度大幅提升。");
|
||||
console.log(" 恢复完整版本:npm run pages:full");
|
||||
} else if (mode === "full") {
|
||||
if (!fs.existsSync(pagesFull)) {
|
||||
console.error("❌ pages.full.json 不存在。");
|
||||
console.error(" 可能当前已经是完整模式,或备份文件已被删除。");
|
||||
process.exit(1);
|
||||
}
|
||||
fs.copyFileSync(pagesFull, pagesJson);
|
||||
console.log("✅ 已恢复【完整 pages.json】");
|
||||
console.log(" 包含 consumer + merchant + admin 全部页面。");
|
||||
} else {
|
||||
console.log("用法:");
|
||||
console.log(" npm run pages:merchant 切换到商家端专属编译模式");
|
||||
console.log(" npm run pages:full 恢复完整编译模式");
|
||||
}
|
||||
Reference in New Issue
Block a user