// +---------------------------------------------------------------------- // | CRMEB [ CRMEB赋能开发者,助力企业发展 ] // +---------------------------------------------------------------------- // 一次性修复脚本:修复 default-config-factory.mjs 因 stale offset 与 // defineProps 括号配对两处 bug 对 mobilePage 40 个组件造成的写坏。 // 修复策略(按可观测的系统性损伤特征): // A. 实例级 const 被插进 defineProps(...) 调用内部(结尾特征 `...props.num););`)→ 拆回 // B. const tagStart = src.lastIndexOf('', blockEnd); if (tagStart !== -1 && tagEnd !== -1) { const rebuilt = ``; src = src.slice(0, tagStart) + rebuilt + src.slice(tagEnd + ''.length); touched = true; } } } // C. 实例级 const 统一重插到 defineProps 语句之后(此时已能正确配平) if (touched && !src.includes(CONST_LINE)) { const dp = src.match(/const props = defineProps\(/); if (dp) { const dpEnd = findStatementEnd(src, src.indexOf('(', dp.index)); if (dpEnd !== -1) { src = src.slice(0, dpEnd) + CONST_BLOCK + src.slice(dpEnd); } } } if (touched) { fs.writeFileSync(full, src); fixed++; console.log(`[修复] ${file}`); } } console.log(`\n修复 ${fixed} 个`);