diff --git a/src/pages/integrated/notice/detail.vue b/src/pages/integrated/notice/detail.vue index 2754613..48f0844 100644 --- a/src/pages/integrated/notice/detail.vue +++ b/src/pages/integrated/notice/detail.vue @@ -1,5 +1,5 @@ - + @@ -66,8 +66,36 @@ const goGetCoupon = () => { uni.navigateTo({ url: `/pages/merchant/merchant-activity?actId=${actDetail.value.actId}&actType=${actDetail.value.actType}` }) } +const normalizeRichText = (html: string) => { + const origin = "https://stgl.pj.gov.cn" + return html.replace(/]*>/gi, (imgTag) => { + let next = imgTag + + next = next.replace(/\bsrc\s*=\s*(['"])(.*?)\1/i, (_m, quote: string, src: string) => { + let resolved = src + if (resolved?.startsWith("/api")) resolved = `${origin}${resolved}` + if (resolved?.startsWith("//")) resolved = `https:${resolved}` + return `src=${quote}${resolved}${quote}` + }) + + const styleMatch = next.match(/\bstyle\s*=\s*(['"])([\s\S]*?)\1/i) + const required = "max-width: 100%; height: auto; display: block;" + if (styleMatch) { + const quote = styleMatch[1] + const styleValue = styleMatch[2] ?? "" + if (styleValue.includes("max-width") || styleValue.includes("width")) return next + const merged = styleValue.trim().length ? `${styleValue.replace(/;?\s*$/, "; ")}${required}` : required + return next.replace(/\bstyle\s*=\s*(['"])([\s\S]*?)\1/i, `style=${quote}${merged}${quote}`) + } + + return next.replace(/ { - return detail.value.description?.replaceAll(` - - - {{ detail.title || "加载中..." }} + + + + {{ detail.title || "加载中..." }} + + 加载中... + {{ error }} + + + - - 加载中... - {{ error }} - - - - +