feat(cwd-api, widget): 实现评论取消点赞功能

- 添加了评论取消点赞的逻辑处理
- 新增 DELETE /api/comments/like 接口用于取消点赞
- 修改点赞接口支持根据请求方法判断增加或减少点赞数
- 优化点赞数计算逻辑,支持正确的增减操作
- 更新错误提示信息为更通用的操作失败提示
This commit is contained in:
zpj80231
2026-03-25 14:57:05 +08:00
parent 071f6bf6f7
commit fc48deb338
3 changed files with 17 additions and 17 deletions

View File

@@ -371,8 +371,12 @@ export class CommentItem extends Component {
likedComments.add(commentId);
this.saveLikedComments(likedComments);
this.props.onLikeComment(commentId, true);
} else {
// 已点赞,执行取消点赞
likedComments.delete(commentId);
this.saveLikedComments(likedComments);
this.props.onLikeComment(commentId, false);
}
// 已点赞则不做任何操作
}
/**