通用评论 vedio

index.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import React, { Component } from "react";
  2. // import PropTypes from 'prop-type';
  3. import { Icon } from "antd";
  4. import Comment from "../../Comment";
  5. import CommentInput from "../CommentInput";
  6. import "./index.css";
  7. class ReplyItem extends Component {
  8. constructor(props) {
  9. super(props);
  10. this.state = {
  11. showInput: false
  12. };
  13. this.handleToggleInput = this.handleToggleInput.bind(this);
  14. }
  15. handleToggleInput() {
  16. this.setState({ showInput: !this.state.showInput });
  17. }
  18. render() {
  19. const { commentId, replyItem, replyId, action, app } = this.props;
  20. const { showInput } = this.state;
  21. return (
  22. <div className="reply-item">
  23. <div className="reply-item-content">
  24. @<strong>{replyItem.user_name}</strong>
  25. {replyItem.reply ? ` 回复 @${replyItem.reply.user_name}` : null}:
  26. &nbsp;
  27. {replyItem.content}
  28. </div>
  29. <div className="reply-item-icon">
  30. <span className="reply-item-span">
  31. <Icon
  32. type="heart"
  33. onClick={() => {
  34. if (replyId) {
  35. // 如果有 replyId,则说明是评论的回复
  36. app.sReplyFavor(replyItem.id, commentId, replyItem.favored);
  37. return;
  38. }
  39. app.sCommentFavor(replyItem.id, replyItem.favored);
  40. }}
  41. className={
  42. replyItem.favored
  43. ? "comment-favor comment-favored"
  44. : "comment-favor"
  45. }
  46. />
  47. &nbsp; {replyItem.favor_count}
  48. </span>
  49. <span className="reply-item-span">
  50. <Icon type="message" onClick={this.handleToggleInput} /> &nbsp;{" "}
  51. {replyItem.reply_count || 0}
  52. </span>
  53. </div>
  54. {showInput && (
  55. <CommentInput
  56. content={app.children}
  57. action={action}
  58. replyId={replyId}
  59. commentId={commentId}
  60. callback={this.handleToggleInput}
  61. />
  62. )}
  63. </div>
  64. );
  65. }
  66. }
  67. export default Comment(ReplyItem);