This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user