xsh_1997 преди 2 дни
родител
ревизия
1bd10f9a06
променени са 2 файла, в които са добавени 6 реда и са изтрити 3 реда
  1. 2 1
      shop-app/utils/goodsDetail.js
  2. 4 2
      shop-app/utils/htmlContent.js

+ 2 - 1
shop-app/utils/goodsDetail.js

@@ -1,4 +1,5 @@
1 1
 import { resolveFileUrl } from '@/utils/image'
2
+import { prepareRichHtml } from '@/utils/htmlContent'
2 3
 import { formatPrice } from '@/utils/format'
3 4
 import { PAGE_GOODS_DETAIL } from '@/utils/pageRoute'
4 5
 import { joinCartSpecParts } from '@/utils/cartSpec'
@@ -40,7 +41,7 @@ export function mapGoodsDetail(data) {
40 41
     goodsStatus: data.goodsStatus,
41 42
     goodsStatusLabel: data.goodsStatusLabel,
42 43
     categoryPath: data.categoryPath,
43
-    detailContent: data.detailContent || '',
44
+    detailContent: prepareRichHtml(data.detailContent),
44 45
     attributes: data.attributes || [],
45 46
     specDisplay: data.specDisplay || [],
46 47
     services: (data.services || []).map(mapService),

+ 4 - 2
shop-app/utils/htmlContent.js

@@ -28,11 +28,13 @@ export function decodeHtmlEntities(html) {
28 28
   return s
29 29
 }
30 30
 
31
-/** 富文本 img 相对路径转完整 URL */
31
+/** 富文本 img 相对路径转完整 URL(Quill 常存 /dev-api/profile/...) */
32 32
 export function fixHtmlImageSrc(html) {
33 33
   if (!html) return ''
34 34
   return html.replace(/src=(["'])([^"']+)\1/gi, (match, quote, src) => {
35
-    const full = resolveFileUrl(src)
35
+    // 去掉代理前缀,再走 resolveFileUrl 拼成小程序/rich-text 可用的完整地址
36
+    const path = String(src).trim().replace(/^\/(dev-api|prod-api|shop-api)/i, '')
37
+    const full = resolveFileUrl(path)
36 38
     return full ? `src=${quote}${full}${quote}` : match
37 39
   })
38 40
 }