{"version":3,"sources":["../src/App.js"],"names":["App","props","state","loading","oss","list","page","total","isNoMoreComment","handleChangeLoading","bind","sGetComment","sGetReply","sCreateComment","sCreateReply","sCommentFavor","sReplyFavor","sOssSts","message","error","showError","axios","defaults","withCredentials","token","headers","common","key","value","setState","API","type","businessId","get","LIMIT","then","response","data","newList","oldList","filter","o","isTemporary","concat","info","catch","msg","lang","ERROR_DEFAULT","finally","commentId","map","item","id","replies","reply_count","reply_page","isNoMoreReply","content","cb","method","business_id","showAlertComment","success","unshift","showAlertReply","comment_id","push","favored","showAlertFavor","favor_count","replyId","r","showEditor","children","showList","marginTop","Component","propTypes","PropTypes","number","isRequired","string","bool","defaultProps","Editor","RenderText"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AAEA;;;;AACA;;AACA;;AACA;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;;;;;;;IAEMA,G;;;AACJ,eAAYC,KAAZ,EAAmB;AAAA;;AAAA,0GACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa;AACXC,eAAS,EADE;;AAGX;AACAC,WAAK,EAJM;;AAMX;AACAC,YAAM,EAPK;AAQXC,YAAM,CARK;AASXC,aAAO,CATI;AAUX;AACAC,uBAAiB;AAXN,KAAb;AAaA,UAAKC,mBAAL,GAA2B,MAAKA,mBAAL,CAAyBC,IAAzB,OAA3B;AACA,UAAKC,WAAL,GAAmB,MAAKA,WAAL,CAAiBD,IAAjB,OAAnB;AACA,UAAKE,SAAL,GAAiB,MAAKA,SAAL,CAAeF,IAAf,OAAjB;AACA,UAAKG,cAAL,GAAsB,MAAKA,cAAL,CAAoBH,IAApB,OAAtB;AACA,UAAKI,YAAL,GAAoB,MAAKA,YAAL,CAAkBJ,IAAlB,OAApB;AACA,UAAKK,aAAL,GAAqB,MAAKA,aAAL,CAAmBL,IAAnB,OAArB;AACA,UAAKM,WAAL,GAAmB,MAAKA,WAAL,CAAiBN,IAAjB,OAAnB;AACA,UAAKO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,cAAYM,oBAAUI,IALR,EAKc;AAC5BrB,oBAAkBiB,oBAAUI,IANd,EAMoB;AAClClB,kBAAgBc,oBAAUI,IAPZ,EAOkB;AAChCd,kBAAgBU,oBAAUI,IARZ,EAQkB;AAChC/D,aAAW2D,oBAAUI,IATP,CASa;AATb,CAAhB;;AAYAnF,IAAIoF,YAAJ,GAAmB;AACjBtD,OAAK,oCADY;AAEjB6C,YAAU,IAFO;AAGjBF,cAAY,IAHK;AAIjBX,oBAAkB,KAJD;AAKjBG,kBAAgB,KALC;AAMjBI,kBAAgB,KANC;AAOjBjD,aAAW;AAPM,CAAnB;;QAUSiE,M,GAAAA,gB;QAAQC,U,GAAAA,oB;kBAEFtF,G","file":"App.js","sourcesContent":["import React, { Component } from \"react\";\r\nimport PropTypes from \"prop-types\";\r\nimport { message as antdMessage } from \"antd\";\r\nimport axios from \"axios\";\r\nimport { ERROR_DEFAULT, LIMIT } from \"./constant\";\r\nimport { CommentContext } from \"./Comment\";\r\nimport { isFunction } from \"./helper\";\r\nimport CommentInput from \"./components/CommentInput\";\r\nimport CommentList from \"./components/CommentList\";\r\nimport Editor from \"./components/Editor\";\r\nimport RenderText from \"./components/RenderText\";\r\nimport lang from \"./lang\";\r\nimport \"./App.css\";\r\n\r\nclass App extends Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n loading: {},\r\n\r\n // oss 配置\r\n oss: {},\r\n\r\n // 评论数据\r\n list: [],\r\n page: 1,\r\n total: 0,\r\n // 是否没有更多评论了\r\n isNoMoreComment: false\r\n };\r\n this.handleChangeLoading = this.handleChangeLoading.bind(this);\r\n this.sGetComment = this.sGetComment.bind(this);\r\n this.sGetReply = this.sGetReply.bind(this);\r\n this.sCreateComment = this.sCreateComment.bind(this);\r\n this.sCreateReply = this.sCreateReply.bind(this);\r\n this.sCommentFavor = this.sCommentFavor.bind(this);\r\n this.sReplyFavor = this.sReplyFavor.bind(this);\r\n this.sOssSts = this.sOssSts.bind(this);\r\n this.message = {\r\n ...antdMessage,\r\n error: (...args) => {\r\n if (this.props.showError) {\r\n antdMessage.error(...args);\r\n }\r\n }\r\n }\r\n }\r\n\r\n componentWillMount() {\r\n this.axios = axios;\r\n this.axios.defaults.withCredentials = true;\r\n if (this.props.token) {\r\n this.axios.defaults.headers.common[\"Authorization\"] = `Bearer ${\r\n this.props.token\r\n }`;\r\n }\r\n }\r\n\r\n componentDidMount() { }\r\n\r\n /**\r\n * 改变 loading 状态\r\n * @param {string} key key\r\n * @param {string} value value\r\n */\r\n handleChangeLoading(key, value) {\r\n const { loading } = this.state;\r\n loading[key] = value;\r\n this.setState({ loading });\r\n }\r\n\r\n /**\r\n * 获取评论列表\r\n */\r\n sGetComment({ page = 1 } = {}) {\r\n this.handleChangeLoading(\"sGetComment\", true);\r\n const { API, type, businessId } = this.props;\r\n this.axios\r\n .get(\r\n `${API}/comments?type=${type}&business_id=${businessId}&page=${page}&limit=${LIMIT}`\r\n )\r\n .then(response => {\r\n const { list, page, total } = response.data;\r\n if (list) {\r\n let newList = list;\r\n if (page > 1) {\r\n let { list: oldList } = this.state;\r\n // 删除临时数据\r\n oldList = oldList.filter(o => !o.isTemporary);\r\n newList = oldList.concat(newList);\r\n }\r\n this.setState({\r\n list: newList,\r\n page,\r\n total\r\n });\r\n } else {\r\n this.message.info(\"没有更多评论了\");\r\n this.setState({\r\n isNoMoreComment: true\r\n });\r\n }\r\n })\r\n .catch(error => {\r\n if (error.response && error.response.data && error.response.data.msg) {\r\n this.message.error(lang[error.response.data.msg] || ERROR_DEFAULT);\r\n return;\r\n }\r\n this.message.error(lang[error.message] || ERROR_DEFAULT);\r\n })\r\n .finally(() => {\r\n this.handleChangeLoading(\"sGetComment\", false);\r\n });\r\n }\r\n\r\n /**\r\n * 获取更多回复\r\n */\r\n sGetReply({ commentId, page = 1 } = {}) {\r\n this.handleChangeLoading(\"sGetReply\", true);\r\n const { API } = this.props;\r\n this.axios\r\n .get(`${API}/replies?comment_id=${commentId}&page=${page}&limit=${LIMIT}`)\r\n .then(response => {\r\n if (!response.data.list) {\r\n this.message.info(\"没有更多数据了!\");\r\n }\r\n const list = this.state.list.map(item => {\r\n if (item.id === commentId) {\r\n if (!item.replies) item.replies = [];\r\n if (response.data.list) {\r\n if (page === 1) {\r\n // 如果当前页数为第一页,则清空当前所有的 replies\r\n // 并将获取到的 replies 存放在 state\r\n item.replies = response.data.list;\r\n } else {\r\n item.replies = item.replies\r\n .filter(o => !o.isTemporary)\r\n .concat(response.data.list);\r\n // 如果当前页数非第一页,则合并 replies\r\n }\r\n item.reply_count = response.data.total;\r\n item.reply_page = response.data.page;\r\n } else {\r\n item.isNoMoreReply = true;\r\n }\r\n }\r\n return item;\r\n });\r\n this.setState({ list });\r\n })\r\n .catch(error => {\r\n if (error.response && error.response.data && error.response.data.msg) {\r\n this.message.error(lang[error.response.data.msg] || ERROR_DEFAULT);\r\n return;\r\n }\r\n this.message.error(lang[error.message] || ERROR_DEFAULT);\r\n })\r\n .finally(() => {\r\n this.handleChangeLoading(\"sGetReply\", false);\r\n });\r\n }\r\n\r\n /**\r\n * 添加评论\r\n * @param {object} {content} comment content\r\n */\r\n sCreateComment({ content } = {}, cb) {\r\n if (!content) return this.message.error(\"评论内容不能为空 \");\r\n this.handleChangeLoading(\"sCreateComment\", true);\r\n const { API, type, businessId } = this.props;\r\n this.axios(`${API}/comments`, {\r\n method: \"post\",\r\n data: {\r\n type,\r\n business_id: businessId,\r\n content\r\n },\r\n withCredentials: true\r\n })\r\n .then(response => {\r\n if (this.props.showAlertComment) {\r\n this.message.success(\"评论成功!\");\r\n }\r\n if (isFunction(cb)) cb();\r\n // 将数据写入到 list 中\r\n // 临时插入\r\n // 等到获取数据之后,删除临时数据\r\n const { list, total } = this.state;\r\n list.unshift({\r\n ...response.data,\r\n isTemporary: true // 临时的数据\r\n });\r\n this.setState({ list, total: total + 1 });\r\n })\r\n .catch(error => {\r\n if (error.response && error.response.data && error.response.data.msg) {\r\n this.message.error(lang[error.response.data.msg] || ERROR_DEFAULT);\r\n return;\r\n }\r\n this.message.error(lang[error.message] || ERROR_DEFAULT);\r\n })\r\n .finally(() => {\r\n this.handleChangeLoading(\"sCreateComment\", false);\r\n });\r\n }\r\n\r\n /**\r\n * 添加回复\r\n * 回复评论/回复回复\r\n * @param {object} data { comment_id, content, [reply_id] }\r\n */\r\n sCreateReply(data, cb) {\r\n if (!data.content) return this.message.error(\"回复内容不能为空 \");\r\n this.handleChangeLoading(\"sCreateReply\", true);\r\n const { API } = this.props;\r\n this.axios(`${API}/replies`, {\r\n method: \"post\",\r\n data,\r\n withCredentials: true\r\n })\r\n .then(response => {\r\n if (this.props.showAlertReply) {\r\n this.message.success(\"回复成功!\");\r\n }\r\n if (isFunction(cb)) cb();\r\n // 将数据写入到 list 中\r\n // 临时插入\r\n // 等到获取数据之后,删除临时数据\r\n const list = this.state.list.map(item => {\r\n if (item.id === data.comment_id) {\r\n if (!item.replies) item.replies = [];\r\n item.replies.push({\r\n ...response.data,\r\n isTemporary: true // 临时的数据\r\n });\r\n item.reply_count += 1;\r\n }\r\n return item;\r\n });\r\n this.setState({ list });\r\n })\r\n .catch(error => {\r\n if (error.response && error.response.data && error.response.data.msg) {\r\n this.message.error(lang[error.response.data.msg] || ERROR_DEFAULT);\r\n return;\r\n }\r\n this.message.error(lang[error.message] || ERROR_DEFAULT);\r\n })\r\n .finally(() => {\r\n this.handleChangeLoading(\"sCreateReply\", false);\r\n });\r\n }\r\n\r\n /**\r\n * 评论 点赞/取消点赞\r\n * @param {string} commentId { commentId }\r\n * @param {boolean} favored 是否已经点过赞\r\n */\r\n sCommentFavor(commentId, favored) {\r\n this.handleChangeLoading(\"sCommentFavor\", true);\r\n const { API } = this.props;\r\n this.axios(`${API}/comments/${commentId}/favor`, {\r\n method: favored ? \"delete\" : \"put\",\r\n withCredentials: true\r\n })\r\n .then(response => {\r\n if (this.props.showAlertFavor) {\r\n this.message.success(favored ? \"取消点赞成功!\" : \"点赞成功!\");\r\n }\r\n // 更新 list 中的该项数据的 favored\r\n const list = this.state.list.map(item => {\r\n if (item.id === commentId) {\r\n item.favored = !favored;\r\n item.favor_count += favored ? -1 : 1;\r\n }\r\n return item;\r\n });\r\n this.setState({ list });\r\n })\r\n .catch(error => {\r\n if (error.response && error.response.data && error.response.data.msg) {\r\n this.message.error(lang[error.response.data.msg] || ERROR_DEFAULT);\r\n return;\r\n }\r\n this.message.error(lang[error.message] || ERROR_DEFAULT);\r\n })\r\n .finally(() => {\r\n this.handleChangeLoading(\"sCommentFavor\", false);\r\n });\r\n }\r\n\r\n /**\r\n * 回复 点赞/取消点赞\r\n * @param {string} replyId replyId\r\n * @param {string} commentId commentId\r\n * @param {boolean} favored 是否已经点过赞\r\n */\r\n sReplyFavor(replyId, commentId, favored) {\r\n this.handleChangeLoading(\"sReplyFavor\", true);\r\n const { API } = this.props;\r\n this.axios(`${API}/replies/${replyId}/favor`, {\r\n method: favored ? \"delete\" : \"put\",\r\n data: {\r\n comment_id: commentId\r\n },\r\n withCredentials: true\r\n })\r\n .then(response => {\r\n this.message.success(favored ? \"取消点赞成功!\" : \"点赞成功!\");\r\n // 更新 list 中的该项数据的 favored\r\n const list = this.state.list.map(item => {\r\n if (item.id === commentId) {\r\n item.replies = item.replies.map(r => {\r\n if (r.id === replyId) {\r\n r.favored = !favored;\r\n // r.favor_count = response.data.favor_count;\r\n // 点赞数 +1,而不是使用后端返回的点赞数\r\n // 不然如果返回的不是增加 1,用户可能以为程序错误\r\n r.favor_count += favored ? -1 : 1;\r\n }\r\n return r;\r\n });\r\n }\r\n return item;\r\n });\r\n this.setState({ list });\r\n })\r\n .catch(error => {\r\n if (error.response && error.response.data && error.response.data.msg) {\r\n this.message.error(lang[error.response.data.msg] || ERROR_DEFAULT);\r\n return;\r\n }\r\n this.message.error(lang[error.message] || ERROR_DEFAULT);\r\n })\r\n .finally(() => {\r\n this.handleChangeLoading(\"sReplyFavor\", false);\r\n });\r\n }\r\n\r\n /**\r\n * 获取 OSS 上传的参数\r\n */\r\n sOssSts() {\r\n this.handleChangeLoading(\"sOssSts\", true);\r\n const { API } = this.props;\r\n this.axios\r\n .get(`${API}/oss/sts`)\r\n .then(response => {\r\n this.setState({ oss: { ...response.data } });\r\n })\r\n .catch(error => {\r\n if (error.response && error.response.data && error.response.data.msg) {\r\n this.message.error(lang[error.response.data.msg] || ERROR_DEFAULT);\r\n return;\r\n }\r\n this.message.error(lang[error.message] || ERROR_DEFAULT);\r\n })\r\n .finally(() => {\r\n this.handleChangeLoading(\"sOssSts\", false);\r\n });\r\n }\r\n\r\n render() {\r\n // 添加到 Context 的数据\r\n const value = {\r\n ...this.state,\r\n ...this.props,\r\n sCreateComment: this.sCreateComment,\r\n sGetComment: this.sGetComment,\r\n sCommentFavor: this.sCommentFavor,\r\n sReplyFavor: this.sReplyFavor,\r\n sCreateReply: this.sCreateReply,\r\n sGetReply: this.sGetReply,\r\n sOssSts: this.sOssSts\r\n };\r\n\r\n return (\r\n \r\n
\r\n {this.props.showEditor && (\r\n \r\n )}\r\n {this.props.showList && (\r\n
\r\n \r\n
\r\n )}\r\n
\r\n
\r\n );\r\n }\r\n}\r\n\r\nApp.propTypes = {\r\n type: PropTypes.number.isRequired, // 评论的 type\r\n businessId: PropTypes.string.isRequired, // 评论的 business_id\r\n API: PropTypes.string, // 评论的 API 前缀\r\n showList: PropTypes.bool, // 是否显示评论列表\r\n showEditor: PropTypes.bool, // 是否显示评论输入框\r\n showAlertComment: PropTypes.bool, // 评论成功之后,是否通过 Antd 的 Message 组件进行提示\r\n showAlertReply: PropTypes.bool, // 回复成功之后,是否通过 Antd 的 Message 组件进行提示\r\n showAlertFavor: PropTypes.bool, // 点赞/取消点赞成功之后,是否通过 Antd 的 Message 组件进行提示\r\n showError: PropTypes.bool, // 是否使用Antd的Message组件提示错误信息\r\n};\r\n\r\nApp.defaultProps = {\r\n API: \"http://api.links123.net/comment/v1\",\r\n showList: true,\r\n showEditor: true,\r\n showAlertComment: false,\r\n showAlertReply: false,\r\n showAlertFavor: false,\r\n showError: true,\r\n};\r\n\r\nexport { Editor, RenderText };\r\n\r\nexport default App;\r\n"]}