Browse Source

fix(frontend): article pages use API_BASE_URL for uploaded cover images

Convert relative coverImage paths to absolute URLs via config.API_BASE_URL in article-center and mind article pages.

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

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Xiaogang Liao 1 month ago
parent
commit
e327a0ef

+ 5 - 1
cfc-frontend/pages/article-center/index.vue

@@ -83,7 +83,7 @@
           <view class="ac-card-media">
             <image
               class="ac-card-cover"
-              :src="item.coverImage || '/static/default-article.png'"
+              :src="getImageUrl(item.coverImage) || '/static/default-article.png'"
               mode="aspectFill"
             />
             <view class="ac-card-dimension-tags" v-if="item.relatedDimensions">
@@ -131,6 +131,7 @@
 
 <script>
 import { getArticleList, getFeaturedArticles } from '@/utils/api.js'
+import config from '@/config.js'
 export default {
   data() {
     return {
@@ -286,6 +287,9 @@ export default {
     },
     onBack() {
       uni.navigateBack()
+    },
+    getImageUrl: function(path) {
+      return config.API_BASE_URL + path
     }
   }
 }

+ 5 - 1
cfc-frontend/pages/article-center/my-posts.vue

@@ -16,7 +16,7 @@
           <image
             v-if="item.coverImage"
             class="post-cover"
-            :src="item.coverImage"
+            :src="getImageUrl(item.coverImage)"
             mode="aspectFill"
           />
           <view class="post-body">
@@ -48,6 +48,7 @@
 
 <script>
 import { getMyPosts } from '@/utils/api.js'
+import config from '@/config.js'
 
 export default {
   data() {
@@ -117,6 +118,9 @@ export default {
       if (item.auditStatus === 'pending') return 'status-pending'
       if (item.auditStatus === 'rejected') return 'status-rejected'
       return 'status-draft'
+    },
+    getImageUrl: function(path) {
+      return config.API_BASE_URL + path
     }
   }
 }

+ 5 - 1
cfc-frontend/pages/mind-detail/articles.vue

@@ -56,7 +56,7 @@
         >
           <image
             class="article-cover"
-            :src="item.coverImage || '/static/default-article.png'"
+            :src="getImageUrl(item.coverImage) || '/static/default-article.png'"
             mode="aspectFill"
           />
           <view class="article-body">
@@ -94,6 +94,7 @@
 <script>
 import PageBanner from '../../components/PageBanner.vue'
 import { getArticleCategories, getArticleList } from '../../utils/api.js'
+import config from '@/config.js'
 
 var dimensionConfig = {
   all:   { label: '全部', color: '#64748B', theme: 'mind-wisdom', tagline: '探索知识,滋养成长', quote: '学而时习之,不亦说乎' },
@@ -241,6 +242,9 @@ export default {
     },
     goDetail(id) {
       uni.navigateTo({ url: '/pages/article-center/article-detail?id=' + id })
+    },
+    getImageUrl: function(path) {
+      return config.API_BASE_URL + path
     }
   }
 }

+ 7 - 3
cfc-frontend/pages/mind-extra/articles.vue

@@ -84,7 +84,7 @@
           >
             <image
               class="article-cover"
-              :src="item.coverImage || '/static/default-article.png'"
+              :src="getImageUrl(item.coverImage) || '/static/default-article.png'"
               mode="aspectFill"
             />
             <view class="article-body">
@@ -123,6 +123,7 @@
 <script>
 import PageBanner from '../../components/PageBanner.vue'
 import { getArticleCategories, getArticleList, getFeaturedArticles } from '../../utils/api.js'
+import config from '@/config.js'
 
 var dimensionConfig = {
   all:   { label: '全部', color: '#64748B', theme: 'mind-wisdom', tagline: '探索知识,滋养成长', quote: '学而时习之,不亦说乎' },
@@ -331,11 +332,14 @@ export default {
     },
     onSearchBlur: function() {
       if (!this.searchKeyword) {
-        this.searchFocused = false
-      }
+      this.searchFocused = false
+    },
+    getImageUrl: function(path) {
+      return config.API_BASE_URL + path
     }
   }
 }
+}
 </script>
 
 <style scoped>