import React, { useState } from 'react'; import { useParams } from '@umijs/max'; import { Card, Avatar, Typography, Space, Divider, Button, Input, message, Tag, List, } from 'antd'; import { LikeOutlined, LikeFilled, StarOutlined, StarFilled, ShareAltOutlined, } from '@ant-design/icons'; const { Title, Paragraph } = Typography; const { TextArea } = Input; // Mock comment data const mockComments = [ { id: 1, author: '张三', avatar: 'https://joeschmoe.io/api/v1/random', content: '这个帖子很有帮助,感谢分享!', createTime: '2024-03-20 10:00', likes: 5, }, { id: 2, author: '李四', avatar: 'https://joeschmoe.io/api/v1/random', content: '我也有一些补充,大家可以参考一下...', createTime: '2024-03-20 11:30', likes: 3, }, { id: 3, author: '王五', avatar: 'https://joeschmoe.io/api/v1/random', content: '学到了很多新知识,期待更多分享!', createTime: '2024-03-20 14:15', likes: 2, }, ]; const ForumDetail: React.FC = () => { const { id } = useParams(); const [liked, setLiked] = useState(false); const [collected, setCollected] = useState(false); const [comment, setComment] = useState(''); const [comments, setComments] = useState(mockComments); const handleSubmitComment = () => { if (!comment.trim()) { message.warning('请输入评论内容'); return; } // 提交评论 const newComment = { id: comments.length + 1, author: '当前用户', avatar: 'https://joeschmoe.io/api/v1/random', content: comment, createTime: new Date().toLocaleString(), likes: 0, }; setComments([newComment, ...comments]); message.success('评论成功'); setComment(''); }; return (
帖子标题 }> 作者名称 发布时间 分类 阅读 1000
帖子内容
评论区