d25-parent-index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/env node
  2. /**
  3. * D25: parent-index.vue 家长首页清理 (debt 57 -> 0)
  4. * 1) template 5 个五维自检图标内联色 -> 语义 class($dim-* 令牌)
  5. * 2) script 5 条渐变 -> BrandColors
  6. * 3) style 4 色 -> 全局令牌
  7. */
  8. const fs = require('fs');
  9. const F = 'pages/home-pages/parent-index.vue';
  10. let src = fs.readFileSync(F, 'utf8');
  11. let replaced = 0;
  12. function repl(from, to) {
  13. const cnt = src.split(from).length - 1;
  14. if (cnt === 0) { console.warn('NOT FOUND: ' + from.slice(0, 100)); return; }
  15. src = src.split(from).join(to);
  16. replaced += cnt;
  17. }
  18. // ---- 1. template 内联色 -> class ----
  19. repl('<view class="selfcheck-icon-circle" style="background: #FF8C42;">', '<view class="selfcheck-icon-circle selfcheck-icon-body">');
  20. repl('<view class="selfcheck-icon-circle" style="background: #6366F1;">', '<view class="selfcheck-icon-circle selfcheck-icon-wisdom">');
  21. repl('<view class="selfcheck-icon-circle" style="background: #F59E0B;">', '<view class="selfcheck-icon-circle selfcheck-icon-wealth">');
  22. repl('<view class="selfcheck-icon-circle" style="background: #10B981;">', '<view class="selfcheck-icon-circle selfcheck-icon-action">');
  23. repl('<view class="selfcheck-icon-circle" style="background: #FF6B9D;">', '<view class="selfcheck-icon-circle selfcheck-icon-mind">');
  24. // ---- 2. script 渐变 ----
  25. repl(" 'linear-gradient(135deg, #10B981, #34D399)',", " 'linear-gradient(135deg, ' + BrandColors.success + ', ' + BrandColors.successLight3 + ')',");
  26. repl(" 'linear-gradient(135deg, #0EA5E9, #38BDF8)',", " 'linear-gradient(135deg, ' + BrandColors.infoSky + ', ' + BrandColors.infoLight + ')',");
  27. repl(" 'linear-gradient(135deg, #8B5CF6, #C084FC)',", " 'linear-gradient(135deg, ' + BrandColors.violet + ', ' + BrandColors.violetLighter + ')',");
  28. repl(" 'linear-gradient(135deg, #F97316, #FB923C)',", " 'linear-gradient(135deg, ' + BrandColors.primary + ', ' + BrandColors.primaryLight + ')',");
  29. repl(" 'linear-gradient(135deg, #6366F1, #818CF8)'", " 'linear-gradient(135deg, ' + BrandColors.wisdom + ', ' + BrandColors.wisdomLight + ')'");
  30. // ---- 3. style ----
  31. repl('.pink-color { color: #EC4899; }', '.pink-color { color: $accent-pink; }');
  32. repl('background: linear-gradient(135deg, $status-success-tint-2, #ECFDF5);', 'background: linear-gradient(135deg, $status-success-tint-2, $status-success-tint);');
  33. repl('color: #065F46;', 'color: $status-success-strong;');
  34. repl('color: #9A3412;', 'color: $mat-orange-deep;');
  35. // ---- 4. 图标 class 定义(追加到 .selfcheck-icon-circle 规则后)----
  36. repl(
  37. '.selfcheck-icon-circle {',
  38. '// 五维自检图标底色(全局维度令牌)\n.selfcheck-icon-body { background: $dim-body; }\n.selfcheck-icon-wisdom { background: $dim-wisdom; }\n.selfcheck-icon-wealth { background: $dim-wealth; }\n.selfcheck-icon-action { background: $dim-action; }\n.selfcheck-icon-mind { background: $dim-mind; }\n\n.selfcheck-icon-circle {'
  39. );
  40. fs.writeFileSync(F, src);
  41. console.log('total replaced:', replaced);
  42. const lines = src.split('\n');
  43. let n = 0;
  44. for (let i = 0; i < lines.length; i++) {
  45. if (/#[0-9a-fA-F]{3,8}\b/.test(lines[i])) { console.log('HEX ' + (i + 1) + ': ' + lines[i].trim().slice(0, 110)); n++; }
  46. }
  47. console.log('remaining hex lines:', n);