Эх сурвалжийг харах

refactor(beautify): D22 FamilyTianpanCard 家庭天盘卡片清理 (debt 60->0)

- 修复 C 批字符串 bug:'BrandColors.success' 等 4 处 -> 变量引用
- 五行/方位色 3 处对象 + themeColor 默认值/兜底全部收编 BrandColors.*
- canvas 外圈底 #FFF5F7 -> BrandColors.blush;#9CA3AF -> textGray400
- 兜底 #94A3B8 -> appTextSubtle;注释内 hex 移除
- hex 20->0;P1 2->1
liaoxg 5 өдөр өмнө
parent
commit
09d3e5b983

+ 21 - 21
cfc-frontend/pages/mind-detail/components/FamilyTianpanCard.vue

@@ -1,5 +1,5 @@
 <template>
-  <!-- 家庭天盘卡片 — 心维度专属 (#FF6B9D 火) -->
+  <!-- 家庭天盘卡片 — 心维度专属(火维度色) -->
   <view class="tianpan-card" v-if="visible" :style="themeStyle">
     <!-- 卡片头部 -->
     <view class="tp-header">
@@ -162,7 +162,7 @@ export default {
       canvasReady: false,
       _compassW: 0,
       _compassH: 0,
-      themeColor: '#FF6B9D', // 默认火维度颜色
+      themeColor: BrandColors.mind, // 默认火维度颜色
       _animFrameId: null,
       _clickableAreas: [],
       // 五行 → 方位映射
@@ -175,11 +175,11 @@ export default {
       },
       // 方位 → 颜色映射
       dirColorMap: {
-        '东': 'BrandColors.success',
-        '南': '#FF6B9D',
-        '中': 'BrandColors.body',
-        '西': 'BrandColors.wisdom',
-        '北': '#3B82F6'
+        '东': BrandColors.success,
+        '南': BrandColors.mind,
+        '中': BrandColors.body,
+        '西': BrandColors.wisdom,
+        '北': BrandColors.infoBlue
       },
       // 方位 → 角度(从北顺时针,Canvas 默认从右/东开始)
       dirAngleMap: {
@@ -224,10 +224,10 @@ export default {
     },
     luckyElementColor: function() {
       var dir = this.luckyDirection
-      return this.dirColorMap[dir] || '#FF6B9D'
+      return this.dirColorMap[dir] || BrandColors.mind
     },
     themeStyle: function() {
-      var color = this.themeColor || '#FF6B9D'
+      var color = this.themeColor || BrandColors.mind
       var lighter = color + '15'
       var borderColor = color + '20'
       var shadowColor = color + '25'
@@ -251,7 +251,7 @@ export default {
     },
     wuxingData: function() {
       if (!this.traditionalData || !this.traditionalData.wuxingElements) return []
-      var colorMap = { wood: 'BrandColors.success', fire: '#FF6B9D', earth: 'BrandColors.body', metal: 'BrandColors.wisdom', water: '#3B82F6' }
+      var colorMap = { wood: BrandColors.success, fire: BrandColors.mind, earth: BrandColors.body, metal: BrandColors.wisdom, water: BrandColors.infoBlue }
       var labelMap = { wood: '木', fire: '火', earth: '土', metal: '金', water: '水' }
       var elements = this.traditionalData.wuxingElements
       var result = []
@@ -261,7 +261,7 @@ export default {
             key: key,
             label: labelMap[key] || key,
             value: elements[key] || 0,
-            color: colorMap[key] || '#94A3B8'
+            color: colorMap[key] || BrandColors.appTextSubtle
           })
         }
       }
@@ -360,10 +360,10 @@ export default {
         self._compassH = h
         
         // 设置初始主题色(火维度)
-        self.themeColor = '#FF6B9D'
+        self.themeColor = BrandColors.mind
         if (self.fortune && self.fortune.dominantElement) {
           var elementColors = {
-            木: 'BrandColors.success', 火: '#FF6B9D', 土: 'BrandColors.body', 金: 'BrandColors.wisdom', 水: '#3B82F6'
+            木: BrandColors.success, 火: BrandColors.mind, 土: BrandColors.body, 金: BrandColors.wisdom, 水: BrandColors.infoBlue
           }
           self.themeColor = elementColors[self.fortune.dominantElement]
         }
@@ -447,11 +447,11 @@ export default {
         { label: '中', element: 'earth', angle: null }
       ]
       var elementColors = {
-        wood: 'BrandColors.success',
-        fire: '#FF6B9D',
-        earth: 'BrandColors.body',
-        metal: 'BrandColors.wisdom',
-        water: '#3B82F6'
+        wood: BrandColors.success,
+        fire: BrandColors.mind,
+        earth: BrandColors.body,
+        metal: BrandColors.wisdom,
+        water: BrandColors.infoBlue
       }
 
       var luckyDir = this.luckyDirection.replace('方', '')
@@ -468,7 +468,7 @@ export default {
       // 外圈背景
       ctx.beginPath()
       ctx.arc(cx, cy, outerR, 0, Math.PI * 2)
-      ctx.fillStyle = '#FFF5F7'
+      ctx.fillStyle = BrandColors.blush
       ctx.fill()
       ctx.strokeStyle = hexToRgba(luckyColor, 0.25)
       ctx.lineWidth = 1.5
@@ -506,7 +506,7 @@ export default {
           ctx.stroke()
         }
 
-        ctx.fillStyle = isLucky ? luckyColor : '#9CA3AF'
+        ctx.fillStyle = isLucky ? luckyColor : BrandColors.textGray400
         ctx.font = (isLucky ? 'bold ' : '') + '10px sans-serif'
         ctx.textAlign = 'center'
         ctx.textBaseline = 'middle'
@@ -563,7 +563,7 @@ export default {
               content: '这里是家里' + elem.name + '能量最旺的方向!\n' + elem.description + ',记得多在这个方向活动哦~',
               confirmText: '知道啦',
               showCancel: false,
-              confirmColor: self.themeColor || '#FF6B9D'
+              confirmColor: self.themeColor || BrandColors.mind
             })
             break
           }

+ 56 - 0
cfc-frontend/scripts/d22-family-tianpan-card.js

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