Преглед изворни кода

fix(frontend): base config/components use API_BASE_URL for uploaded image URLs

Convert relative uploaded image paths to absolute URLs via config.API_BASE_URL in shared components and config; fixes mini-program image load 500.

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

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Xiaogang Liao пре 3 месеци
родитељ
комит
da1339cf2c

+ 6 - 1
cfc-frontend/components/ArticleBookshelf.vue

@@ -63,7 +63,7 @@
               <image
                 v-if="article.coverImage"
                 class="bs-cover-img"
-                :src="article.coverImage"
+                :src="getImageUrl(article.coverImage)"
                 mode="aspectFill"
               />
 
@@ -121,6 +121,8 @@
 
 <script>
 // 五维配色体系(书脊颜色)
+import config from '@/config.js'
+
 var DIMENSION_COLORS = {
   body:    { bg: 'linear-gradient(180deg, #FF8C42 0%, #E8762A 100%)', text: '#FFF5EE' },
   mind:    { bg: 'linear-gradient(180deg, #FF6B9D 0%, #E84A7F 100%)', text: '#FFF0F5' },
@@ -196,6 +198,9 @@ export default {
       }
       return FALLBACK_GRADIENTS[idx % FALLBACK_GRADIENTS.length].text
     },
+    getImageUrl: function(path) {
+      return config.API_BASE_URL + path
+    },
     getCategoryLabel: function(article) {
       if (!article) return '推荐'
       if (article.categoryName) return article.categoryName

+ 6 - 1
cfc-frontend/components/DimensionActivities.vue

@@ -37,7 +37,7 @@
             <!-- 封面图(占满卡片高度) -->
             <image
               class="card-cover-img"
-              :src="act.coverImage || '/static/default-activity.png'"
+              :src="getImageUrl(act.coverImage) || '/static/default-activity.png'"
               mode="aspectFill"
             />
             <!-- 右侧信息区 -->
@@ -86,6 +86,8 @@
 </template>
 
 <script>
+import config from '@/config.js'
+
 var DIMENSION_MAP = {
   body: { name: '身', color: '#FF8C42', icon: '🌏' },
   mind: { name: '心', color: '#FF6B9D', icon: '🔥' },
@@ -182,6 +184,9 @@ export default {
     formatPriceWithSymbol: function(price) {
       if (price == null) return '免费'
       return '¥' + (Number(price) / 100).toFixed(2)
+    },
+    getImageUrl: function(path) {
+      return config.API_BASE_URL + path
     }
   }
 }

+ 5 - 1
cfc-frontend/components/DimensionProducts.vue

@@ -9,7 +9,7 @@
     </view>
     <view class="product-list" v-if="displayProducts.length > 0">
       <view class="product-card" v-for="prod in displayProducts" :key="prod.id" @click="onProductClick(prod)">
-        <image class="product-img" :src="prod.coverImage || '/static/default-product.png'" mode="aspectFill" />
+        <image class="product-img" :src="getImageUrl(prod.coverImage) || '/static/default-product.png'" mode="aspectFill" />
         <text class="product-name line-clamp-2">{{ prod.name }}</text>
         <view class="weight-badges" v-if="prod._badges && prod._badges.length">
           <text class="weight-badge" v-for="badge in prod._badges" :key="badge.name" :style="{ background: badge.color + '20', color: badge.color }">{{ badge.name }}{{ badge.weight }}%</text>
@@ -33,6 +33,7 @@
 
 <script>
 import { getDimensionProducts, clickRepurchaseReminder } from '../utils/api.js'
+import config from '@/config.js'
 
 var DIMENSION_MAP = {
   body: { name: '身', color: '#FF8C42' },
@@ -135,6 +136,9 @@ export default {
       } catch (e) {
         return []
       }
+    },
+    getImageUrl: function(path) {
+      return config.API_BASE_URL + path
     }
   }
 }

+ 7 - 2
cfc-frontend/components/RecommendedFeed.vue

@@ -25,7 +25,7 @@
         >
           <!-- 商品卡片 -->
           <template v-if="item.type === 'product'">
-            <image class="feed-img" :src="item.coverImage || '/static/default-product.png'" mode="aspectFill" />
+            <image class="feed-img" :src="getImageUrl(item.coverImage) || '/static/default-product.png'" mode="aspectFill" />
             <view class="feed-info">
               <view class="feed-tag-row">
                 <text class="feed-type-badge product-badge">🛍️ 商品</text>
@@ -38,7 +38,7 @@
           </template>
           <!-- 活动卡片 -->
           <template v-else-if="item.type === 'activity'">
-            <image class="feed-img" :src="item.coverImage || '/static/default-activity.png'" mode="aspectFill" />
+            <image class="feed-img" :src="getImageUrl(item.coverImage) || '/static/default-activity.png'" mode="aspectFill" />
             <view class="feed-info">
               <view class="feed-tag-row">
                 <text class="feed-type-badge activity-badge">🔥 活动</text>
@@ -60,6 +60,8 @@
 </template>
 
 <script>
+import config from '@/config.js'
+
 export default {
   props: {
     products: { type: Array, default: function() { return [] } },
@@ -124,6 +126,9 @@ export default {
     getStatusClass: function(status) {
       var map = { upcoming: 'status-upcoming', ongoing: 'status-ongoing', ended: 'status-ended' }
       return map[status] || ''
+    },
+    getImageUrl: function(path) {
+      return config.API_BASE_URL + path
     }
   }
 }

+ 0 - 1
cfc-frontend/config.js

@@ -52,7 +52,6 @@ export default {
   LANGGRAPH_BASE_URL,
   DIFY_BASE_URL,
 
-  /** 构建 API 完整 URL */
   api(path) {
     return API_BASE_URL + path
   }