通用评论 vedio

index.js 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _icon = require("antd/es/icon");
  6. var _icon2 = _interopRequireDefault(_icon);
  7. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  8. require("antd/es/icon/style/css");
  9. var _react = require("react");
  10. var _react2 = _interopRequireDefault(_react);
  11. var _Comment = require("../../Comment");
  12. var _Comment2 = _interopRequireDefault(_Comment);
  13. var _CommentInput = require("../CommentInput");
  14. var _CommentInput2 = _interopRequireDefault(_CommentInput);
  15. require("./index.css");
  16. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  19. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  20. // import PropTypes from 'prop-type';
  21. var ReplyItem = function (_Component) {
  22. _inherits(ReplyItem, _Component);
  23. function ReplyItem(props) {
  24. _classCallCheck(this, ReplyItem);
  25. var _this = _possibleConstructorReturn(this, (ReplyItem.__proto__ || Object.getPrototypeOf(ReplyItem)).call(this, props));
  26. _this.state = {
  27. showInput: false
  28. };
  29. _this.handleToggleInput = _this.handleToggleInput.bind(_this);
  30. return _this;
  31. }
  32. _createClass(ReplyItem, [{
  33. key: "handleToggleInput",
  34. value: function handleToggleInput() {
  35. this.setState({ showInput: !this.state.showInput });
  36. }
  37. }, {
  38. key: "render",
  39. value: function render() {
  40. var _props = this.props,
  41. commentId = _props.commentId,
  42. replyItem = _props.replyItem,
  43. action = _props.action,
  44. app = _props.app;
  45. var replyId = replyItem.id;
  46. // console.log('replyId', replyId);
  47. var showInput = this.state.showInput;
  48. return _react2.default.createElement(
  49. "div",
  50. { className: "reply-item" },
  51. _react2.default.createElement(
  52. "div",
  53. { className: "reply-item-content" },
  54. "@",
  55. _react2.default.createElement(
  56. "strong",
  57. null,
  58. replyItem.user_name
  59. ),
  60. replyItem.reply ? " \u56DE\u590D @" + replyItem.reply.user_name : null,
  61. ": \xA0",
  62. replyItem.content
  63. ),
  64. _react2.default.createElement(
  65. "div",
  66. { className: "reply-item-icon" },
  67. _react2.default.createElement(
  68. "span",
  69. { className: "reply-item-span" },
  70. _react2.default.createElement(_icon2.default, {
  71. type: "heart",
  72. onClick: function onClick() {
  73. // if (replyId) {
  74. // 如果有 replyId,则说明是评论的回复
  75. app.sReplyFavor(replyItem.id, commentId, replyItem.favored);
  76. // return;
  77. // }
  78. // app.sCommentFavor(replyItem.id, replyItem.favored);
  79. },
  80. className: replyItem.favored ? "comment-favor comment-favored" : "comment-favor"
  81. }),
  82. "\xA0 ",
  83. replyItem.favor_count
  84. ),
  85. _react2.default.createElement(
  86. "span",
  87. { className: "reply-item-span" },
  88. _react2.default.createElement(_icon2.default, { type: "message", onClick: this.handleToggleInput }),
  89. " \xA0",
  90. " ",
  91. replyItem.reply_count || 0
  92. )
  93. ),
  94. showInput && _react2.default.createElement(_CommentInput2.default, {
  95. content: app.children,
  96. action: action,
  97. replyId: replyId,
  98. commentId: commentId,
  99. callback: this.handleToggleInput
  100. })
  101. );
  102. }
  103. }]);
  104. return ReplyItem;
  105. }(_react.Component);
  106. exports.default = (0, _Comment2.default)(ReplyItem);
  107. //# sourceMappingURL=index.js.map