通用评论

index.js.map 5.7KB

1
  1. {"version":3,"sources":["../../../src/components/CommentBox/index.js"],"names":["CommentBox","props","state","showReply","page","handleToggleReply","bind","handleGetMoreReply","renderReplies","setState","commentId","app","sGetReply","replies","isNoMoreReply","length","len","marginLeft","map","item","index","id","float","content","Component","propTypes","PropTypes","string","isRequired","defaultProps"],"mappings":";;;;;;;;;;;;;;AAAA;;;;AACA;;;;AAEA;;;;AACA;;;;AACA;;;;;;;;;;IAEMA,U;;;AACJ,sBAAYC,KAAZ,EAAmB;AAAA;;AAAA,wHACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa;AACXC,iBAAW,IADA;AAEXC,YAAM;AAFK,KAAb;;AAKA,UAAKC,iBAAL,GAAyB,MAAKA,iBAAL,CAAuBC,IAAvB,OAAzB;AACA,UAAKC,kBAAL,GAA0B,MAAKA,kBAAL,CAAwBD,IAAxB,OAA1B;AACA,UAAKE,aAAL,GAAqB,MAAKA,aAAL,CAAmBF,IAAnB,OAArB;AATiB;AAUlB;;AAED;;;;;;;wCAGoB;AAClB,WAAKG,QAAL,CAAc,EAAEN,WAAW,CAAC,KAAKD,KAAL,CAAWC,SAAzB,EAAd;AACD;;AAED;;;;;;;uCAImBO,S,EAAW;AAC5B;AAD4B,UAEpBN,IAFoB,GAEX,KAAKF,KAFM,CAEpBE,IAFoB;;AAG5B,WAAKH,KAAL,CAAWU,GAAX,CAAeC,SAAf,CAAyB,EAAEF,oBAAF,EAAaN,UAAb,EAAzB;AACA,WAAKK,QAAL,CAAc,EAAEL,MAAMA,OAAO,CAAf,EAAd;AACD;;AAED;;;;;;;;kCAKcS,O,EAASC,a,EAAe;AAAA;;AAAA,UAC5BJ,SAD4B,GACd,KAAKT,KADS,CAC5BS,SAD4B;AAAA,UAE5BP,SAF4B,GAEd,KAAKD,KAFS,CAE5BC,SAF4B;;AAGpC,UAAIA,aAAaU,OAAb,IAAwBA,QAAQE,MAApC,EAA4C;AAC1C,YAAMC,MAAMH,QAAQE,MAApB;AACA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;;AA0GzBxB,WAAWyB,SAAX,GAAuB;AACrBf,aAAWgB,oBAAUC,MAAV,CAAiBC;AADP,CAAvB;;AAIA5B,WAAW6B,YAAX,GAA0B,EAA1B;;kBAEe,uBAAQ7B,UAAR,C","file":"index.js","sourcesContent":["import React, { Component } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { Icon } from \"antd\";\nimport Comment from \"../../Comment\";\nimport ContentItem from \"./../ContentItem\";\nimport \"./index.css\";\n\nclass CommentBox extends Component {\n constructor(props) {\n super(props);\n this.state = {\n showReply: true,\n page: 1\n };\n\n this.handleToggleReply = this.handleToggleReply.bind(this);\n this.handleGetMoreReply = this.handleGetMoreReply.bind(this);\n this.renderReplies = this.renderReplies.bind(this);\n }\n\n /**\n * 切换是否显示回复列表\n */\n handleToggleReply() {\n this.setState({ showReply: !this.state.showReply });\n }\n\n /**\n * 获取更多评论\n * @param {string} commentId comment id\n */\n handleGetMoreReply(commentId) {\n // 从第一页开始获取评论\n const { page } = this.state;\n this.props.app.sGetReply({ commentId, page });\n this.setState({ page: page + 1 });\n }\n\n /**\n * 渲染回复 DOM\n * @param {array} replies 回复列表\n * @param {boolean} isNoMoreReply 是否没有更多回复\n */\n renderReplies(replies, isNoMoreReply) {\n const { commentId } = this.props;\n const { showReply } = this.state;\n if (showReply && replies && replies.length) {\n const len = replies.length;\n return (\n <div style={{ marginLeft: 50 }}>\n {replies.map((item, index) => {\n if (index === len - 1) {\n return [\n <ContentItem\n commentId={commentId}\n replyId={item.id}\n key={item.id}\n content={item}\n type=\"reply\"\n />,\n <div className=\"moreBox\" key=\"show_more_button\">\n {!isNoMoreReply && (\n <span\n className=\"showMore\"\n onClick={() => this.handleGetMoreReply(commentId)}\n >\n 查看更多回复\n </span>\n )}\n\n <a\n style={{ float: \"right\" }}\n onClick={this.handleToggleReply}\n >\n <Icon type=\"up\" /> 收起回复\n </a>\n </div>\n ];\n }\n return (\n <ContentItem\n commentId={commentId}\n replyId={item.id}\n key={item.id}\n content={item}\n type=\"reply\"\n />\n );\n })}\n </div>\n );\n }\n return null;\n }\n\n render() {\n const { content } = this.props;\n const { showReply } = this.state;\n return (\n <div>\n <ContentItem\n content={content}\n onShowReply={this.handleToggleReply}\n showReply={showReply}\n commentId={content.id}\n type=\"comment\"\n />\n {this.renderReplies(content.replies, content.isNoMoreReply)}\n </div>\n );\n }\n}\n\nCommentBox.propTypes = {\n commentId: PropTypes.string.isRequired\n};\n\nCommentBox.defaultProps = {};\n\nexport default Comment(CommentBox);\n"]}