feat(组件): 为评论项组件添加点赞功能支持
扩展评论项组件以支持点赞功能,包括传递点赞启用标志和点赞事件处理器。 同时更新评论列表组件,将点赞处理器参数扩展为包含评论ID和点赞状态。
This commit is contained in:
@@ -231,7 +231,9 @@ export class CommentItem extends Component {
|
|||||||
submitting: this.props.submitting,
|
submitting: this.props.submitting,
|
||||||
adminEmail: this.props.adminEmail,
|
adminEmail: this.props.adminEmail,
|
||||||
adminBadge: this.props.adminBadge,
|
adminBadge: this.props.adminBadge,
|
||||||
|
enableCommentLike: this.props.enableCommentLike,
|
||||||
onReply: this.props.onReply,
|
onReply: this.props.onReply,
|
||||||
|
onLikeComment: this.props.onLikeComment,
|
||||||
onSubmitReply: this.props.onSubmitReply,
|
onSubmitReply: this.props.onSubmitReply,
|
||||||
onCancelReply: this.props.onCancelReply,
|
onCancelReply: this.props.onCancelReply,
|
||||||
onUpdateReplyContent: this.props.onUpdateReplyContent,
|
onUpdateReplyContent: this.props.onUpdateReplyContent,
|
||||||
@@ -304,7 +306,9 @@ export class CommentItem extends Component {
|
|||||||
replyingTo: this.props.replyingTo,
|
replyingTo: this.props.replyingTo,
|
||||||
replyContent: this.props.replyContent,
|
replyContent: this.props.replyContent,
|
||||||
replyError: this.props.replyError,
|
replyError: this.props.replyError,
|
||||||
submitting: this.props.submitting
|
submitting: this.props.submitting,
|
||||||
|
enableCommentLike: this.props.enableCommentLike,
|
||||||
|
onLikeComment: this.props.onLikeComment
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ export class CommentList extends Component {
|
|||||||
onCancelReply: () => this.handleCancelReply(),
|
onCancelReply: () => this.handleCancelReply(),
|
||||||
onUpdateReplyContent: (content) => this.handleUpdateReplyContent(content),
|
onUpdateReplyContent: (content) => this.handleUpdateReplyContent(content),
|
||||||
onClearReplyError: () => this.handleClearReplyError(),
|
onClearReplyError: () => this.handleClearReplyError(),
|
||||||
onLikeComment: (commentId) => this.handleLikeComment(commentId)
|
onLikeComment: (commentId, isLike) => this.handleLikeComment(commentId, isLike)
|
||||||
});
|
});
|
||||||
commentItem.render();
|
commentItem.render();
|
||||||
// 缓存 CommentItem 实例
|
// 缓存 CommentItem 实例
|
||||||
@@ -166,7 +166,9 @@ export class CommentList extends Component {
|
|||||||
replyingTo: this.props.replyingTo,
|
replyingTo: this.props.replyingTo,
|
||||||
replyContent: this.props.replyContent,
|
replyContent: this.props.replyContent,
|
||||||
replyError: this.props.replyError,
|
replyError: this.props.replyError,
|
||||||
submitting: this.props.submitting
|
submitting: this.props.submitting,
|
||||||
|
enableCommentLike: this.props.enableCommentLike,
|
||||||
|
onLikeComment: (commentId, isLike) => this.handleLikeComment(commentId, isLike)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@@ -222,9 +224,9 @@ export class CommentList extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLikeComment(commentId) {
|
handleLikeComment(commentId, isLike) {
|
||||||
if (this.props.onLikeComment) {
|
if (this.props.onLikeComment) {
|
||||||
this.props.onLikeComment(commentId);
|
this.props.onLikeComment(commentId, isLike);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user