小程序适配
All checks were successful
Deploy to Server / deploy (push) Successful in 58s

This commit is contained in:
jeremygan2021
2026-02-26 15:10:52 +08:00
parent 66cfbdd75b
commit 9215ec3b42
11 changed files with 453 additions and 150 deletions

View File

@@ -1,9 +1,9 @@
import React, { useState, useEffect } from 'react'
import Taro, { useRouter, useShareAppMessage, useDidShow } from '@tarojs/taro'
import { View, Text, Image, Video, RichText, Input, ScrollView } from '@tarojs/components'
import { View, Text, Image, Video, Input, ScrollView } from '@tarojs/components'
import { AtActivityIndicator, AtIcon, AtActionSheet, AtActionSheetItem, AtFloatLayout } from 'taro-ui'
import { getTopicDetail, createReply, uploadMedia, getStarUsers } from '../../../api'
import { marked } from 'marked'
import MarkdownReader from '../../../components/MarkdownReader'
import './detail.scss'
const ForumDetail = () => {
@@ -14,7 +14,6 @@ const ForumDetail = () => {
const [loading, setLoading] = useState(true)
const [replyContent, setReplyContent] = useState('')
const [sending, setSending] = useState(false)
const [htmlContent, setHtmlContent] = useState('')
const [userInfo, setUserInfo] = useState<any>(null)
// Star Users & Mention
@@ -30,14 +29,6 @@ const ForumDetail = () => {
const res = await getTopicDetail(Number(id))
const topicData = res.data || res
setTopic(topicData)
// Parse markdown
if (topicData.content) {
const html = marked.parse(topicData.content)
// Basic fix for images to fit screen
const styledHtml = (html as string).replace(/<img/g, '<img style="max-width:100%;border-radius:8px;"')
setHtmlContent(styledHtml)
}
} catch (error) {
console.error(error)
Taro.showToast({ title: '加载失败', icon: 'none' })
@@ -207,7 +198,7 @@ const ForumDetail = () => {
</View>
<View className='content'>
<RichText nodes={htmlContent} />
<MarkdownReader content={topic.content} />
</View>
{topic.media && topic.media.length > 0 && (
@@ -244,8 +235,7 @@ const ForumDetail = () => {
</View>
</View>
<View className='reply-content'>
{/* Simple markdown render for replies or just text if complex */}
<RichText nodes={marked.parse(reply.content) as string} />
<MarkdownReader content={reply.content} />
</View>
</View>
</View>