Просмотр исходного кода

fix(frontend): 关卡页与报告渲染组件 :key 改为方法调用,消除非h5平台编译告警

liaoxg 1 месяц назад
Родитель
Сommit
dc090f4b63

+ 2 - 1
cfc-frontend/components/report-blocks-renderer.vue

@@ -11,7 +11,7 @@
               </view>
               <text class="score-label">{{ item.label }}</text>
               <view class="sub-items" v-if="item.subItems && item.subItems.length" style="margin-top:8rpx; display:flex; flex-direction:column; align-items:center;">
-                <view class="sub-item" v-for="(sub, ssi) in item.subItems" :key="'sub'+ssi" style="display:flex; flex-direction:row; align-items:center;">
+                <view class="sub-item" v-for="(sub, ssi) in item.subItems" :key="getSubKey(ssi)" style="display:flex; flex-direction:row; align-items:center;">
                   <text class="sub-label" style="font-size:20rpx; color:#666; margin-right:4rpx;">{{ sub.label }}:</text>
                   <text class="sub-value" style="font-size:20rpx; color:#333;">{{ sub.value }}</text>
                 </view>
@@ -78,6 +78,7 @@ export default {
   methods: {
     getBlockKey: function(bi) { return 'b' + bi },
     getScoreKey: function(si) { return 's' + si },
+  getSubKey: function(ssi) { return 'sub' + ssi },
     getRiskKey: function(ri) { return 'r' + ri },
     getIndicatorKey: function(ii) { return 'i' + ii },
     getColumnKey: function(ci) { return 'c' + ci },

+ 4 - 3
cfc-frontend/pages/profile-extra/gates.vue

@@ -3,7 +3,7 @@
   <view class="page-section" v-if="mainGates.length > 0">
     <text class="section-title">主线关卡</text>
     <view class="gate-list">
-      <view class="gate-card" v-for="(g, i) in mainGates" :key="g.id || i"
+      <view class="gate-card" v-for="(g, i) in mainGates" :key="getGateKey(g, i)"
         :class="'gate-card--' + (g.status === 'UNLOCKED' ? 'done' : (g.status === 'CURRENT' ? 'current' : 'locked'))">
         <view class="gate-status-icon">
           <text v-if="g.status === 'UNLOCKED'">✅</text>
@@ -32,7 +32,7 @@
     <text class="section-title">推荐挑战</text>
     <view class="gate-list">
       <view class="gate-card" :class="'gate-card--' + (g.status === 'UNLOCKED' ? 'done' : 'current')"
-        v-for="(g, i) in softGates" :key="'soft' + (g.id || i)">
+        v-for="(g, i) in softGates" :key="getGateKey(g, i)">
         <view class="gate-status-icon">
           <text v-if="g.status === 'UNLOCKED'">✅</text>
           <text v-else>🎯</text>
@@ -57,7 +57,7 @@
   <view class="page-section" v-if="valueGates.length > 0">
     <text class="section-title">增值关卡</text>
     <view class="gate-list">
-      <view class="gate-card gate-card--value" v-for="(g, i) in valueGates" :key="'val' + (g.id || i)">
+      <view class="gate-card gate-card--value" v-for="(g, i) in valueGates" :key="getGateKey(g, i)">
         <view class="gate-status-icon">
           <text v-if="g.status === 'UNLOCKED'">✅</text>
           <text v-else>💎</text>
@@ -110,6 +110,7 @@ export default {
     this.loadData()
   },
   methods: {
+    getGateKey: function(g, i) { return (g && g.id) ? g.id : i },
     loadData: function() {
       var self = this
       self.loading = true