feat(组件): 为评论项组件添加点赞功能支持

扩展评论项组件以支持点赞功能,包括传递点赞启用标志和点赞事件处理器。
同时更新评论列表组件,将点赞处理器参数扩展为包含评论ID和点赞状态。
This commit is contained in:
anghunk
2026-01-23 19:52:08 +08:00
parent 2b88672f09
commit ee646506a9
2 changed files with 11 additions and 5 deletions

View File

@@ -231,7 +231,9 @@ export class CommentItem extends Component {
submitting: this.props.submitting,
adminEmail: this.props.adminEmail,
adminBadge: this.props.adminBadge,
enableCommentLike: this.props.enableCommentLike,
onReply: this.props.onReply,
onLikeComment: this.props.onLikeComment,
onSubmitReply: this.props.onSubmitReply,
onCancelReply: this.props.onCancelReply,
onUpdateReplyContent: this.props.onUpdateReplyContent,
@@ -304,7 +306,9 @@ export class CommentItem extends Component {
replyingTo: this.props.replyingTo,
replyContent: this.props.replyContent,
replyError: this.props.replyError,
submitting: this.props.submitting
submitting: this.props.submitting,
enableCommentLike: this.props.enableCommentLike,
onLikeComment: this.props.onLikeComment
});
});
}

View File

@@ -103,7 +103,7 @@ export class CommentList extends Component {
onCancelReply: () => this.handleCancelReply(),
onUpdateReplyContent: (content) => this.handleUpdateReplyContent(content),
onClearReplyError: () => this.handleClearReplyError(),
onLikeComment: (commentId) => this.handleLikeComment(commentId)
onLikeComment: (commentId, isLike) => this.handleLikeComment(commentId, isLike)
});
commentItem.render();
// 缓存 CommentItem 实例
@@ -166,7 +166,9 @@ export class CommentList extends Component {
replyingTo: this.props.replyingTo,
replyContent: this.props.replyContent,
replyError: this.props.replyError,
submitting: this.props.submitting
submitting: this.props.submitting,
enableCommentLike: this.props.enableCommentLike,
onLikeComment: (commentId, isLike) => this.handleLikeComment(commentId, isLike)
});
});
return;
@@ -222,9 +224,9 @@ export class CommentList extends Component {
}
}
handleLikeComment(commentId) {
handleLikeComment(commentId, isLike) {
if (this.props.onLikeComment) {
this.props.onLikeComment(commentId);
this.props.onLikeComment(commentId, isLike);
}
}