通用评论

1
  1. {"version":3,"sources":["../src/App.js"],"names":["App","props","state","loading","oss","list","page","total","isNoMoreComment","initDone","locale","editModalVisible","action","replyId","commentId","userId","content","replyPage","emojiList","handleChangeLoading","bind","sCreateComment","sUpdateComment","sDeleteComment","sCommentFavor","sCreateReply","sDeleteReply","errorHandler","sGetComment","sReplyFavor","sGetReply","sUpdateReply","sOssSts","handleEdit","handleClose","axios","defaults","withCredentials","token","headers","common","loadLocales","loadEmoji","currentLocale","locales","cookieLang","Cookies","get","intl","determineLocale","urlLocaleKey","SUPPORT_LOCALES","find","item","value","version","require","hash","languageURL","LANGUAGE_LINK","fetch","then","response","status","Error","json","init","data","setState","emojiAPI","emojiMap","forEach","name","url","window","sessionStorage","setItem","JSON","stringify","catch","replies","reply","msg","info","showError","error","onError","localResponse","LOCALES_RESPONSE","ERROR_DEFAULT","key","filterSpeak","pageType","API","type","businessId","limit","newList","oldList","filter","o","isTemporary","concat","scrollTo","onCountChange","finally","map","id","reply_count","reply_page","isNoMoreReply","cb","businessUserId","method","business_id","business_user_id","showAlertComment","success","unshift","onCommentFail","res","deletedItem","onDelete","COMMENT_TYPE","COMMENT","it","onUpdateComment","showAlertReply","comment_id","push","REPLY","i","favored","showAlertFavor","favor_count","r","showEditor","children","showList","marginTop","user_id","preRenderValue","Component","propTypes","PropTypes","number","isRequired","string","bool","func","onPageChange","onGetMoreBtnClick","defaultProps","LOGINLINK","process","env","RUN_MOD","showEdit","LIMIT","onBeforeUpdateComment","v","Editor","RenderText"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AAEA;;;;AACA;;;;AACA;;;;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;AAEX;AACAC,WAAK,EAHM;AAIX;AACA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,YAAUsB,oBAAUK,IAlBN;AAmBdvB,mBAAiBkB,oBAAUK,IAnBb;AAoBdzG,WAASoG,oBAAUG,MApBL,EAoBa;AAC3B3C,iBAAewC,oBAAUK,IArBX,EAqBiB;AAC/B9B,iBAAeyB,oBAAUK,IAtBX,EAsBiB;AAC/BR,kBAAgBG,oBAAUK,IAvBZ,CAuBiB;AAvBjB,CAAhB;;AA0BArJ,IAAIwJ,YAAJ,GAAmB;AACjBxC,kBAAgB,CADC;AAEjBnB,OAAK,+BAFY;AAGjBxB,YAAU,4BAHO;AAIjBoF,aACEC,QAAQC,GAAR,CAAYC,OAAZ,KAAwB,YAAxB,GACI,qCADJ,GAEI,qCAPW;AAQjBlB,YAAU,IARO;AASjBF,cAAY,IATK;AAUjBpB,oBAAkB,KAVD;AAWjBW,kBAAgB,KAXC;AAYjBM,kBAAgB,KAZC;AAajBjD,aAAW,IAbM;AAcjByE,YAAU,KAdO;AAejBjE,YAAU,MAfO;AAgBjBI,SAAO8D,eAhBU;AAiBjBP,qBAAmB,6BAAM,CAAE,CAjBV;AAkBjBD,gBAAc,4BAAQ,CAAE,CAlBP;AAmBjB5B,YAAU,oBAAM,CAAE,CAnBD;AAoBjBI,mBAAiB,2BAAM,CAAE,CApBR;AAqBjBiC,yBAAuB,iCAAM,CAAE,CArBd;AAsBjBvD,iBAAe,yBAAM,CAAE,CAtBN;AAuBjBe,iBAAe,yBAAM,CAAE,CAvBN;AAwBjBsB,kBAAgB;AAAA,WAAKmB,CAAL;AAAA;AAxBC,CAAnB;;QA2BSC,M,GAAAA,gB;QAAQC,U,GAAAA,oB;kBAEFlK,G","file":"App.js","sourcesContent":["import React, { Component } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { message } from \"antd\";\nimport axios from \"axios\";\nimport Cookies from \"js-cookie\";\nimport intl from \"react-intl-universal\";\nimport { ERROR_DEFAULT, LIMIT, COMMENT_TYPE, LANGUAGE_LINK } 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 EditComment from \"./components/EditComment/EditComment\";\nimport { SUPPORT_LOCALES, LOCALES_RESPONSE } from \"./lang\";\nimport \"./App.css\";\n\nclass App extends Component {\n constructor(props) {\n super(props);\n this.state = {\n loading: {},\n // oss 配置\n oss: {},\n // 评论数据\n list: [],\n page: 1,\n total: 0,\n // 是否没有更多评论了\n isNoMoreComment: false,\n initDone: false,\n locale: \"zh-CN\",\n editModalVisible: false,\n action: \"\",\n replyId: \"\",\n commentId: \"\",\n userId: \"\",\n content: \"\",\n replyPage: 1,\n emojiList: []\n };\n this.handleChangeLoading = this.handleChangeLoading.bind(this);\n this.sCreateComment = this.sCreateComment.bind(this);\n this.sUpdateComment = this.sUpdateComment.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.sUpdateReply = this.sUpdateReply.bind(this);\n this.sOssSts = this.sOssSts.bind(this);\n this.handleEdit = this.handleEdit.bind(this);\n this.handleClose = this.handleClose.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[\n \"Authorization\"\n ] = `Bearer ${this.props.token}`;\n }\n }\n\n componentDidMount() {\n this.loadLocales();\n this.loadEmoji();\n }\n\n /**\n * 加载语言包\n * 只能根据url或者传入的props来确定加载哪个语言包\n * 优先级:传入的props > url\n */\n loadLocales() {\n let { locales: currentLocale } = this.props;\n const cookieLang = Cookies.get(\"lnk_lang\");\n if (!currentLocale) {\n currentLocale =\n cookieLang ||\n intl.determineLocale({\n urlLocaleKey: \"lang\"\n });\n }\n currentLocale = SUPPORT_LOCALES.find(item => item.value === currentLocale)\n ? currentLocale\n : \"zh-CN\";\n const version = require(\"./version.json\").hash;\n // 使用绝对路径\n const languageURL = `${LANGUAGE_LINK}/${currentLocale}.json?v=${version}`;\n return fetch(languageURL)\n .then(response => {\n if (response.status >= 400) {\n throw new Error(\"Bad response from server\");\n }\n return response.json();\n })\n .then(data => {\n // console.log('data: ', data);\n intl\n .init({\n currentLocale,\n locales: {\n [currentLocale]: data\n }\n })\n .then(() => {\n this.setState({ initDone: true, locale: currentLocale });\n });\n });\n }\n\n /**\n * 加载表情包\n */\n loadEmoji() {\n this.axios\n .get(`${this.props.emojiAPI}/emoticons`)\n .then(response => {\n const emojiMap = {};\n response.data.list.forEach(item => {\n emojiMap[item.name] = item.url;\n });\n window.sessionStorage.setItem(\"emojiMap\", JSON.stringify(emojiMap));\n this.setState({ emojiList: response.data.list });\n })\n .catch(this.errorHandler);\n }\n\n handleEdit({ replyId, commentId, userId, content, replyPage }) {\n this.setState({\n editModalVisible: true,\n action: content.replies\n ? \"comment\"\n : content.reply\n ? \"replyToReply\"\n : \"reply\",\n replyId,\n commentId,\n userId,\n content,\n replyPage\n });\n }\n\n handleClose() {\n this.setState({\n editModalVisible: false\n });\n }\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 const { locale } = this.state;\n const localResponse = LOCALES_RESPONSE[locale];\n if (error.response && error.response.data && error.response.data.msg) {\n this.error(localResponse[error.response.data.msg] || ERROR_DEFAULT, {\n response: error.response\n });\n return;\n }\n this.error(localResponse[error.response.data.msg] || 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, filterSpeak = 0 } = {}) {\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}&is_speak=${filterSpeak}&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 this.props.onCountChange(total);\n } else {\n message.info(intl.get(\"message.noMoreComment\"));\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(intl.get(\"message.noMoreData\"));\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(intl.get(\"message.notNull\"));\n this.handleChangeLoading(\"sCreateComment\", true);\n const { API, type, businessId, businessUserId } = this.props;\n this.axios(`${API}/comments`, {\n method: \"post\",\n data: {\n type,\n business_id: businessId,\n business_user_id: businessUserId,\n content\n },\n withCredentials: true\n })\n .then(response => {\n if (this.props.showAlertComment) {\n message.success(intl.get(\"message.success\"));\n }\n if (isFunction(cb)) cb(response.data);\n // 将数据写入到 list 中\n // 临时插入\n // 等到获取数据之后,删除临时数据\n const { list, total } = this.state;\n list.unshift({\n ...response.data,\n replies: [],\n isTemporary: true // 临时的数据\n });\n this.setState({ list, total: total + 1 });\n this.props.onCountChange(total + 1);\n })\n .catch(error => {\n this.props.onCommentFail(error.response.status);\n this.errorHandler(error);\n })\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 const deletedItem = list.find(item => item.id === commentId);\n this.setState({ list: res, total: total - 1 });\n this.props.onDelete(COMMENT_TYPE.COMMENT, deletedItem);\n this.props.onCountChange(total - 1);\n })\n .catch(this.errorHandler)\n .finally(() => {\n this.handleChangeLoading(\"sDeleteComment\", false);\n });\n }\n /**\n * 更新评论\n * @param {object} {content} comment content\n */\n sUpdateComment({ commentId, content }) {\n this.handleChangeLoading(\"sUpdateComment\", true);\n const { API } = this.props;\n this.axios(`${API}/comments/${commentId}`, {\n method: \"post\",\n data: {\n content\n },\n withCredentials: true\n })\n .then(() => {\n let { list } = this.state;\n list = list.map(it => {\n if (it.id === commentId) {\n return {\n ...it,\n content\n };\n }\n return it;\n });\n this.props.onUpdateComment(\"comment\");\n this.setState({ list });\n })\n .catch(this.errorHandler)\n .finally(() => {\n this.handleChangeLoading(\"sUpdateComment\", false);\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(intl.get(\"message.replyNoNull\"));\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(intl.get(\"message.replySuccess\"));\n }\n if (isFunction(cb)) cb(response.data);\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(error => {\n this.props.onCommentFail(error.response.status);\n this.errorHandler(error);\n })\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 let deletedItem = null;\n const list = this.state.list.map(item => {\n if (item.id === commentId) {\n const replies = item.replies.filter(item => item.id !== replyId);\n deletedItem = item.replies.find(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, deletedItem);\n })\n .catch(this.errorHandler)\n .finally(() => {\n this.handleChangeLoading(\"sDeleteReply\", false);\n });\n }\n /**\n * 更新回复\n * 回复评论/回复回复\n * @param {object} data { comment_id, content, reply_id }\n */\n sUpdateReply({ commentId, content, replyId, replyPage }) {\n this.handleChangeLoading(\"sUpdateReply\", true);\n const { API } = this.props;\n this.axios(`${API}/replies/${replyId}`, {\n method: \"post\",\n data: {\n comment_id: commentId,\n content\n },\n withCredentials: true\n })\n .then(() => {\n for (let i = 1; i <= replyPage; i++) {\n this.sGetReply({ commentId, page: i });\n }\n this.props.onUpdateComment(\"reply\");\n })\n .catch(this.errorHandler)\n .finally(() => {\n this.handleChangeLoading(\"sUpdateReply\", false);\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(\n favored\n ? intl.get(\"message.cancelLickSuccess\")\n : intl.get(\"message.likeSuccess\")\n );\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(\n favored\n ? intl.get(\"message.cancelLickSuccess\")\n : intl.get(\"message.likeSuccess\")\n );\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 sUpdateReply: this.sUpdateReply,\n sUpdateComment: this.sUpdateComment,\n handleEdit: this.handleEdit\n };\n\n return (\n this.state.initDone && (\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 {this.state.editModalVisible && (\n <EditComment\n visible={this.state.editModalVisible}\n action={this.state.action}\n replyId={this.state.replyId}\n replyPage={this.state.replyPage}\n commentId={this.state.commentId}\n userId={this.state.content.user_id}\n content={this.state.content}\n handleClose={this.handleClose}\n preRenderValue={this.props.preRenderValue}\n />\n )}\n </CommentContext.Provider>\n )\n );\n }\n}\n\nApp.propTypes = {\n type: PropTypes.number.isRequired, // 评论的 type\n businessId: PropTypes.string.isRequired, // 评论的 business_id\n businessUserId: PropTypes.number,\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 onUpdateComment: PropTypes.func,\n locales: PropTypes.string, // 传入的语言环境, en-US/zh-CN\n onCountChange: PropTypes.func, // 评论数量变更时的回调\n onCommentFail: PropTypes.func, // 评论失败时的回调\n preRenderValue: PropTypes.func // 编辑器渲染前对值需要做的工作\n};\n\nApp.defaultProps = {\n businessUserId: 0,\n API: \"//api.links123.net/comment/v1\",\n emojiAPI: \"//api.links123.net/link/v1\",\n LOGINLINK:\n process.env.RUN_MOD === \"production\"\n ? \"https://passport.links123.com/login\"\n : \"http://test.links123.net:5050/login\",\n showList: true,\n showEditor: true,\n showAlertComment: false,\n showAlertReply: false,\n showAlertFavor: false,\n showError: true,\n showEdit: false,\n pageType: \"more\",\n limit: LIMIT,\n onGetMoreBtnClick: () => {},\n onPageChange: page => {},\n onDelete: () => {},\n onUpdateComment: () => {},\n onBeforeUpdateComment: () => {},\n onCountChange: () => {},\n onCommentFail: () => {},\n preRenderValue: v => v\n};\n\nexport { Editor, RenderText };\n\nexport default App;\n"]}