#!/usr/bin/env node /** * D11b: relation-detail 多行块因 CRLF 未命中,逐行补齐 */ const fs = require('fs'); const F = 'pages/tianpan/relation-detail.vue'; let src = fs.readFileSync(F, 'utf8'); const MAP = [ [" return '#6B7280'", " return BrandColors.textSlate"], [" 'parent': '#F97316',", " 'parent': BrandColors.primary,"], [" 'child': '#3B82F6',", " 'child': BrandColors.infoBlue,"], [" 'teacher': '#8B5CF6'", " 'teacher': BrandColors.violet"], ["return colorMap[this.relation.fromMemberRole] || '#6B7280'", "return colorMap[this.relation.fromMemberRole] || BrandColors.textSlate"], ["return colorMap[this.relation.toMemberRole] || '#6B7280'", "return colorMap[this.relation.toMemberRole] || BrandColors.textSlate"], [" return '#10B981'", " return BrandColors.success"], [" return '#F59E0B'", " return BrandColors.wealth"], [" return '#EF4444'", " return BrandColors.danger"], ]; let n = 0; for (const [f, t] of MAP) { const cnt = src.split(f).length - 1; if (cnt === 0) { console.warn('NOT FOUND:', f); continue; } src = src.split(f).join(t); n += cnt; } // getScoreColor 的 if (!score) return '#6B7280'(4 空格缩进) if (src.includes(" if (!score) {\n return '#6B7280'")) { /* noop */ } const sCount = src.split(" if (!score) {").length - 1; console.log('if(!score) blocks:', sCount); fs.writeFileSync(F, src); console.log('replaced:', n); const lines = src.split('\n'); let h = 0; for (let i = 0; i < lines.length; i++) { if (/#[0-9a-fA-F]{3,8}\b/.test(lines[i])) { const L = lines[i].trim(); if (L.indexOf('$c-') !== 0) { console.log('HEX ' + (i + 1) + ': ' + L); h++; } } } console.log('remaining non-palette hex:', h);