From 074aa7ab3e1fb880d909048c98f39e7c4361ec94 Mon Sep 17 00:00:00 2001 From: hajimi Date: Sun, 5 Jul 2026 11:43:30 +0800 Subject: [PATCH] deploy: auto commit repo-root changes 2026-07-05 11:43:29 --- uniapp/src/pages/news_detail/news_detail.vue | 35 +++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/uniapp/src/pages/news_detail/news_detail.vue b/uniapp/src/pages/news_detail/news_detail.vue index 832eca7..31010ca 100644 --- a/uniapp/src/pages/news_detail/news_detail.vue +++ b/uniapp/src/pages/news_detail/news_detail.vue @@ -40,7 +40,8 @@
- + {{ block.translated }} @@ -268,12 +269,36 @@ const translatedTitle = computed(() => translatedParts.value.title) const translatedAbstract = computed(() => translatedParts.value.abstract) const translatedBodyLines = computed(() => translatedParts.value.body) +const richTextTagStyle = { + p: 'margin:0;line-height:1.52;font-size:22rpx;color:#333;word-break:break-word;', + div: 'margin:0;line-height:1.52;font-size:22rpx;color:#333;word-break:break-word;', + li: 'margin:0;line-height:1.52;font-size:22rpx;color:#333;word-break:break-word;', + h1: 'margin:8rpx 0;font-size:34rpx;font-weight:700;line-height:1.35;color:#1f2937;', + h2: 'margin:8rpx 0;font-size:30rpx;font-weight:700;line-height:1.38;color:#1f2937;', + h3: 'margin:8rpx 0;font-size:28rpx;font-weight:700;line-height:1.4;color:#1f2937;', + blockquote: 'margin:8rpx 0;padding:8rpx 16rpx;border-left:6rpx solid #d6def2;background:#f7f9fc;color:#4b5563;', + img: 'max-width:100%;height:auto;display:block;margin:10px 0;', +} + +const normalizeImageAttrs = (attrs: string) => { + let normalized = String(attrs || '').replace(/\/\s*$/, '').trim() + if (!/\breferrerpolicy\s*=/i.test(normalized)) { + normalized = `${normalized} referrerpolicy="no-referrer"`.trim() + } + + const imageStyle = 'max-width:100%;height:auto;display:block;margin:10px 0;' + const styleMatch = normalized.match(/(^|\s)style=(["'])(.*?)\2/i) + if (styleMatch) { + const mergedStyle = `${styleMatch[3].replace(/;?\s*$/, ';')}${imageStyle}` + return normalized.replace(styleMatch[0], `${styleMatch[1]}style=${styleMatch[2]}${mergedStyle}${styleMatch[2]}`) + } + + return `${normalized} style="${imageStyle}"`.trim() +} + const normalizeHtml = (html: string) => { if (!html) return '' - return String(html).replace( - /]*)>/gi, - '' - ) + return String(html).replace(/]*)>/gi, (_match, attrs = '') => ``) } const stripHtmlText = (html: string) => {