فهرست منبع

feat: add emotion impact annotations to gut flora indicators on mind page

- Map each emotion-related gut flora indicator to its emotional function:
  serotonin/5-HT → mood stability, dopamine → pleasure/motivation,
  GABA → relaxation/stress relief, tryptophan → sleep/mood,
  melatonin → sleep regulation, cortisol → stress level
- Display '影响情绪稳定/影响愉悦·动力' etc. below each indicator name
- Fix value display bug: backend uses indicatorValue, frontend was reading broken ind.value
- Add indicatorBarWidth() and formatIndicatorValue() helper methods
- Add CSS for new gut-indicator-impact label (pink #FF6B9D for mind page)
E2E Test Bot 1 روز پیش
والد
کامیت
a9eed09e6c
1فایلهای تغییر یافته به همراه41 افزوده شده و 3 حذف شده
  1. 41 3
      cfc-frontend/pages/mind-detail/index.vue

+ 41 - 3
cfc-frontend/pages/mind-detail/index.vue

@@ -117,11 +117,12 @@
             <view class="gut-indicator-item" v-for="ind in gutIndicators" :key="ind.id">
             <view class="gut-indicator-item" v-for="ind in gutIndicators" :key="ind.id">
               <view class="gut-indicator-left">
               <view class="gut-indicator-left">
                 <text class="gut-indicator-name">{{ ind.indicatorName || ind.name }}</text>
                 <text class="gut-indicator-name">{{ ind.indicatorName || ind.name }}</text>
+                <text class="gut-indicator-impact" v-if="emotionImpactLabel(ind.indicatorName || ind.name)">影响{{ emotionImpactLabel(ind.indicatorName || ind.name) }}</text>
               </view>
               </view>
               <view class="gut-indicator-bar-track">
               <view class="gut-indicator-bar-track">
-                <view class="gut-indicator-bar-fill" :style="{ width: (ind.value || 0) + '%', background: indicatorColor(ind.status) }"></view>
+                <view class="gut-indicator-bar-fill" :style="{ width: indicatorBarWidth(ind), background: indicatorColor(ind.status) }"></view>
               </view>
               </view>
-              <text class="gut-indicator-value">{{ ind.value }}{{ ind.unit || '%' }}</text>
+              <text class="gut-indicator-value">{{ formatIndicatorValue(ind) }}{{ ind.unit || '%' }}</text>
               <text :class="['gut-indicator-status', 'status-' + (ind.status || 'normal')]">{{ statusLabel(ind.status) }}</text>
               <text :class="['gut-indicator-status', 'status-' + (ind.status || 'normal')]">{{ statusLabel(ind.status) }}</text>
             </view>
             </view>
           </view>
           </view>
@@ -726,6 +727,35 @@ var descList = descMap[this.dominantElement] || descMap.wood
       if (status === 'warning') return '警讯'
       if (status === 'warning') return '警讯'
       return status || '正常'
       return status || '正常'
     },
     },
+    // 情绪影响映射:指标名 → 影响的情绪功能
+    emotionImpactLabel: function(name) {
+      if (!name) return ''
+      if (name.indexOf('血清素') !== -1 || name.indexOf('5-HT') !== -1) return '情绪稳定'
+      if (name.indexOf('多巴胺') !== -1 || name.indexOf('Dopamine') !== -1) return '愉悦·动力'
+      if (name.indexOf('GABA') !== -1 || name.indexOf('氨基丁酸') !== -1) return '放松·减压'
+      if (name.indexOf('色氨酸') !== -1 || name.indexOf('Tryptophan') !== -1) return '睡眠·情绪'
+      if (name.indexOf('褪黑素') !== -1 || name.indexOf('Melatonin') !== -1) return '睡眠调节'
+      if (name.indexOf('皮质醇') !== -1 || name.indexOf('Cortisol') !== -1) return '压力水平'
+      return ''
+    },
+    // 指标值展示:后端字段为 indicatorValue,兼容数值型
+    formatIndicatorValue: function(ind) {
+      if (!ind) return ''
+      var v = ind.value !== undefined && ind.value !== null ? ind.value : ind.indicatorValue
+      if (v === undefined || v === null || v === '') return ''
+      return String(v)
+    },
+    // 指标条宽度:将指标值归一化为 0-100% 百分比
+    indicatorBarWidth: function(ind) {
+      var raw = ind.value !== undefined && ind.value !== null ? ind.value : ind.indicatorValue
+      var n = parseFloat(raw)
+      if (!isNaN(n) && n >= 0 && n <= 100) return n + '%'
+      if (!isNaN(n) && n > 100) return '100%'
+      var st = ind.status || ''
+      if (st === '偏低' || st === '缺乏' || st === 'abnormal') return '30%'
+      if (st === '偏高' || st === '过高') return '75%'
+      return '55%'
+    },
 
 
     // ===== EMI 分数评级 =====
     // ===== EMI 分数评级 =====
     getScoreLevel: function(score) {
     getScoreLevel: function(score) {
@@ -1926,12 +1956,20 @@ var descList = descMap[this.dominantElement] || descMap.wood
   gap: 12rpx;
   gap: 12rpx;
 }
 }
 .gut-indicator-left {
 .gut-indicator-left {
-  width: 80rpx;
+  width: 110rpx;
   flex-shrink: 0;
   flex-shrink: 0;
 }
 }
 .gut-indicator-name {
 .gut-indicator-name {
   font-size: 22rpx;
   font-size: 22rpx;
   color: #666;
   color: #666;
+  font-weight: 500;
+  display: block;
+}
+.gut-indicator-impact {
+  font-size: 18rpx;
+  color: #FF6B9D;
+  display: block;
+  margin-top: 2rpx;
 }
 }
 .gut-indicator-bar-track {
 .gut-indicator-bar-track {
   flex: 1;
   flex: 1;