From e6152cb932e2927ff942b9d091dcf6ef6b65b111 Mon Sep 17 00:00:00 2001 From: Pine Date: Thu, 27 Aug 2026 15:01:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(content):=20C=E7=AB=AF=E6=AD=A3=E6=96=87?= =?UTF-8?q?=E5=AF=8C=E6=96=87=E6=9C=AC=E6=B8=B2=E6=9F=93(HTML)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 小程序 content-detail: 渲染 HTML(图片/视频/排版),样式对齐 - 网站 Content.jsx 详情展开:dangerouslySetInnerHTML 渲染富文本 Co-Authored-By: Claude --- miniprogram/src/pages/content-detail/index.jsx | 6 ++++-- miniprogram/src/pages/content-detail/index.scss | 4 +++- website/src/user/Content.jsx | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/miniprogram/src/pages/content-detail/index.jsx b/miniprogram/src/pages/content-detail/index.jsx index 95f0d1e..24972e0 100644 --- a/miniprogram/src/pages/content-detail/index.jsx +++ b/miniprogram/src/pages/content-detail/index.jsx @@ -1,4 +1,4 @@ -import { View, Text, Image, Video, ScrollView, Button } from '@tarojs/components'; +import { View, Text, Image, Video, ScrollView, Button, RichText } from '@tarojs/components'; import Taro from '@tarojs/taro'; import { useState, useEffect } from 'react'; import { getContent } from '@/utils/content'; @@ -45,7 +45,9 @@ export default function ContentDetail() { {item.summary ? {item.summary} : null} - {item.body || '暂无正文'} + {item.body + ? + : 暂无正文} {/* 图集 */} {images.length > 0 && ( diff --git a/miniprogram/src/pages/content-detail/index.scss b/miniprogram/src/pages/content-detail/index.scss index 75874e2..651f16a 100644 --- a/miniprogram/src/pages/content-detail/index.scss +++ b/miniprogram/src/pages/content-detail/index.scss @@ -9,7 +9,9 @@ .cd-dot { font-size: 24rpx; color: #6d6d72; } .cd-meta-at { font-size: 24rpx; color: #7c7c80; } .cd-summary { display: block; margin: 20rpx 28rpx 0; font-size: 27rpx; color: #c4c2c3; line-height: 1.7; } -.cd-body { display: block; margin: 20rpx 28rpx 0; font-size: 28rpx; color: #e4e4e6; line-height: 1.8; white-space: pre-wrap; } +.cd-body { display: block; margin: 20rpx 28rpx 0; font-size: 28rpx; color: #e4e4e6; line-height: 1.8; } +.cd-body img, .cd-body video { max-width: 100%; border-radius: 14rpx; } +.cd-body p { margin: 0 0 8rpx; } .cd-gallery { display: flex; gap: 12rpx; margin: 24rpx 28rpx 0; white-space: nowrap; } .cd-gal-img { width: 240rpx; height: 240rpx; border-radius: 14rpx; flex-shrink: 0; margin-right: 12rpx; } .cd-link { margin: 28rpx 28rpx 0; } diff --git a/website/src/user/Content.jsx b/website/src/user/Content.jsx index 93c26ca..c798b6d 100644 --- a/website/src/user/Content.jsx +++ b/website/src/user/Content.jsx @@ -69,7 +69,7 @@ function NewsCard({ it, big, open, onToggle }) { {open && (
{it.summary &&

{it.summary}

} -

{it.body || '暂无正文'}

+
{Array.isArray(it.images) && it.images.length > 0 && (
{it.images.map((u, i) => )}