mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-27 19:46:24 +00:00
✨ feat: 重构评论功能,支持删除和点赞,更新国际化文本,优化组件结构
This commit is contained in:
@ -38,7 +38,7 @@ export default function CommentSection(props: CommentAreaProps) {
|
||||
})
|
||||
}, [targetType, targetId]);
|
||||
|
||||
const onCommentSubmitted = () => {
|
||||
const onCommentsChange = () => {
|
||||
// 重新加载评论列表
|
||||
listComments({
|
||||
targetType,
|
||||
@ -54,17 +54,19 @@ export default function CommentSection(props: CommentAreaProps) {
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: 支持分页加载更多评论
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Separator className="my-16" />
|
||||
<div className="font-bold text-2xl">评论</div>
|
||||
<CommentInput targetType={targetType} targetId={targetId} replyId={0} onCommentSubmitted={onCommentSubmitted} />
|
||||
<CommentInput targetType={targetType} targetId={targetId} replyId={0} onCommentSubmitted={onCommentsChange} />
|
||||
<div className="mt-4">
|
||||
<Suspense fallback={<CommentLoading />}>
|
||||
{comments.map((comment, idx) => (
|
||||
<div key={comment.id} className="fade-in-up" style={{ animationDelay: `${idx * 60}ms` }}>
|
||||
<Separator className="my-2" />
|
||||
<CommentItem comment={comment} parentComment={null} />
|
||||
<CommentItem comment={comment} parentComment={null} onCommentDelete={onCommentsChange} />
|
||||
</div>
|
||||
))}
|
||||
</Suspense>
|
||||
|
Reference in New Issue
Block a user