d11b-relation-detail.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env node
  2. /**
  3. * D11b: relation-detail 多行块因 CRLF 未命中,逐行补齐
  4. */
  5. const fs = require('fs');
  6. const F = 'pages/tianpan/relation-detail.vue';
  7. let src = fs.readFileSync(F, 'utf8');
  8. const MAP = [
  9. [" return '#6B7280'", " return BrandColors.textSlate"],
  10. [" 'parent': '#F97316',", " 'parent': BrandColors.primary,"],
  11. [" 'child': '#3B82F6',", " 'child': BrandColors.infoBlue,"],
  12. [" 'teacher': '#8B5CF6'", " 'teacher': BrandColors.violet"],
  13. ["return colorMap[this.relation.fromMemberRole] || '#6B7280'", "return colorMap[this.relation.fromMemberRole] || BrandColors.textSlate"],
  14. ["return colorMap[this.relation.toMemberRole] || '#6B7280'", "return colorMap[this.relation.toMemberRole] || BrandColors.textSlate"],
  15. [" return '#10B981'", " return BrandColors.success"],
  16. [" return '#F59E0B'", " return BrandColors.wealth"],
  17. [" return '#EF4444'", " return BrandColors.danger"],
  18. ];
  19. let n = 0;
  20. for (const [f, t] of MAP) {
  21. const cnt = src.split(f).length - 1;
  22. if (cnt === 0) { console.warn('NOT FOUND:', f); continue; }
  23. src = src.split(f).join(t);
  24. n += cnt;
  25. }
  26. // getScoreColor 的 if (!score) return '#6B7280'(4 空格缩进)
  27. if (src.includes(" if (!score) {\n return '#6B7280'")) { /* noop */ }
  28. const sCount = src.split(" if (!score) {").length - 1;
  29. console.log('if(!score) blocks:', sCount);
  30. fs.writeFileSync(F, src);
  31. console.log('replaced:', n);
  32. const lines = src.split('\n');
  33. let h = 0;
  34. for (let i = 0; i < lines.length; i++) {
  35. if (/#[0-9a-fA-F]{3,8}\b/.test(lines[i])) {
  36. const L = lines[i].trim();
  37. if (L.indexOf('$c-') !== 0) { console.log('HEX ' + (i + 1) + ': ' + L); h++; }
  38. }
  39. }
  40. console.log('remaining non-palette hex:', h);