Bläddra i källkod

perf(DimensionActivities): pre-compute display values in computed to avoid template method calls

formatTime/statusText/formatPriceWithSymbol 从模板移入 computed displayActivities
避免 swiper autoplay 触发每次 re-render 时重复调用方法

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
liaoxg 1 månad sedan
förälder
incheckning
8b194e6178
1 ändrade filer med 17 tillägg och 5 borttagningar
  1. 17 5
      cfc-frontend/components/DimensionActivities.vue

+ 17 - 5
cfc-frontend/components/DimensionActivities.vue

@@ -46,7 +46,7 @@
               <view class="card-meta-row">
                 <view class="card-time">
                   <text class="meta-icon">🕐</text>
-                  <text class="meta-text">{{ formatTime(act.startTime) }}</text>
+                  <text class="meta-text">{{ act._timeText }}</text>
                 </view>
                 <view class="card-badges" v-if="act._badges && act._badges.length">
                   <text
@@ -61,10 +61,10 @@
               </view>
               <view class="card-bottom">
                 <text class="card-status" :class="'status-' + (act.status || 'upcoming')">
-                  {{ statusText(act.status) }}
+                  {{ act._statusText }}
                 </text>
                 <text class="card-price" v-if="act.priceLabel">{{ act.priceLabel }}</text>
-                <text class="card-price" v-else-if="act.price && act.price > 0">{{ formatPriceWithSymbol(act.price) }}</text>
+                <text class="card-price" v-else-if="act.price && act.price > 0">{{ act._priceDisplay }}</text>
                 <text class="card-price-free" v-else>免费</text>
               </view>
             </view>
@@ -109,8 +109,20 @@ export default {
     displayActivities: function() {
       var self = this
       return (this.activities || []).slice(0, 3).map(function(item) {
-        item._badges = self.parseWeights(item.dimensionWeights)
-        return item
+        return {
+          id: item.id,
+          title: item.title,
+          coverImage: item.coverImage,
+          startTime: item.startTime,
+          status: item.status,
+          price: item.price,
+          priceLabel: item.priceLabel,
+          dimensionWeights: item.dimensionWeights,
+          _badges: self.parseWeights(item.dimensionWeights),
+          _timeText: self.formatTime(item.startTime),
+          _statusText: self.statusText(item.status),
+          _priceDisplay: self.formatPriceWithSymbol(item.price)
+        }
       })
     },
     dimensionIcon: function() {