d22-family-tianpan-card.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env node
  2. /**
  3. * D22: FamilyTianpanCard.vue 家庭天盘卡片清理 (debt 60)
  4. * 修复 C 批字符串 bug + 五行/方位色收编 BrandColors + canvas 色收编
  5. */
  6. const fs = require('fs');
  7. const F = 'pages/mind-detail/components/FamilyTianpanCard.vue';
  8. let src = fs.readFileSync(F, 'utf8');
  9. let replaced = 0;
  10. function repl(from, to) {
  11. const cnt = src.split(from).length - 1;
  12. if (cnt === 0) { console.warn('NOT FOUND: ' + from.slice(0, 100)); return; }
  13. src = src.split(from).join(to);
  14. replaced += cnt;
  15. }
  16. // ---- 1. 修复 C 批字符串 bug('BrandColors.x' -> BrandColors.x)----
  17. repl("'BrandColors.success'", "BrandColors.success");
  18. repl("'BrandColors.body'", "BrandColors.body");
  19. repl("'BrandColors.wisdom'", "BrandColors.wisdom");
  20. // ---- 2. themeColor 默认值 ----
  21. repl("themeColor: '#FF6B9D', // 默认火维度颜色", "themeColor: BrandColors.mind, // 默认火维度颜色");
  22. repl("self.themeColor = '#FF6B9D'", "self.themeColor = BrandColors.mind");
  23. // ---- 3. 方位色映射 ----
  24. repl(" '南': '#FF6B9D',", " '南': BrandColors.mind,");
  25. repl(" '北': '#3B82F6'", " '北': BrandColors.infoBlue");
  26. // ---- 4. 五行色映射(3 处对象,统一 fire/water)----
  27. repl("fire: '#FF6B9D'", "fire: BrandColors.mind");
  28. repl("火: '#FF6B9D'", "火: BrandColors.mind");
  29. repl("水: '#3B82F6'", "水: BrandColors.infoBlue");
  30. repl("water: '#3B82F6'", "water: BrandColors.infoBlue");
  31. // ---- 5. 兜底色 ----
  32. repl("colorMap[key] || '#94A3B8'", "colorMap[key] || BrandColors.appTextSubtle");
  33. repl("ctx.fillStyle = isLucky ? luckyColor : '#9CA3AF'", "ctx.fillStyle = isLucky ? luckyColor : BrandColors.textGray400");
  34. repl("ctx.fillStyle = '#FFF5F7'", "ctx.fillStyle = BrandColors.blush");
  35. // ---- 6. 其余残留 ----
  36. repl("return this.dirColorMap[dir] || '#FF6B9D'", "return this.dirColorMap[dir] || BrandColors.mind");
  37. repl("var color = this.themeColor || '#FF6B9D'", "var color = this.themeColor || BrandColors.mind");
  38. repl("confirmColor: self.themeColor || '#FF6B9D'", "confirmColor: self.themeColor || BrandColors.mind");
  39. fs.writeFileSync(F, src);
  40. console.log('total replaced:', replaced);
  41. const lines = src.split('\n');
  42. let n = 0;
  43. for (let i = 0; i < lines.length; i++) {
  44. const L = lines[i].trim();
  45. if (/#[0-9a-fA-F]{3,8}\b/.test(L) && L.charAt(0) !== '$') { console.log('HEX ' + (i + 1) + ': ' + L.slice(0, 110)); n++; }
  46. }
  47. console.log('remaining non-palette hex:', n);