通用评论

1
  1. {"version":3,"sources":["../src/index.js"],"names":["Index","props","state","fileList","editorProps","setState","React","Component","renderComment","config","id","Error","type","businessId","console","warn","API","ReactDOM","render","document","getElementById","window","process","env","NODE_ENV","businessUserId","userId","currentUser","user_id","userAvaHoverData","nickname","followers","fans","isFollowed","showHoverCard","userAvaClick","log","getUserInfo","focus","Promise","resolve","reject","unFocus","onCountChange","c","onDelete","data","onCommentSuccess"],"mappings":";;;;;;AAAA;;;;AACA;;;;AACA;;;;;;;;;;;;AACA;;IAEMA,K;;;AACJ,iBAAYC,KAAZ,EAAmB;AAAA;;AAAA,8GACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa;AACXC,gBAAU;AADC,KAAb;AAFiB;AAKlB;;;;6BAEQ;AAAA;;AACP,aACE;AAAC,qBAAD;AAAA;AACE,gCADF;AAEE,8BAFF;AAGE,8BAHF;AAIE;AAJF,WAKM,KAAKF,KALX;AAOE,sCAAC,WAAD;AACE,qBAAW,CADb;AAEE;AAFF,WAGM,KAAKA,KAAL,CAAWG,WAHjB;AAIE,oBAAU,KAAKF,KAAL,CAAWC,QAJvB;AAKE,gCAAsB,wCAAY;AAChC,mBAAKE,QAAL,CAAc;AACZF;AADY,aAAd;AAGD;AATH;AAPF,OADF;AAqBD;;;;EA9BiBG,gBAAMC,S;;AAiC1B;;;;;;;;;;AAQA,SAASC,aAAT,CAAuBC,MAAvB,EAA+B;AAC7B,MAAI,CAACA,OAAOC,EAAZ,EAAgB;AACd,UAAM,IAAIC,KAAJ,CAAU,gBAAV,CAAN;AACD;AACD,MAAI,CAACF,OAAOG,IAAZ,EAAkB;AAChB,UAAM,IAAID,KAAJ,CAAU,kBAAV,CAAN;AACD;AACD,MAAI,CAACF,OAAOI,UAAZ,EAAwB;AACtB;AACAJ,WAAOI,UAAP,GAAoB,MAApB;AACAC,YAAQC,IAAR,CAAa,+BAAb;AACD;AACD,MAAI,CAACN,OAAOO,GAAZ,EAAiB;AACf;AACAP,WAAOO,GAAP,GAA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AwB1B,EAAxB;AACA8B;AACD,OAHM,CAAP;AAID,KA/CW;;AAiDZG,mBAAe,0BAAK;AAClB7B,cAAQsB,GAAR,CAAYQ,CAAZ;AACD,KAnDW;AAoDZC,cAAU,kBAACjC,IAAD,EAAOkC,IAAP,EAAgB;AACxBhC,cAAQsB,GAAR,CAAYxB,IAAZ,EAAkBkC,IAAlB;AACD,KAtDW;AAuDZ1C,iBAAa;AACX2C,wBAAkB,gCAAQ;AACxBjC,gBAAQsB,GAAR,CAAYU,IAAZ;AACD;AAHU;AAvDD,GAAd;AA6DD;;AAED;AACA;AACA;AACA;AACA;AACA","file":"index.js","sourcesContent":["import React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport App, { Editor } from \"./App\";\n// import registerServiceWorker from \"./registerServiceWorker\";\n\nclass Index extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n fileList: []\n };\n }\n\n render() {\n return (\n <App\n showAlertComment\n showAlertReply\n showAlertFavor\n showError\n {...this.props}\n >\n <Editor\n maxUpload={9}\n autoFocus\n {...this.props.editorProps}\n fileList={this.state.fileList}\n handleChangeFileList={fileList => {\n this.setState({\n fileList\n });\n }}\n />\n </App>\n );\n }\n}\n\n/**\n * 渲染评论组件\n * @param {object} config 编辑器配置\n * - {string} id 渲染评论的DOM的 ID\n * - {number} type 评论的 type\n * - {string} businessId 评论的 businessId\n * - {string} API, API 前缀, 默认 http://api.links123.net/comment/v1\n */\nfunction renderComment(config) {\n if (!config.id) {\n throw new Error(\"id is required\");\n }\n if (!config.type) {\n throw new Error(\"type is required\");\n }\n if (!config.businessId) {\n // throw new Error(\"businessId is required\");\n config.businessId = \"test\";\n console.warn(\"没有传入 businessId 参数,默认使用: test\");\n }\n if (!config.API) {\n // throw new Error(\"API is required\");\n config.API = \"http://api.links123.net/comment/v1\";\n console.warn(\n \"没有传入 API 参数,默认使用: http://api.links123.net/comment/v1\"\n );\n }\n\n ReactDOM.render(<Index {...config} />, document.getElementById(config.id));\n // registerServiceWorker();\n}\n\nwindow.renderComment = renderComment;\n\nif (process.env.NODE_ENV !== \"production\") {\n renderComment({\n id: \"root-comment\",\n type: 1,\n businessId: \"test\",\n businessUserId: 4,\n userId: 71748,\n currentUser: {\n user_id: 71748\n },\n userAvaHoverData: {\n 71763: {\n nickname: \"aaa\",\n followers: 20,\n fans: 2,\n isFollowed: true\n },\n 71748: {\n nickname: \"L0\",\n followers: 10,\n fans: 11,\n isFollowed: false\n },\n 71299: {\n nickname: \"narro\",\n followers: 10,\n fans: 11,\n isFollowed: false\n }\n },\n showHoverCard: true,\n userAvaClick: id => {\n console.log(\"userAvaClick\", id);\n },\n getUserInfo: id => {\n console.log(\"getinfo:\", id);\n },\n focus: id => {\n return new Promise(function(resolve, reject) {\n console.log(\"focus:\", id);\n resolve();\n });\n },\n unFocus: id => {\n return new Promise(function(resolve, reject) {\n console.log(\"unFocus:\", id);\n resolve();\n });\n },\n\n onCountChange: c => {\n console.log(c);\n },\n onDelete: (type, data) => {\n console.log(type, data);\n },\n editorProps: {\n onCommentSuccess: data => {\n console.log(data);\n }\n }\n });\n}\n\n// renderComment({\n// id: \"root-comment\",\n// type: 1,\n// businessId: \"test\",\n// API: 'http://api.links123.net/comment/v1',\n// });\n"]}