feat(comments): 实现评论点赞功能
- 在数据库和API中添加likes字段支持 - 新增评论点赞接口和前端交互逻辑 - 在前端展示点赞数并处理点赞操作 - 更新相关组件和存储逻辑以支持点赞功能
This commit is contained in:
@@ -176,7 +176,8 @@ export class CWDComments {
|
||||
this.store = createCommentStore(
|
||||
this.config,
|
||||
api.fetchComments.bind(api),
|
||||
api.submitComment.bind(api)
|
||||
api.submitComment.bind(api),
|
||||
typeof api.likeComment === 'function' ? api.likeComment.bind(api) : undefined
|
||||
);
|
||||
|
||||
this.unsubscribe = this.store.store.subscribe((state) => {
|
||||
@@ -379,6 +380,11 @@ export class CWDComments {
|
||||
onPrevPage: () => this.store.goToPage(state.pagination.page - 1),
|
||||
onNextPage: () => this.store.goToPage(state.pagination.page + 1),
|
||||
onGoToPage: (page) => this.store.goToPage(page),
|
||||
onLikeComment: (commentId) => {
|
||||
if (this.store && typeof this.store.likeComment === 'function') {
|
||||
this.store.likeComment(commentId);
|
||||
}
|
||||
},
|
||||
});
|
||||
this.commentList.render();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user