通用评论

1
  1. {"version":3,"sources":["../src/App.js"],"names":["App","props","state","loading","oss","list","page","total","isNoMoreComment","handleChangeLoading","bind","sCreateComment","sDeleteComment","sCommentFavor","sCreateReply","sDeleteReply","errorHandler","sGetComment","sReplyFavor","sGetReply","sOssSts","axios","defaults","withCredentials","token","headers","common","msg","info","showError","error","onError","response","data","lang","ERROR_DEFAULT","message","key","value","setState","pageType","API","type","businessId","limit","get","then","newList","oldList","filter","o","isTemporary","concat","window","scrollTo","catch","finally","commentId","map","item","id","replies","reply_count","reply_page","isNoMoreReply","content","cb","method","business_id","showAlertComment","success","unshift","res","onDelete","COMMENT_TYPE","COMMENT","showAlertReply","comment_id","push","replyId","REPLY","favored","showAlertFavor","favor_count","r","showEditor","children","showList","marginTop","Component","propTypes","PropTypes","number","isRequired","string","bool","func","userId","onPageChange","onGetMoreBtnClick","defaultProps","LIMIT","Editor","RenderText"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AAEA;;;;AACA;;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,cAAL,GAAsB,MAAKA,cAAL,CAAoBD,IAApB,OAAtB;AACA,UAAKE,cAAL,GAAsB,MAAKA,cAAL,CAAoBF,IAApB,OAAtB;AACA,UAAKG,aAAL,GAAqB,MAAKA,aAAL,CAAmBH,IAAnB,OAArB;AACA,UAAKI,YAAL,GAAoB,MAAKA,YAAL,CAAkBJ,IAAlB,OAApB;AACA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;AAWjBD,gBAAc,4BAAQ,CAAE,CAXP;AAYjBzB,YAAU,oBAAM,CAAE;AAZD,CAAnB;;QAeS6B,M,GAAAA,gB;QAAQC,U,GAAAA,oB;kBAEFvG,G","file":"App.js","sourcesContent":["import React, { Component } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { message } from \"antd\";\nimport axios from \"axios\";\nimport { ERROR_DEFAULT, LIMIT, COMMENT_TYPE } from \"./constant\";\nimport { CommentContext } from \"./Comment\";\nimport { isFunction } from \"./helper\";\nimport CommentInput from \"./components/CommentInput\";\nimport CommentList from \"./components/CommentList\";\nimport Editor from \"./components/Editor\";\nimport RenderText from \"./components/RenderText\";\nimport lang from \"./lang\";\nimport \"./App.css\";\n// import styles from \"./App.module.css\";\n\nclass App extends Component {\n constructor(props) {\n super(props);\n this.state = {\n loading: {},\n\n // oss 配置\n oss: {},\n\n // 评论数据\n list: [],\n page: 1,\n total: 0,\n // 是否没有更多评论了\n isNoMoreComment: false\n };\n this.handleChangeLoading = this.handleChangeLoading.bind(this);\n this.sCreateComment = this.sCreateComment.bind(this);\n this.sDeleteComment = this.sDeleteComment.bind(this);\n this.sCommentFavor = this.sCommentFavor.bind(this);\n this.sCreateReply = this.sCreateReply.bind(this);\n this.sDeleteReply = this.sDeleteReply.bind(this);\n this.errorHandler = this.errorHandler.bind(this);\n this.sGetComment = this.sGetComment.bind(this);\n this.sReplyFavor = this.sReplyFavor.bind(this);\n this.sGetReply = this.sGetReply.bind(this);\n this.sOssSts = this.sOssSts.bind(this);\n }\n\n componentWillMount() {\n this.axios = axios;\n this.axios.defaults.withCredentials = true;\n if (this.props.token) {\n this.axios.defaults.headers.common[\"Authorization\"] = `Bearer ${\n this.props.token\n }`;\n }\n }\n\n componentDidMount() {}\n\n error(msg, info = {}) {\n if (this.props.showError) {\n message.error(msg);\n }\n if (this.props.onError) {\n this.props.onError(msg, info);\n }\n }\n\n errorHandler(error) {\n if (error.response && error.response.data && error.response.data.msg) {\n this.error(lang[error.response.data.msg] || ERROR_DEFAULT, {\n response: error.response\n });\n return;\n }\n this.error(lang[error.message] || ERROR_DEFAULT, {\n response: error.response\n });\n }\n\n /**\n * 改变 loading 状态\n * @param {string} key key\n * @param {string} value value\n */\n handleChangeLoading(key, value) {\n const { loading } = this.state;\n loading[key] = value;\n this.setState({ loading });\n }\n\n /**\n * 获取评论列表\n */\n sGetComment({ page = 1 } = {}) {\n const { pageType } = this.props;\n this.handleChangeLoading(\"sGetComment\", true);\n const { API, type, businessId, limit } = this.props;\n this.axios\n .get(\n `${API}/comments?type=${type}&business_id=${businessId}&page=${page}&limit=${limit}`\n )\n .then(response => {\n const { list, page, total } = response.data;\n if (list) {\n let newList = list;\n let { list: oldList } = this.state;\n if (pageType === \"more\") {\n if (page > 1) {\n // 删除临时数据\n oldList = oldList.filter(o => !o.isTemporary);\n newList = oldList.concat(newList);\n }\n } else if (pageType === \"pagination\") {\n // TODO 滚动到顶部\n window.scrollTo(0, 0);\n }\n\n this.setState({\n list: newList,\n page,\n total\n });\n } else {\n message.info(\"没有更多评论了\");\n this.setState({\n isNoMoreComment: true\n });\n }\n })\n .catch(this.errorHandler)\n .finally(() => {\n this.handleChangeLoading(\"sGetComment\", false);\n });\n }\n\n /**\n * 获取更多回复\n */\n sGetReply({ commentId, page = 1 } = {}) {\n this.handleChangeLoading(\"sGetReply\", true);\n const { API, limit } = this.props;\n this.axios\n .get(`${API}/replies?comment_id=${commentId}&page=${page}&limit=${limit}`)\n .then(response => {\n if (!response.data.list) {\n message.info(\"没有更多数据了!\");\n }\n const list = this.state.list.map(item => {\n if (item.id === commentId) {\n if (!item.replies) item.replies = [];\n if (response.data.list) {\n if (page === 1) {\n // 如果当前页数为第一页,则清空当前所有的 replies\n // 并将获取到的 replies 存放在 state\n item.replies = response.data.list;\n } else {\n item.replies = item.replies\n .filter(o => !o.isTemporary)\n .concat(response.data.list);\n // 如果当前页数非第一页,则合并 replies\n }\n item.reply_count = response.data.total;\n item.reply_page = response.data.page;\n } else {\n item.isNoMoreReply = true;\n }\n }\n return item;\n });\n this.setState({ list });\n })\n .catch(this.errorHandler)\n .finally(() => {\n this.handleChangeLoading(\"sGetReply\", false);\n });\n }\n\n /**\n * 添加评论\n * @param {object} {content} comment content\n */\n sCreateComment({ content } = {}, cb) {\n if (!content) return this.error(\"评论内容不能为空 \");\n this.handleChangeLoading(\"sCreateComment\", true);\n const { API, type, businessId } = this.props;\n this.axios(`${API}/comments`, {\n method: \"post\",\n data: {\n type,\n business_id: businessId,\n content\n },\n withCredentials: true\n })\n .then(response => {\n if (this.props.showAlertComment) {\n message.success(\"评论成功!\");\n }\n if (isFunction(cb)) cb();\n // 将数据写入到 list 中\n // 临时插入\n // 等到获取数据之后,删除临时数据\n const { list, total } = this.state;\n list.unshift({\n ...response.data,\n isTemporary: true // 临时的数据\n });\n this.setState({ list, total: total + 1 });\n })\n .catch(this.errorHandler)\n .finally(() => {\n this.handleChangeLoading(\"sCreateComment\", false);\n });\n }\n\n /**\n * 删除评论\n */\n sDeleteComment(commentId) {\n this.handleChangeLoading(\"sDeleteComment\", true);\n const { API } = this.props;\n this.axios(`${API}/comments/${commentId}`, {\n method: \"delete\",\n withCredentials: true\n })\n .then(() => {\n const { list, total } = this.state;\n const res = list.filter(item => item.id !== commentId);\n this.setState({ list: res, total: total - 1 });\n this.props.onDelete(COMMENT_TYPE.COMMENT);\n })\n .catch(this.errorHandler)\n .finally(() => {\n this.handleChangeLoading(\"sDeleteComment\", false);\n });\n }\n\n /**\n * 添加回复\n * 回复评论/回复回复\n * @param {object} data { comment_id, content, [reply_id] }\n */\n sCreateReply(data, cb) {\n if (!data.content) return this.error(\"回复内容不能为空 \");\n this.handleChangeLoading(\"sCreateReply\", true);\n const { API } = this.props;\n this.axios(`${API}/replies`, {\n method: \"post\",\n data,\n withCredentials: true\n })\n .then(response => {\n if (this.props.showAlertReply) {\n message.success(\"回复成功!\");\n }\n if (isFunction(cb)) cb();\n // 将数据写入到 list 中\n // 临时插入\n // 等到获取数据之后,删除临时数据\n const list = this.state.list.map(item => {\n if (item.id === data.comment_id) {\n if (!item.replies) item.replies = [];\n item.replies.push({\n ...response.data,\n isTemporary: true // 临时的数据\n });\n item.reply_count += 1;\n }\n return item;\n });\n this.setState({ list });\n })\n .catch(this.errorHandler)\n .finally(() => {\n this.handleChangeLoading(\"sCreateReply\", false);\n });\n }\n\n /**\n * 删除回复\n * @param {*} replyId\n * @param {*} commentId\n */\n sDeleteReply(replyId, commentId) {\n this.handleChangeLoading(\"sDeleteReply\", true);\n const { API } = this.props;\n this.axios(`${API}/replies/${replyId}?CommentID=${commentId}`, {\n method: \"delete\",\n withCredentials: true\n })\n .then(() => {\n const list = this.state.list.map(item => {\n if (item.id === commentId) {\n const replies = item.replies.filter(item => item.id !== replyId);\n item.replies = replies;\n item.reply_count -= 1;\n }\n return item;\n });\n this.setState({ list });\n this.props.onDelete(COMMENT_TYPE.REPLY);\n })\n .catch(this.errorHandler)\n .finally(() => {\n this.handleChangeLoading(\"sDeleteReply\", false);\n });\n }\n\n /**\n * 评论 点赞/取消点赞\n * @param {string} commentId { commentId }\n * @param {boolean} favored 是否已经点过赞\n */\n sCommentFavor(commentId, favored) {\n this.handleChangeLoading(\"sCommentFavor\", true);\n const { API } = this.props;\n this.axios(`${API}/comments/${commentId}/favor`, {\n method: favored ? \"delete\" : \"put\",\n withCredentials: true\n })\n .then(response => {\n if (this.props.showAlertFavor) {\n message.success(favored ? \"取消点赞成功!\" : \"点赞成功!\");\n }\n // 更新 list 中的该项数据的 favored\n const list = this.state.list.map(item => {\n if (item.id === commentId) {\n item.favored = !favored;\n item.favor_count += favored ? -1 : 1;\n }\n return item;\n });\n this.setState({ list });\n })\n .catch(this.errorHandler)\n .finally(() => {\n this.handleChangeLoading(\"sCommentFavor\", false);\n });\n }\n\n /**\n * 回复 点赞/取消点赞\n * @param {string} replyId replyId\n * @param {string} commentId commentId\n * @param {boolean} favored 是否已经点过赞\n */\n sReplyFavor(replyId, commentId, favored) {\n this.handleChangeLoading(\"sReplyFavor\", true);\n const { API } = this.props;\n this.axios(`${API}/replies/${replyId}/favor`, {\n method: favored ? \"delete\" : \"put\",\n data: {\n comment_id: commentId\n },\n withCredentials: true\n })\n .then(response => {\n message.success(favored ? \"取消点赞成功!\" : \"点赞成功!\");\n // 更新 list 中的该项数据的 favored\n const list = this.state.list.map(item => {\n if (item.id === commentId) {\n item.replies = item.replies.map(r => {\n if (r.id === replyId) {\n r.favored = !favored;\n // r.favor_count = response.data.favor_count;\n // 点赞数 +1,而不是使用后端返回的点赞数\n // 不然如果返回的不是增加 1,用户可能以为程序错误\n r.favor_count += favored ? -1 : 1;\n }\n return r;\n });\n }\n return item;\n });\n this.setState({ list });\n })\n .catch(this.errorHandler)\n .finally(() => {\n this.handleChangeLoading(\"sReplyFavor\", false);\n });\n }\n\n /**\n * 获取 OSS 上传的参数\n */\n sOssSts() {\n this.handleChangeLoading(\"sOssSts\", true);\n const { API } = this.props;\n this.axios\n .get(`${API}/oss/sts`)\n .then(response => {\n this.setState({ oss: { ...response.data } });\n })\n .catch(this.errorHandler)\n .finally(() => {\n this.handleChangeLoading(\"sOssSts\", false);\n });\n }\n\n render() {\n // 添加到 Context 的数据\n const value = {\n ...this.state,\n ...this.props,\n sCreateComment: this.sCreateComment,\n sGetComment: this.sGetComment,\n sCommentFavor: this.sCommentFavor,\n sReplyFavor: this.sReplyFavor,\n sCreateReply: this.sCreateReply,\n sGetReply: this.sGetReply,\n sOssSts: this.sOssSts,\n sDeleteComment: this.sDeleteComment,\n sDeleteReply: this.sDeleteReply\n };\n\n return (\n <CommentContext.Provider value={value}>\n <div className=\"comment\">\n {this.props.showEditor && (\n <CommentInput content={this.props.children} />\n )}\n {this.props.showList && (\n <div style={{ marginTop: 20 }}>\n <CommentList />\n </div>\n )}\n </div>\n </CommentContext.Provider>\n );\n }\n}\n\nApp.propTypes = {\n type: PropTypes.number.isRequired, // 评论的 type\n businessId: PropTypes.string.isRequired, // 评论的 business_id\n API: PropTypes.string, // 评论的 API 前缀\n showList: PropTypes.bool, // 是否显示评论列表\n showEditor: PropTypes.bool, // 是否显示评论输入框\n showAlertComment: PropTypes.bool, // 评论成功之后,是否通过 Antd 的 Message 组件进行提示\n showAlertReply: PropTypes.bool, // 回复成功之后,是否通过 Antd 的 Message 组件进行提示\n showAlertFavor: PropTypes.bool, // 点赞/取消点赞成功之后,是否通过 Antd 的 Message 组件进行提示\n showError: PropTypes.bool, // 是否使用Antd的Message组件提示错误信息\n onError: PropTypes.func, // 错误回调, 出错了会被调用\n userId: PropTypes.number, // 用户id, comment内部不维护用户id, 调用组件时传递过来, 目前用于判断是否显示删除按钮\n pageType: PropTypes.string, // 分页类型\n page: PropTypes.number, // 页码\n limit: PropTypes.number, // 一次加载评论数量\n onPageChange: PropTypes.func, // 页码变化回调\n onGetMoreBtnClick: PropTypes.func, // 点击查看更多按钮回调\n onDelete: PropTypes.func\n};\n\nApp.defaultProps = {\n API: \"//api.links123.net/comment/v1\",\n showList: true,\n showEditor: true,\n showAlertComment: false,\n showAlertReply: false,\n showAlertFavor: false,\n showError: true,\n pageType: \"more\",\n limit: LIMIT,\n onGetMoreBtnClick: () => {},\n onPageChange: page => {},\n onDelete: () => {}\n};\n\nexport { Editor, RenderText };\n\nexport default App;\n"]}