通用评论 vedio

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","API","type","businessId","get","LIMIT","then","newList","oldList","filter","o","isTemporary","concat","catch","finally","commentId","map","item","id","replies","reply_count","reply_page","isNoMoreReply","content","cb","method","business_id","showAlertComment","success","unshift","res","showAlertReply","comment_id","push","replyId","favored","showAlertFavor","favor_count","r","showEditor","children","showList","marginTop","Component","propTypes","PropTypes","number","isRequired","string","bool","func","userId","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,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,UAAKK,YAAL,GAAoB,MAAKA,YAAL,CAAkBL,IAAlB,OAApB;AACA,UAAKM,YAAL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M,oBAAUI,IALR,EAKc;AAC5BtB,oBAAkBkB,oBAAUI,IANd,EAMoB;AAClClB,kBAAgBc,oBAAUI,IAPZ,EAOkB;AAChCb,kBAAgBS,oBAAUI,IARZ,EAQkB;AAChC3D,aAAWuD,oBAAUI,IATP,EASa;AAC3BzD,WAASqD,oBAAUK,IAVL,EAUW;AACzBC,UAAQN,oBAAUC,MAXJ,CAWW;AAXX,CAAhB;;AAcArF,IAAI2F,YAAJ,GAAmB;AACjBnD,OAAK,oCADY;AAEjBwC,YAAU,IAFO;AAGjBF,cAAY,IAHK;AAIjBZ,oBAAkB,KAJD;AAKjBI,kBAAgB,KALC;AAMjBK,kBAAgB,KANC;AAOjB9C,aAAW;AAPM,CAAnB;;QAUS+D,M,GAAAA,gB;QAAQC,U,GAAAA,oB;kBAEF7F,G","file":"App.js","sourcesContent":["import React, { Component } from \"react\";\r\nimport PropTypes from \"prop-types\";\r\nimport { message } 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.sCreateComment = this.sCreateComment.bind(this);\r\n this.sDeleteComment = this.sDeleteComment.bind(this);\r\n this.sCommentFavor = this.sCommentFavor.bind(this);\r\n this.sCreateReply = this.sCreateReply.bind(this);\r\n this.sDeleteReply = this.sDeleteReply.bind(this);\r\n this.errorHandler = this.errorHandler.bind(this);\r\n this.sGetComment = this.sGetComment.bind(this);\r\n this.sReplyFavor = this.sReplyFavor.bind(this);\r\n this.sGetReply = this.sGetReply.bind(this);\r\n this.sOssSts = this.sOssSts.bind(this);\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 error(msg, info = {}) {\r\n if (this.props.showError) {\r\n message.error(msg);\r\n }\r\n if (this.props.onError) {\r\n this.props.onError(msg, info);\r\n }\r\n }\r\n\r\n errorHandler(error) {\r\n if (error.response && error.response.data && error.response.data.msg) {\r\n this.error(lang[error.response.data.msg] || ERROR_DEFAULT, {\r\n response: error.response\r\n });\r\n return;\r\n }\r\n this.error(lang[error.message] || ERROR_DEFAULT, {\r\n response: error.response\r\n });\r\n }\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 message.info(\"没有更多评论了\");\r\n this.setState({\r\n isNoMoreComment: true\r\n });\r\n }\r\n })\r\n .catch(this.errorHandler)\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 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(this.errorHandler)\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.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 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(this.errorHandler)\r\n .finally(() => {\r\n this.handleChangeLoading(\"sCreateComment\", false);\r\n });\r\n }\r\n\r\n /**\r\n * 删除评论\r\n */\r\n sDeleteComment(commentId) {\r\n this.handleChangeLoading(\"sDeleteComment\", true);\r\n const { API } = this.props;\r\n this.axios(`${API}/comments/${commentId}`, {\r\n method: \"delete\",\r\n withCredentials: true\r\n })\r\n .then(() => {\r\n const { list, total } = this.state;\r\n const res = list.filter(item => item.id !== commentId);\r\n this.setState({ list: res, total: total - 1 });\r\n })\r\n .catch(this.errorHandler)\r\n .finally(() => {\r\n this.handleChangeLoading(\"sDeleteComment\", 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.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 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(this.errorHandler)\r\n .finally(() => {\r\n this.handleChangeLoading(\"sCreateReply\", false);\r\n });\r\n }\r\n\r\n /**\r\n * 删除回复\r\n * @param {*} replyId\r\n * @param {*} commentId\r\n */\r\n sDeleteReply(replyId, commentId) {\r\n this.handleChangeLoading(\"sDeleteReply\", true);\r\n const { API } = this.props;\r\n this.axios(`${API}/replies/${replyId}?CommentID=${commentId}`, {\r\n method: \"delete\",\r\n withCredentials: true\r\n })\r\n .then(() => {\r\n const list = this.state.list.map(item => {\r\n if (item.id === commentId) {\r\n const replies = item.replies.filter(item => item.id !== replyId);\r\n item.replies = replies;\r\n item.reply_count -= 1;\r\n }\r\n return item;\r\n });\r\n this.setState({ list });\r\n })\r\n .catch(this.errorHandler)\r\n .finally(() => {\r\n this.handleChangeLoading(\"sDeleteReply\", 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 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(this.errorHandler)\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 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(this.errorHandler)\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(this.errorHandler)\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 sDeleteComment: this.sDeleteComment,\r\n sDeleteReply: this.sDeleteReply\r\n };\r\n\r\n return (\r\n <CommentContext.Provider value={value}>\r\n <div className=\"comment\">\r\n {this.props.showEditor && (\r\n <CommentInput content={this.props.children} />\r\n )}\r\n {this.props.showList && (\r\n <div style={{ marginTop: 20 }}>\r\n <CommentList />\r\n </div>\r\n )}\r\n </div>\r\n </CommentContext.Provider>\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 onError: PropTypes.func, // 错误回调, 出错了会被调用\r\n userId: PropTypes.number // 用户id, comment内部不维护用户id, 调用组件时传递过来, 目前用于判断是否显示删除按钮\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"]}