Bläddra i källkod

增加showError props.

narro 6 år sedan
förälder
incheckning
7e3432fe57

+ 33
- 30
README.md Visa fil

@@ -8,45 +8,48 @@
8 8
 import Comment, { Editor, RenderText } from 'comment';
9 9
 ```
10 10
 
11
-- [deprecate] 表示不推荐使用
11
+- 标记了`deprecated`的配置项表示不推荐使用,并且可能在将来版本中不再受支持。
12 12
 
13 13
 ## Comment
14 14
 
15 15
 
16
-| props      | type    | default                            | required | description                                  |
17
-| ---------- | ------- | ---------------------------------- | -------- | -------------------------------------------- |
18
-| type       | number  |                                    | true     | 评论的 type                                  |
19
-| businessId | string  |                                    | true     | 评论的 business id                           |
20
-| API        | string  | http://api.links123.net/comment/v1 | false    | API 前缀                                     |
21
-| showList   | boolean | true                               | false    | 是否显示评论列表                             |
22
-| showEditor | boolean | true                               | false    | 是否显示评论输入框                           |
23
-| showAlertComment | boolean | false                               | false    | 评论成功之后,是否通过 Antd 的 Message 组件进行提示  |
24
-| showAlertReply | boolean | false                               | false    | 回复成功之后,是否通过 Antd 的 Message 组件进行提示  |
25
-| showAlertFavor | boolean | false                               | false    | 点赞/取消点赞成功之后,是否通过 Antd 的 Message 组件进行提示  |
26
-| token      | string  |                                    | false    |  [deprecate] token,用于身份认证,非必须。默认使用 cookie |
16
+| props            | type    | default                            | required | description                                                  |
17
+| ---------------- | ------- | ---------------------------------- | -------- | ------------------------------------------------------------ |
18
+| type             | number  |                                    | true     | 评论的 type                                                  |
19
+| businessId       | string  |                                    | true     | 评论的 business id                                           |
20
+| API              | string  | http://api.links123.net/comment/v1 | false    | API 前缀                                                     |
21
+| showList         | boolean | true                               | false    | 是否显示评论列表                                             |
22
+| showEditor       | boolean | true                               | false    | 是否显示评论输入框                                           |
23
+| showAlertComment | boolean | false                              | false    | 评论成功之后,是否通过 Antd 的 Message 组件进行提示          |
24
+| showAlertReply   | boolean | false                              | false    | 回复成功之后,是否通过 Antd 的 Message 组件进行提示          |
25
+| showAlertFavor   | boolean | false                              | false    | 点赞/取消点赞成功之后,是否通过 Antd 的 Message 组件进行提示 |
26
+| showError        | boolean | true                               | false    | 是否使用Antd的Message组件提示错误信息                        |
27
+| token            | string  |                                    | false    | [deprecated] token,用于身份认证,非必须。默认使用 cookie    |
27 28
 
28 29
 
29 30
 
30 31
 ## Editor
31 32
 
32
-| props         | type            | default       | required | description                                                                                       |
33
-| ------------- | --------------- | ------------- | -------- | ------------------------------------------------------------------------------------------------- |
34
-| rows          | number          | 5             | false    | 编辑器的高度。默认情况下,回复评论/回复回复的编辑器会比评论的编辑器高度小一行                     |
35
-| placeholder   | string          | 说点什么吧... | false    | 评论的中的提示文字                                                                                |
36
-| showEmoji     | boolean         | true          | false    | 是否显示 Toolbar 中表情工具                                                                       |
37
-| showUpload    | boolean         | true          | false    | 是否显示 Toolbar 中 上传图片工具                                                                  |
38
-| maxUpload    | number         |  1          | false    | 最大能够上传的图片数量                                                                  |
39
-| value         | string          |               | false    | 编辑器的值。如果设置了该属性,则编辑器变为受控组件,需要父组件来维护 value                        |
40
-| onChange      | function(value) |               | false    | 编辑器内容改变的回调函数                                                                          |
41
-| onSubmit      | function({ text, files }) |               | false    | 点击提交按钮的回调函数,text 为编辑器的文本,files 为上传的文件列表                           |
42
-| btnSubmitText | string          | 发表          | false    | 提交按钮的文字                                                                                    |
43
-| btnLoading    | boolean         | false         | false    | 按钮是否正在加载中                                                                                |
44
-| btnDisable    | boolean         | false         | false    | 按钮是否禁用                                                                                      |
45
-| button        | ReactNode       |               | false    | 按钮组件。如果上面几个 btn 相关的属性都无法满足要求,则可以使用 button 来自定义提交编辑器值的按钮 |
46
-| emojiToolIcon | ReactNode       |               | false    | Toolbar 中表情的图标                                                                              |
47
-| imageToolIcon | ReactNode       |               | false    | Toolbar 中上传文件的图标                                                     |
48
-| onRef      | function |                                   | false    | 传递子组件的引用                       |
49
-| closeUploadWhenBlur      | boolean |         | false    | 当 upload 失去焦点(鼠标点击非 Upload 的区域)的时候,是否自动关闭 Popover                |
33
+| props               | type                      | default       | required | description                                                                                       |
34
+| ------------------- | ------------------------- | ------------- | -------- | ------------------------------------------------------------------------------------------------- |
35
+| rows                | number                    | 5             | false    | 编辑器的高度。默认情况下,回复评论/回复回复的编辑器会比评论的编辑器高度小一行                     |
36
+| placeholder         | string                    | 说点什么吧... | false    | 评论的中的提示文字                                                                                |
37
+| showEmoji           | boolean                   | true          | false    | 是否显示 Toolbar 中表情工具                                                                       |
38
+| showUpload          | boolean                   | true          | false    | 是否显示 Toolbar 中 上传图片工具                                                                  |
39
+| maxUpload           | number                    | 1             | false    | 最大能够上传的图片数量                                                                            |
40
+| value               | string                    |               | false    | 编辑器的值。如果设置了该属性,则编辑器变为受控组件,需要父组件来维护 value                        |
41
+| onChange            | function(value)           |               | false    | 编辑器内容改变的回调函数                                                                          |
42
+| onSubmit            | function({ text, files }) |               | false    | 点击提交按钮的回调函数,text 为编辑器的文本,files 为上传的文件列表                               |
43
+| btnSubmitText       | string                    | 发表          | false    | 提交按钮的文字                                                                                    |
44
+| btnLoading          | boolean                   | false         | false    | 按钮是否正在加载中                                                                                |
45
+| btnDisable          | boolean                   | false         | false    | 按钮是否禁用                                                                                      |
46
+| button              | ReactNode                 |               | false    | 按钮组件。如果上面几个 btn 相关的属性都无法满足要求,则可以使用 button 来自定义提交编辑器值的按钮 |
47
+| emojiToolIcon       | ReactNode                 |               | false    | Toolbar 中表情的图标                                                                              |
48
+| imageToolIcon       | ReactNode                 |               | false    | Toolbar 中上传文件的图标                                                                          |
49
+| onRef               | function                  |               | false    | 传递子组件的引用                                                                                  |
50
+| closeUploadWhenBlur | boolean                   |               | false    | 当 upload 失去焦点(鼠标点击非 Upload 的区域)的时候,是否自动关闭 Popover                        |
51
+| showError           | boolean                   | true          | false    | 是否使用Antd的Message组件提示错误信息, 主要是上传图片出错的情况                                   |
52
+
50 53
 
51 54
 
52 55
 

+ 33
- 24
lib/App.js Visa fil

@@ -92,6 +92,13 @@ var App = function (_Component) {
92 92
     _this.sCommentFavor = _this.sCommentFavor.bind(_this);
93 93
     _this.sReplyFavor = _this.sReplyFavor.bind(_this);
94 94
     _this.sOssSts = _this.sOssSts.bind(_this);
95
+    _this.message = _extends({}, _message3.default, {
96
+      error: function error() {
97
+        if (_this.props.showError) {
98
+          _message3.default.error.apply(antdMessage, arguments);
99
+        }
100
+      }
101
+    });
95 102
     return _this;
96 103
   }
97 104
 
@@ -165,17 +172,17 @@ var App = function (_Component) {
165 172
             total: total
166 173
           });
167 174
         } else {
168
-          _message3.default.info("没有更多评论了");
175
+          _this2.message.info("没有更多评论了");
169 176
           _this2.setState({
170 177
             isNoMoreComment: true
171 178
           });
172 179
         }
173 180
       }).catch(function (error) {
174 181
         if (error.response && error.response.data && error.response.data.msg) {
175
-          _message3.default.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT);
182
+          _this2.message.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT);
176 183
           return;
177 184
         }
178
-        _message3.default.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
185
+        _this2.message.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
179 186
       }).finally(function () {
180 187
         _this2.handleChangeLoading("sGetComment", false);
181 188
       });
@@ -200,7 +207,7 @@ var App = function (_Component) {
200 207
 
201 208
       this.axios.get(API + "/replies?comment_id=" + commentId + "&page=" + page + "&limit=" + _constant.LIMIT).then(function (response) {
202 209
         if (!response.data.list) {
203
-          _message3.default.info("没有更多数据了!");
210
+          _this3.message.info("没有更多数据了!");
204 211
         }
205 212
         var list = _this3.state.list.map(function (item) {
206 213
           if (item.id === commentId) {
@@ -227,10 +234,10 @@ var App = function (_Component) {
227 234
         _this3.setState({ list: list });
228 235
       }).catch(function (error) {
229 236
         if (error.response && error.response.data && error.response.data.msg) {
230
-          _message3.default.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT);
237
+          _this3.message.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT);
231 238
           return;
232 239
         }
233
-        _message3.default.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
240
+        _this3.message.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
234 241
       }).finally(function () {
235 242
         _this3.handleChangeLoading("sGetReply", false);
236 243
       });
@@ -251,7 +258,7 @@ var App = function (_Component) {
251 258
 
252 259
       var cb = arguments[1];
253 260
 
254
-      if (!content) return _message3.default.error("评论内容不能为空 ");
261
+      if (!content) return this.message.error("评论内容不能为空 ");
255 262
       this.handleChangeLoading("sCreateComment", true);
256 263
       var _props2 = this.props,
257 264
           API = _props2.API,
@@ -268,7 +275,7 @@ var App = function (_Component) {
268 275
         withCredentials: true
269 276
       }).then(function (response) {
270 277
         if (_this4.props.showAlertComment) {
271
-          _message3.default.success("评论成功!");
278
+          _this4.message.success("评论成功!");
272 279
         }
273 280
         if ((0, _helper.isFunction)(cb)) cb();
274 281
         // 将数据写入到 list 中
@@ -284,10 +291,10 @@ var App = function (_Component) {
284 291
         _this4.setState({ list: list, total: total + 1 });
285 292
       }).catch(function (error) {
286 293
         if (error.response && error.response.data && error.response.data.msg) {
287
-          _message3.default.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT);
294
+          _this4.message.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT);
288 295
           return;
289 296
         }
290
-        _message3.default.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
297
+        _this4.message.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
291 298
       }).finally(function () {
292 299
         _this4.handleChangeLoading("sCreateComment", false);
293 300
       });
@@ -304,7 +311,7 @@ var App = function (_Component) {
304 311
     value: function sCreateReply(data, cb) {
305 312
       var _this5 = this;
306 313
 
307
-      if (!data.content) return _message3.default.error("回复内容不能为空 ");
314
+      if (!data.content) return this.message.error("回复内容不能为空 ");
308 315
       this.handleChangeLoading("sCreateReply", true);
309 316
       var API = this.props.API;
310 317
 
@@ -314,7 +321,7 @@ var App = function (_Component) {
314 321
         withCredentials: true
315 322
       }).then(function (response) {
316 323
         if (_this5.props.showAlertReply) {
317
-          _message3.default.success("回复成功!");
324
+          _this5.message.success("回复成功!");
318 325
         }
319 326
         if ((0, _helper.isFunction)(cb)) cb();
320 327
         // 将数据写入到 list 中
@@ -333,10 +340,10 @@ var App = function (_Component) {
333 340
         _this5.setState({ list: list });
334 341
       }).catch(function (error) {
335 342
         if (error.response && error.response.data && error.response.data.msg) {
336
-          _message3.default.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT);
343
+          _this5.message.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT);
337 344
           return;
338 345
         }
339
-        _message3.default.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
346
+        _this5.message.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
340 347
       }).finally(function () {
341 348
         _this5.handleChangeLoading("sCreateReply", false);
342 349
       });
@@ -361,7 +368,7 @@ var App = function (_Component) {
361 368
         withCredentials: true
362 369
       }).then(function (response) {
363 370
         if (_this6.props.showAlertFavor) {
364
-          _message3.default.success(favored ? "取消点赞成功!" : "点赞成功!");
371
+          _this6.message.success(favored ? "取消点赞成功!" : "点赞成功!");
365 372
         }
366 373
         // 更新 list 中的该项数据的 favored
367 374
         var list = _this6.state.list.map(function (item) {
@@ -374,10 +381,10 @@ var App = function (_Component) {
374 381
         _this6.setState({ list: list });
375 382
       }).catch(function (error) {
376 383
         if (error.response && error.response.data && error.response.data.msg) {
377
-          _message3.default.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT);
384
+          _this6.message.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT);
378 385
           return;
379 386
         }
380
-        _message3.default.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
387
+        _this6.message.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
381 388
       }).finally(function () {
382 389
         _this6.handleChangeLoading("sCommentFavor", false);
383 390
       });
@@ -405,7 +412,7 @@ var App = function (_Component) {
405 412
         },
406 413
         withCredentials: true
407 414
       }).then(function (response) {
408
-        _message3.default.success(favored ? "取消点赞成功!" : "点赞成功!");
415
+        _this7.message.success(favored ? "取消点赞成功!" : "点赞成功!");
409 416
         // 更新 list 中的该项数据的 favored
410 417
         var list = _this7.state.list.map(function (item) {
411 418
           if (item.id === commentId) {
@@ -425,10 +432,10 @@ var App = function (_Component) {
425 432
         _this7.setState({ list: list });
426 433
       }).catch(function (error) {
427 434
         if (error.response && error.response.data && error.response.data.msg) {
428
-          _message3.default.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT);
435
+          _this7.message.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT);
429 436
           return;
430 437
         }
431
-        _message3.default.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
438
+        _this7.message.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
432 439
       }).finally(function () {
433 440
         _this7.handleChangeLoading("sReplyFavor", false);
434 441
       });
@@ -450,10 +457,10 @@ var App = function (_Component) {
450 457
         _this8.setState({ oss: _extends({}, response.data) });
451 458
       }).catch(function (error) {
452 459
         if (error.response && error.response.data && error.response.data.msg) {
453
-          _message3.default.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT);
460
+          _this8.message.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT);
454 461
           return;
455 462
         }
456
-        _message3.default.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
463
+        _this8.message.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
457 464
       }).finally(function () {
458 465
         _this8.handleChangeLoading("sOssSts", false);
459 466
       });
@@ -500,7 +507,8 @@ App.propTypes = {
500 507
   showEditor: _propTypes2.default.bool, // 是否显示评论输入框
501 508
   showAlertComment: _propTypes2.default.bool, // 评论成功之后,是否通过 Antd 的 Message 组件进行提示
502 509
   showAlertReply: _propTypes2.default.bool, // 回复成功之后,是否通过 Antd 的 Message 组件进行提示
503
-  showAlertFavor: _propTypes2.default.bool // 点赞/取消点赞成功之后,是否通过 Antd 的 Message 组件进行提示
510
+  showAlertFavor: _propTypes2.default.bool, // 点赞/取消点赞成功之后,是否通过 Antd 的 Message 组件进行提示
511
+  showError: _propTypes2.default.bool // 是否使用Antd的Message组件提示错误信息
504 512
 };
505 513
 
506 514
 App.defaultProps = {
@@ -509,7 +517,8 @@ App.defaultProps = {
509 517
   showEditor: true,
510 518
   showAlertComment: false,
511 519
   showAlertReply: false,
512
-  showAlertFavor: false
520
+  showAlertFavor: false,
521
+  showError: true
513 522
 };
514 523
 
515 524
 exports.Editor = _Editor2.default;

+ 1
- 1
lib/App.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 1
- 1
lib/avatar.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 1
- 1
lib/axios.js.map Visa fil

@@ -1 +1 @@
1
-{"version":3,"sources":["../src/axios.js"],"names":["axios","defaults","withCredentials","headers","common"],"mappings":";;;;;;AAAA;;;;;;AAEAA,gBAAMC,QAAN,CAAeC,eAAf,GAAiC,IAAjC;AACAF,gBAAMC,QAAN,CAAeE,OAAf,CAAuBC,MAAvB,CAA8B,eAA9B,IAAiD,SAAjD;;kBAEeJ,e","file":"axios.js","sourcesContent":["import axios from \"axios\";\n\naxios.defaults.withCredentials = true;\naxios.defaults.headers.common[\"Authorization\"] = \"Bearer \";\n\nexport default axios;\n"]}
1
+{"version":3,"sources":["../src/axios.js"],"names":["axios","defaults","withCredentials","headers","common"],"mappings":";;;;;;AAAA;;;;;;AAEAA,gBAAMC,QAAN,CAAeC,eAAf,GAAiC,IAAjC;AACAF,gBAAMC,QAAN,CAAeE,OAAf,CAAuBC,MAAvB,CAA8B,eAA9B,IAAiD,SAAjD;;kBAEeJ,e","file":"axios.js","sourcesContent":["import axios from \"axios\";\r\n\r\naxios.defaults.withCredentials = true;\r\naxios.defaults.headers.common[\"Authorization\"] = \"Bearer \";\r\n\r\nexport default axios;\r\n"]}

+ 1
- 1
lib/components/CommentBox/index.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 1
- 1
lib/components/CommentInput/index.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 1
- 1
lib/components/CommentList/index.js.map Visa fil

@@ -1 +1 @@
1
-{"version":3,"sources":["../../../src/components/CommentList/index.js"],"names":["CommentList","props","state","app","sGetComment","list","total","page","loading","isNoMoreComment","spinning","Boolean","sCommentFavor","sReplyFavor","map","item","id","length","Component","propTypes"],"mappings":";;;;;;;;;;;;;;AAAA;;;;AAEA;;;;AACA;;;;AACA;;;;;;;;;;IAEMA,W;;;AACJ,uBAAYC,KAAZ,EAAmB;AAAA;;AAAA,0HACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa,EAAb;AAFiB;AAGlB;;;;yCAEoB;AACnB,WAAKD,KAAL,CAAWE,GAAX,CAAeC,WAAf;AACD;;;6BAEQ;AAAA,uBAQH,KAAKH,KAAL,CAAWE,GARR;AAAA,UAELE,IAFK,cAELA,IAFK;AAAA,UAGLC,KAHK,cAGLA,KAHK;AAAA,UAILC,IAJK,cAILA,IAJK;AAAA,UAKLC,OALK,cAKLA,OALK;AAAA,UAMLC,eANK,cAMLA,eANK;AAAA,UAOLL,WAPK,cAOLA,WAPK;;;AAUP,UAAMM,WAAWC,QACfH,QAAQJ,WAAR,IAAuBI,QAAQI,aAA/B,IAAgDJ,QAAQK,WADzC,CAAjB;AAGA,aACE;AAAA;AAAA;AACE;AAAA;AAAA,YAAM,UAAUH,QAAhB;AACE;AAAA;AAAA;AAAA;AAAQJ,iBAAR;AAAA;AAAA,WADF;AAEGD,eAAKS,GAAL,CAAS;AAAA,mBACR,8BAAC,oBAAD,IAAY,SAASC,IAArB,EAA2B,KAAKA,KAAKC,EAArC,EAAyC,WAAWD,KAAKC,EAAzD,GADQ;AAAA,WAAT,CAFH;AAMG,WAACP,eAAD,IACCJ,KAAKY,MAAL,KAAgBX,KADjB,IAEG;AAAA;AAAA;AACE,yBAAU,wBADZ;AAEE,uBAAS;AAAA,uBAAMF,YAAY,EAAEG,MAAMA,OAAO,CAAf,EAAZ,CAAN;AAAA;AAFX;AAIE;AAAA;AAAA;AAAA;AAAA;AAJF;AARN;AADF,OADF;AAoBD;;;;EA3CuBW,gB;;AA8C1BlB,YAAYmB,SAAZ,GAAwB,EAAxB;;kBAEe,uBAAQnB,WAAR,C","file":"index.js","sourcesContent":["import React, { Component } from \"react\";\nimport { Spin } from \"antd\";\nimport Comment from \"../../Comment\";\nimport CommentBox from \"../CommentBox\";\nimport \"./index.css\";\n\nclass CommentList extends Component {\n  constructor(props) {\n    super(props);\n    this.state = {};\n  }\n\n  componentWillMount() {\n    this.props.app.sGetComment();\n  }\n\n  render() {\n    const {\n      list,\n      total,\n      page,\n      loading,\n      isNoMoreComment,\n      sGetComment\n    } = this.props.app;\n\n    const spinning = Boolean(\n      loading.sGetComment || loading.sCommentFavor || loading.sReplyFavor\n    );\n    return (\n      <div>\n        <Spin spinning={spinning}>\n          <div>共 {total} 条评论</div>\n          {list.map(item => (\n            <CommentBox content={item} key={item.id} commentId={item.id} />\n          ))}\n\n          {!isNoMoreComment &&\n            list.length !== total && (\n              <div\n                className=\"comment-list-show-more\"\n                onClick={() => sGetComment({ page: page + 1 })}\n              >\n                <span>查看更多评论</span>\n              </div>\n            )}\n        </Spin>\n      </div>\n    );\n  }\n}\n\nCommentList.propTypes = {};\n\nexport default Comment(CommentList);\n"]}
1
+{"version":3,"sources":["../../../src/components/CommentList/index.js"],"names":["CommentList","props","state","app","sGetComment","list","total","page","loading","isNoMoreComment","spinning","Boolean","sCommentFavor","sReplyFavor","map","item","id","length","Component","propTypes"],"mappings":";;;;;;;;;;;;;;AAAA;;;;AAEA;;;;AACA;;;;AACA;;;;;;;;;;IAEMA,W;;;AACJ,uBAAYC,KAAZ,EAAmB;AAAA;;AAAA,0HACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa,EAAb;AAFiB;AAGlB;;;;yCAEoB;AACnB,WAAKD,KAAL,CAAWE,GAAX,CAAeC,WAAf;AACD;;;6BAEQ;AAAA,uBAQH,KAAKH,KAAL,CAAWE,GARR;AAAA,UAELE,IAFK,cAELA,IAFK;AAAA,UAGLC,KAHK,cAGLA,KAHK;AAAA,UAILC,IAJK,cAILA,IAJK;AAAA,UAKLC,OALK,cAKLA,OALK;AAAA,UAMLC,eANK,cAMLA,eANK;AAAA,UAOLL,WAPK,cAOLA,WAPK;;;AAUP,UAAMM,WAAWC,QACfH,QAAQJ,WAAR,IAAuBI,QAAQI,aAA/B,IAAgDJ,QAAQK,WADzC,CAAjB;AAGA,aACE;AAAA;AAAA;AACE;AAAA;AAAA,YAAM,UAAUH,QAAhB;AACE;AAAA;AAAA;AAAA;AAAQJ,iBAAR;AAAA;AAAA,WADF;AAEGD,eAAKS,GAAL,CAAS;AAAA,mBACR,8BAAC,oBAAD,IAAY,SAASC,IAArB,EAA2B,KAAKA,KAAKC,EAArC,EAAyC,WAAWD,KAAKC,EAAzD,GADQ;AAAA,WAAT,CAFH;AAMG,WAACP,eAAD,IACCJ,KAAKY,MAAL,KAAgBX,KADjB,IAEG;AAAA;AAAA;AACE,yBAAU,wBADZ;AAEE,uBAAS;AAAA,uBAAMF,YAAY,EAAEG,MAAMA,OAAO,CAAf,EAAZ,CAAN;AAAA;AAFX;AAIE;AAAA;AAAA;AAAA;AAAA;AAJF;AARN;AADF,OADF;AAoBD;;;;EA3CuBW,gB;;AA8C1BlB,YAAYmB,SAAZ,GAAwB,EAAxB;;kBAEe,uBAAQnB,WAAR,C","file":"index.js","sourcesContent":["import React, { Component } from \"react\";\r\nimport { Spin } from \"antd\";\r\nimport Comment from \"../../Comment\";\r\nimport CommentBox from \"../CommentBox\";\r\nimport \"./index.css\";\r\n\r\nclass CommentList extends Component {\r\n  constructor(props) {\r\n    super(props);\r\n    this.state = {};\r\n  }\r\n\r\n  componentWillMount() {\r\n    this.props.app.sGetComment();\r\n  }\r\n\r\n  render() {\r\n    const {\r\n      list,\r\n      total,\r\n      page,\r\n      loading,\r\n      isNoMoreComment,\r\n      sGetComment\r\n    } = this.props.app;\r\n\r\n    const spinning = Boolean(\r\n      loading.sGetComment || loading.sCommentFavor || loading.sReplyFavor\r\n    );\r\n    return (\r\n      <div>\r\n        <Spin spinning={spinning}>\r\n          <div>共 {total} 条评论</div>\r\n          {list.map(item => (\r\n            <CommentBox content={item} key={item.id} commentId={item.id} />\r\n          ))}\r\n\r\n          {!isNoMoreComment &&\r\n            list.length !== total && (\r\n              <div\r\n                className=\"comment-list-show-more\"\r\n                onClick={() => sGetComment({ page: page + 1 })}\r\n              >\r\n                <span>查看更多评论</span>\r\n              </div>\r\n            )}\r\n        </Spin>\r\n      </div>\r\n    );\r\n  }\r\n}\r\n\r\nCommentList.propTypes = {};\r\n\r\nexport default Comment(CommentList);\r\n"]}

+ 1
- 1
lib/components/ContentItem/index.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 1
- 1
lib/components/Editor/Emoji.js.map Visa fil

@@ -1 +1 @@
1
-{"version":3,"sources":["../../../src/components/Editor/Emoji.js"],"names":["Emoji","onClick","content","i","emoji","length","push","map","item","index","value","prefixUrl","ext","title","display"],"mappings":";;;;;;;;;;;;AAAA;;;;AAEA;;;;AACA;;;;AACA;AACA;;AAEA;;AAEA,IAAMA,QAAQ,SAARA,KAAQ,OAAiB;AAAA,MAAdC,QAAc,QAAdA,OAAc;;AAC7B,MAAMC,UAAU,CAAC,EAAD,EAAK,EAAL,EAAS,EAAT,CAAhB;;AAEA,OAAK,IAAIC,IAAI,CAAb,EAAgBA,IAAIC,gBAAMC,MAA1B,EAAkCF,GAAlC,EAAuC;AACrC,QAAIA,IAAI,EAAR,EAAY;AACVD,cAAQ,CAAR,EAAWI,IAAX,CAAgBF,gBAAMD,CAAN,CAAhB;AACD,KAFD,MAEO,IAAIA,IAAI,EAAR,EAAY;AACjBD,cAAQ,CAAR,EAAWI,IAAX,CAAgBF,gBAAMD,CAAN,CAAhB;AACD,KAFM,MAEA,IAAIA,IAAIC,gBAAMC,MAAd,EAAsB;AAC3BH,cAAQ,CAAR,EAAWI,IAAX,CAAgBF,gBAAMD,CAAN,CAAhB;AACD;AACF;AACD,SACE;AAAA;AAAA;AACE;AAAA;AAAA;AACGD,cAAQ,CAAR,EAAWK,GAAX,CAAe,UAACC,IAAD,EAAOC,KAAP;AAAA,eACd;AAAA;AAAA,YAAK,WAAU,MAAf,EAAsB,KAAKD,KAAKE,KAAhC;AACE,kDAAM,WAAU,QAAhB,GADF;AAEE;AACE,sBAAQC,gBAAR,GAAoBH,KAAKE,KAAzB,SAAkCE,UADpC;AAEE,iBAAKJ,KAAKK,KAFZ;AAGE,mBAAO,EAAEC,SAAS,cAAX,EAHT;AAIE,qBAAS;AAAA,qBAAMb,SAAQO,KAAKK,KAAb,CAAN;AAAA;AAJX;AAFF,SADc;AAAA,OAAf;AADH,KADF;AAcE;AAAA;AAAA;AACGX,cAAQ,CAAR,EAAWK,GAAX,CAAe,UAACC,IAAD,EAAOC,KAAP;AAAA,eACd;AAAA;AAAA,YAAK,WAAU,MAAf,EAAsB,KAAKD,KAAKE,KAAhC;AACE,kDAAM,WAAU,QAAhB,GADF;AAEE;AACE,sBAAQC,gBAAR,GAAoBH,KAAKE,KAAzB,SAAkCE,UADpC;AAEE,iBAAKJ,KAAKK,KAFZ;AAGE,mBAAO,EAAEC,SAAS,cAAX,EAHT;AAIE,qBAAS;AAAA,qBAAMb,SAAQO,KAAKK,KAAb,CAAN;AAAA;AAJX;AAFF,SADc;AAAA,OAAf;AADH,KAdF;AA2BE;AAAA;AAAA;AACGX,cAAQ,CAAR,EAAWK,GAAX,CAAe;AAAA,eACd;AAAA;AAAA,YAAK,WAAU,MAAf,EAAsB,KAAKC,KAAKE,KAAhC;AACE,kDAAM,WAAU,QAAhB,GADF;AAEE;AACE,sBAAQC,gBAAR,GAAoBH,KAAKE,KAAzB,SAAkCE,UADpC;AAEE,iBAAKJ,KAAKK,KAFZ;AAGE,mBAAO,EAAEC,SAAS,cAAX,EAHT;AAIE,qBAAS;AAAA,qBAAMb,SAAQO,KAAKK,KAAb,CAAN;AAAA;AAJX;AAFF,SADc;AAAA,OAAf;AADH;AA3BF,GADF;AA2CD,CAvDD;;kBAyDeb,K","file":"Emoji.js","sourcesContent":["import React from \"react\";\nimport { Carousel } from \"antd\";\nimport emoji, { prefixUrl, ext } from \"../../emoji\";\nimport \"./Emoji.css\";\n// 每页 20  5*4\n// 共 20 * 3 = 60 (实际是 54)\n\n// class Emoji\n\nconst Emoji = ({ onClick }) => {\n  const content = [[], [], []];\n\n  for (let i = 0; i < emoji.length; i++) {\n    if (i < 20) {\n      content[0].push(emoji[i]);\n    } else if (i < 40) {\n      content[1].push(emoji[i]);\n    } else if (i < emoji.length) {\n      content[2].push(emoji[i]);\n    }\n  }\n  return (\n    <Carousel>\n      <div>\n        {content[0].map((item, index) => (\n          <div className=\"item\" key={item.value}>\n            <span className=\"helper\" />\n            <img\n              src={`${prefixUrl}${item.value}.${ext}`}\n              alt={item.title}\n              style={{ display: \"inline-block\" }}\n              onClick={() => onClick(item.title)}\n            />\n          </div>\n        ))}\n      </div>\n      <div>\n        {content[1].map((item, index) => (\n          <div className=\"item\" key={item.value}>\n            <span className=\"helper\" />\n            <img\n              src={`${prefixUrl}${item.value}.${ext}`}\n              alt={item.title}\n              style={{ display: \"inline-block\" }}\n              onClick={() => onClick(item.title)}\n            />\n          </div>\n        ))}\n      </div>\n      <div>\n        {content[2].map(item => (\n          <div className=\"item\" key={item.value}>\n            <span className=\"helper\" />\n            <img\n              src={`${prefixUrl}${item.value}.${ext}`}\n              alt={item.title}\n              style={{ display: \"inline-block\" }}\n              onClick={() => onClick(item.title)}\n            />\n          </div>\n        ))}\n      </div>\n    </Carousel>\n  );\n};\n\nexport default Emoji;\n"]}
1
+{"version":3,"sources":["../../../src/components/Editor/Emoji.js"],"names":["Emoji","onClick","content","i","emoji","length","push","map","item","index","value","prefixUrl","ext","title","display"],"mappings":";;;;;;;;;;;;AAAA;;;;AAEA;;;;AACA;;;;AACA;AACA;;AAEA;;AAEA,IAAMA,QAAQ,SAARA,KAAQ,OAAiB;AAAA,MAAdC,QAAc,QAAdA,OAAc;;AAC7B,MAAMC,UAAU,CAAC,EAAD,EAAK,EAAL,EAAS,EAAT,CAAhB;;AAEA,OAAK,IAAIC,IAAI,CAAb,EAAgBA,IAAIC,gBAAMC,MAA1B,EAAkCF,GAAlC,EAAuC;AACrC,QAAIA,IAAI,EAAR,EAAY;AACVD,cAAQ,CAAR,EAAWI,IAAX,CAAgBF,gBAAMD,CAAN,CAAhB;AACD,KAFD,MAEO,IAAIA,IAAI,EAAR,EAAY;AACjBD,cAAQ,CAAR,EAAWI,IAAX,CAAgBF,gBAAMD,CAAN,CAAhB;AACD,KAFM,MAEA,IAAIA,IAAIC,gBAAMC,MAAd,EAAsB;AAC3BH,cAAQ,CAAR,EAAWI,IAAX,CAAgBF,gBAAMD,CAAN,CAAhB;AACD;AACF;AACD,SACE;AAAA;AAAA;AACE;AAAA;AAAA;AACGD,cAAQ,CAAR,EAAWK,GAAX,CAAe,UAACC,IAAD,EAAOC,KAAP;AAAA,eACd;AAAA;AAAA,YAAK,WAAU,MAAf,EAAsB,KAAKD,KAAKE,KAAhC;AACE,kDAAM,WAAU,QAAhB,GADF;AAEE;AACE,sBAAQC,gBAAR,GAAoBH,KAAKE,KAAzB,SAAkCE,UADpC;AAEE,iBAAKJ,KAAKK,KAFZ;AAGE,mBAAO,EAAEC,SAAS,cAAX,EAHT;AAIE,qBAAS;AAAA,qBAAMb,SAAQO,KAAKK,KAAb,CAAN;AAAA;AAJX;AAFF,SADc;AAAA,OAAf;AADH,KADF;AAcE;AAAA;AAAA;AACGX,cAAQ,CAAR,EAAWK,GAAX,CAAe,UAACC,IAAD,EAAOC,KAAP;AAAA,eACd;AAAA;AAAA,YAAK,WAAU,MAAf,EAAsB,KAAKD,KAAKE,KAAhC;AACE,kDAAM,WAAU,QAAhB,GADF;AAEE;AACE,sBAAQC,gBAAR,GAAoBH,KAAKE,KAAzB,SAAkCE,UADpC;AAEE,iBAAKJ,KAAKK,KAFZ;AAGE,mBAAO,EAAEC,SAAS,cAAX,EAHT;AAIE,qBAAS;AAAA,qBAAMb,SAAQO,KAAKK,KAAb,CAAN;AAAA;AAJX;AAFF,SADc;AAAA,OAAf;AADH,KAdF;AA2BE;AAAA;AAAA;AACGX,cAAQ,CAAR,EAAWK,GAAX,CAAe;AAAA,eACd;AAAA;AAAA,YAAK,WAAU,MAAf,EAAsB,KAAKC,KAAKE,KAAhC;AACE,kDAAM,WAAU,QAAhB,GADF;AAEE;AACE,sBAAQC,gBAAR,GAAoBH,KAAKE,KAAzB,SAAkCE,UADpC;AAEE,iBAAKJ,KAAKK,KAFZ;AAGE,mBAAO,EAAEC,SAAS,cAAX,EAHT;AAIE,qBAAS;AAAA,qBAAMb,SAAQO,KAAKK,KAAb,CAAN;AAAA;AAJX;AAFF,SADc;AAAA,OAAf;AADH;AA3BF,GADF;AA2CD,CAvDD;;kBAyDeb,K","file":"Emoji.js","sourcesContent":["import React from \"react\";\r\nimport { Carousel } from \"antd\";\r\nimport emoji, { prefixUrl, ext } from \"../../emoji\";\r\nimport \"./Emoji.css\";\r\n// 每页 20  5*4\r\n// 共 20 * 3 = 60 (实际是 54)\r\n\r\n// class Emoji\r\n\r\nconst Emoji = ({ onClick }) => {\r\n  const content = [[], [], []];\r\n\r\n  for (let i = 0; i < emoji.length; i++) {\r\n    if (i < 20) {\r\n      content[0].push(emoji[i]);\r\n    } else if (i < 40) {\r\n      content[1].push(emoji[i]);\r\n    } else if (i < emoji.length) {\r\n      content[2].push(emoji[i]);\r\n    }\r\n  }\r\n  return (\r\n    <Carousel>\r\n      <div>\r\n        {content[0].map((item, index) => (\r\n          <div className=\"item\" key={item.value}>\r\n            <span className=\"helper\" />\r\n            <img\r\n              src={`${prefixUrl}${item.value}.${ext}`}\r\n              alt={item.title}\r\n              style={{ display: \"inline-block\" }}\r\n              onClick={() => onClick(item.title)}\r\n            />\r\n          </div>\r\n        ))}\r\n      </div>\r\n      <div>\r\n        {content[1].map((item, index) => (\r\n          <div className=\"item\" key={item.value}>\r\n            <span className=\"helper\" />\r\n            <img\r\n              src={`${prefixUrl}${item.value}.${ext}`}\r\n              alt={item.title}\r\n              style={{ display: \"inline-block\" }}\r\n              onClick={() => onClick(item.title)}\r\n            />\r\n          </div>\r\n        ))}\r\n      </div>\r\n      <div>\r\n        {content[2].map(item => (\r\n          <div className=\"item\" key={item.value}>\r\n            <span className=\"helper\" />\r\n            <img\r\n              src={`${prefixUrl}${item.value}.${ext}`}\r\n              alt={item.title}\r\n              style={{ display: \"inline-block\" }}\r\n              onClick={() => onClick(item.title)}\r\n            />\r\n          </div>\r\n        ))}\r\n      </div>\r\n    </Carousel>\r\n  );\r\n};\r\n\r\nexport default Emoji;\r\n"]}

+ 3
- 1
lib/components/Editor/Upload.js Visa fil

@@ -145,7 +145,9 @@ var App = function (_React$Component) {
145 145
           info.onSuccess();
146 146
           _this2.props.onUpload({ path: data.name, uid: file.uid });
147 147
         }).catch(function (e) {
148
-          _message3.default.error(e.message || _constant.ERROR_DEFAULT);
148
+          if (_this2.props.showError) {
149
+            _message3.default.error(e.message || _constant.ERROR_DEFAULT);
150
+          }
149 151
           info.onError(e);
150 152
         });
151 153
       };

+ 1
- 1
lib/components/Editor/Upload.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 6
- 3
lib/components/Editor/index.js Visa fil

@@ -339,7 +339,8 @@ var Editor = function (_React$Component) {
339 339
                     onChangeFileList: this.handleChangeFileList,
340 340
                     onUpload: this.handleUpload,
341 341
                     maxUpload: maxUpload,
342
-                    fileList: this.state.fileList
342
+                    fileList: this.state.fileList,
343
+                    showError: this.props.showError
343 344
                   })
344 345
                 ),
345 346
                 placement: "bottomLeft",
@@ -426,7 +427,8 @@ Editor.propTypes = {
426 427
   btnDisabled: _propTypes2.default.bool,
427 428
   button: _propTypes2.default.node,
428 429
   emojiToolIcon: _propTypes2.default.node,
429
-  imageToolIcon: _propTypes2.default.node
430
+  imageToolIcon: _propTypes2.default.node,
431
+  showError: _propTypes2.default.bool
430 432
 };
431 433
 
432 434
 Editor.defaultProps = {
@@ -438,7 +440,8 @@ Editor.defaultProps = {
438 440
   maxUpload: 1,
439 441
   btnSubmitText: "发表",
440 442
   btnLoading: false,
441
-  btnDisabled: false
443
+  btnDisabled: false,
444
+  showError: true
442 445
 };
443 446
 
444 447
 exports.default = Editor;

+ 1
- 1
lib/components/Editor/index.js.map
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 1
- 1
lib/components/RenderText/index.js.map Visa fil

@@ -1 +1 @@
1
-{"version":3,"sources":["../../../src/components/RenderText/index.js"],"names":["App","__html","text"],"mappings":";;;;;;AAAA;;;;AACA;;;;AAEA,IAAMA,MAAM,SAANA,GAAM;AAAA,SACV;AACE,eAAU,sBADZ;AAEE,6BAAyB;AACvBC,cAAQ,2BAAcC,IAAd;AADe;AAF3B,IADU;AAAA,CAAZ;;kBASeF,G","file":"index.js","sourcesContent":["import React from \"react\";\nimport { renderContent } from \"../../helper\";\n\nconst App = text => (\n  <div\n    className=\"comment-item-content\"\n    dangerouslySetInnerHTML={{\n      __html: renderContent(text)\n    }}\n  />\n);\n\nexport default App;\n"]}
1
+{"version":3,"sources":["../../../src/components/RenderText/index.js"],"names":["App","__html","text"],"mappings":";;;;;;AAAA;;;;AACA;;;;AAEA,IAAMA,MAAM,SAANA,GAAM;AAAA,SACV;AACE,eAAU,sBADZ;AAEE,6BAAyB;AACvBC,cAAQ,2BAAcC,IAAd;AADe;AAF3B,IADU;AAAA,CAAZ;;kBASeF,G","file":"index.js","sourcesContent":["import React from \"react\";\r\nimport { renderContent } from \"../../helper\";\r\n\r\nconst App = text => (\r\n  <div\r\n    className=\"comment-item-content\"\r\n    dangerouslySetInnerHTML={{\r\n      __html: renderContent(text)\r\n    }}\r\n  />\r\n);\r\n\r\nexport default App;\r\n"]}

+ 1
- 1
lib/constant.js.map Visa fil

@@ -1 +1 @@
1
-{"version":3,"sources":["../src/constant.js"],"names":["ERROR_DEFAULT","LIMIT","OSS_ENDPOINT","OSS_BUCKET","DRIVER_LICENSE_PATH","OSS_LINK","MAX_UPLOAD_NUMBER","REGEXP","AVATAR","IMAGE_SPLIT"],"mappings":";;;;;AAAO,IAAMA,wCAAgB,MAAtB;;AAEA,IAAMC,wBAAQ,EAAd,C,CAAkB;;AAElB,IAAMC,sCAAe,6BAArB;AACA,IAAMC,kCAAa,eAAnB;AACA,IAAMC,oDAAsB,UAA5B;;AAEA,IAAMC,8BAAW,kDAAjB;;AAEA,IAAMC,gDAAoB,CAA1B;;AAEA,IAAMC,0BAAS,UAAf;;AAEA,IAAMC,0BAAS,EAAf;;AAEA,IAAMC,oCAAc,aAApB","file":"constant.js","sourcesContent":["export const ERROR_DEFAULT = \"出错了!\";\n\nexport const LIMIT = 10; // 默认 limit\n\nexport const OSS_ENDPOINT = \"oss-cn-beijing.aliyuncs.com\";\nexport const OSS_BUCKET = \"links-comment\";\nexport const DRIVER_LICENSE_PATH = \"/comment\";\n\nexport const OSS_LINK = \"http://links-comment.oss-cn-beijing.aliyuncs.com\";\n\nexport const MAX_UPLOAD_NUMBER = 4;\n\nexport const REGEXP = /\\[.+?\\]/g;\n\nexport const AVATAR = \"\";\n\nexport const IMAGE_SPLIT = \"IMAGE_SPLIT\";\n"]}
1
+{"version":3,"sources":["../src/constant.js"],"names":["ERROR_DEFAULT","LIMIT","OSS_ENDPOINT","OSS_BUCKET","DRIVER_LICENSE_PATH","OSS_LINK","MAX_UPLOAD_NUMBER","REGEXP","AVATAR","IMAGE_SPLIT"],"mappings":";;;;;AAAO,IAAMA,wCAAgB,MAAtB;;AAEA,IAAMC,wBAAQ,EAAd,C,CAAkB;;AAElB,IAAMC,sCAAe,6BAArB;AACA,IAAMC,kCAAa,eAAnB;AACA,IAAMC,oDAAsB,UAA5B;;AAEA,IAAMC,8BAAW,kDAAjB;;AAEA,IAAMC,gDAAoB,CAA1B;;AAEA,IAAMC,0BAAS,UAAf;;AAEA,IAAMC,0BAAS,EAAf;;AAEA,IAAMC,oCAAc,aAApB","file":"constant.js","sourcesContent":["export const ERROR_DEFAULT = \"出错了!\";\r\n\r\nexport const LIMIT = 10; // 默认 limit\r\n\r\nexport const OSS_ENDPOINT = \"oss-cn-beijing.aliyuncs.com\";\r\nexport const OSS_BUCKET = \"links-comment\";\r\nexport const DRIVER_LICENSE_PATH = \"/comment\";\r\n\r\nexport const OSS_LINK = \"http://links-comment.oss-cn-beijing.aliyuncs.com\";\r\n\r\nexport const MAX_UPLOAD_NUMBER = 4;\r\n\r\nexport const REGEXP = /\\[.+?\\]/g;\r\n\r\nexport const AVATAR = \"\";\r\n\r\nexport const IMAGE_SPLIT = \"IMAGE_SPLIT\";\r\n"]}

+ 1
- 1
lib/helper.js.map Visa fil

@@ -1 +1 @@
1
-{"version":3,"sources":["../src/helper.js"],"names":["isFunction","isUrl","arrayToObject","htmlEncode","renderContent","emojiObejct","emoji","functionToCheck","toString","call","userInput","regexp","res","match","array","keyField","reduce","obj","item","str","replace","i","charCodeAt","content","onClick","newContent","indexOf","IMAGE_SPLIT","split","pop","join","REGEXP","a","b","src","slice","value","prefixUrl","ext"],"mappings":";;;;;QAKgBA,U,GAAAA,U;QAMAC,K,GAAAA,K;QAYAC,a,GAAAA,a;QAYAC,U,GAAAA,U;QAYAC,a,GAAAA,a;;AA/ChB;;AACA;;;;;;AAEA,IAAMC,cAAcH,cAAcI,eAAd,EAAqB,OAArB,CAApB;;AAEO,SAASN,UAAT,CAAoBO,eAApB,EAAqC;AAC1C,SACEA,mBAAmB,GAAGC,QAAH,CAAYC,IAAZ,CAAiBF,eAAjB,MAAsC,mBAD3D;AAGD;;AAEM,SAASN,KAAT,CAAeS,SAAf,EAA0B;AAC/B,MAAMC,SAAS,kGAAf;AACA,MAAIC,MAAMF,UAAUG,KAAV,CAAgBF,MAAhB,CAAV;AACA,MAAIC,QAAQ,IAAZ,EAAkB,OAAO,KAAP,CAAlB,KACK,OAAO,IAAP;AACN;;AAED;;;;;AAKO,SAASV,aAAT,CAAuBY,KAAvB,EAA8BC,QAA9B,EAAwC;AAC7C,SAAOD,MAAME,MAAN,CAAa,UAACC,GAAD,EAAMC,IAAN,EAAe;AACjCD,QAAIC,KAAKH,QAAL,CAAJ,IAAsBG,IAAtB;AACA,WAAOD,GAAP;AACD,GAHM,EAGJ,EAHI,CAAP;AAID;;AAED;;;;;AAKO,SAASd,UAAT,CAAoBgB,GAApB,EAAyB;AAC9B,MAAI,CAACA,GAAL,EAAU,OAAO,EAAP;AACV,SAAOA,IAAIC,OAAJ,CAAY,SAAZ,EAAuB,UAASC,CAAT,EAAY;AACxC,WAAO,OAAOA,EAAEC,UAAF,CAAa,CAAb,CAAP,GAAyB,GAAhC;AACD,GAFM,CAAP;AAGD;;AAED;;;;;AAKO,SAASlB,aAAT,CAAuBmB,OAAvB,EAAgCC,OAAhC,EAAyC;AAC9C,MAAIC,aAAaF,OAAjB;AACA,MAAIE,WAAWC,OAAX,CAAmBC,qBAAnB,MAAoC,CAAC,CAAzC,EAA4C;AAC1CF,iBAAaA,WAAWG,KAAX,CAAiBD,qBAAjB,CAAb;AACAF,eAAWI,GAAX;AACAJ,iBAAaA,WAAWK,IAAX,CAAgB,EAAhB,CAAb;AACD;;AAED,SAAO3B,WAAWsB,UAAX,EAAuBL,OAAvB,CAA+BW,gBAA/B,EAAuC,UAASC,CAAT,EAAYC,CAAZ,EAAe;AAC3D,QAAMC,MAAMF,EAAEG,KAAF,CAAQ,CAAR,EAAW,CAAC,CAAZ,CAAZ;;AAEA;AACA;AACA,QAAIlC,MAAMiC,GAAN,CAAJ,EAAgB;AACd,kCAAyBA,GAAzB,iBAAsCA,GAAtC;AACD;AACD,QAAME,QAAQ/B,YAAY6B,GAAZ,IAAmB7B,YAAY6B,GAAZ,EAAiBE,KAApC,GAA4CF,GAA1D;AACA,2BAAoBG,gBAApB,GAAgCD,KAAhC,SAAyCE,UAAzC,iBAAsDF,KAAtD;AACD,GAVM,CAAP;AAWD","file":"helper.js","sourcesContent":["import { REGEXP, IMAGE_SPLIT } from \"./constant\";\nimport emoji, { prefixUrl, ext } from \"./emoji\";\n\nconst emojiObejct = arrayToObject(emoji, \"title\");\n\nexport function isFunction(functionToCheck) {\n  return (\n    functionToCheck && {}.toString.call(functionToCheck) === \"[object Function]\"\n  );\n}\n\nexport function isUrl(userInput) {\n  const regexp = /(http(s)?:\\/\\/.)?(www\\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/g;\n  var res = userInput.match(regexp);\n  if (res === null) return false;\n  else return true;\n}\n\n/**\n * 将对象数组转换为对象\n * @param {array} array Array of Objects\n * @param {string} keyField string\n */\nexport function arrayToObject(array, keyField) {\n  return array.reduce((obj, item) => {\n    obj[item[keyField]] = item;\n    return obj;\n  }, {});\n}\n\n/**\n * HTML 编码\n * 将 < > 等字符串进行编码\n * @param {string} str 文本\n */\nexport function htmlEncode(str) {\n  if (!str) return \"\";\n  return str.replace(/[<>]/gim, function(i) {\n    return \"&#\" + i.charCodeAt(0) + \";\";\n  });\n}\n\n/**\n * 渲染编辑器\n * [x] => <img src=\"x\" />\n * @param {strig} content\n */\nexport function renderContent(content, onClick) {\n  let newContent = content;\n  if (newContent.indexOf(IMAGE_SPLIT) !== -1) {\n    newContent = newContent.split(IMAGE_SPLIT);\n    newContent.pop();\n    newContent = newContent.join(\"\");\n  }\n\n  return htmlEncode(newContent).replace(REGEXP, function(a, b) {\n    const src = a.slice(1, -1);\n\n    // 兼容旧的评\n    // 因为旧的评论用 [img url] 方式存储的\n    if (isUrl(src)) {\n      return `<br/><img src=\"${src}\" alt=\"${src}\" style=\"max-width: 100%\" />`;\n    }\n    const value = emojiObejct[src] ? emojiObejct[src].value : src;\n    return `<img src=\"${prefixUrl}${value}.${ext}\" alt=\"${value}\" />`;\n  });\n}\n"]}
1
+{"version":3,"sources":["../src/helper.js"],"names":["isFunction","isUrl","arrayToObject","htmlEncode","renderContent","emojiObejct","emoji","functionToCheck","toString","call","userInput","regexp","res","match","array","keyField","reduce","obj","item","str","replace","i","charCodeAt","content","onClick","newContent","indexOf","IMAGE_SPLIT","split","pop","join","REGEXP","a","b","src","slice","value","prefixUrl","ext"],"mappings":";;;;;QAKgBA,U,GAAAA,U;QAMAC,K,GAAAA,K;QAYAC,a,GAAAA,a;QAYAC,U,GAAAA,U;QAYAC,a,GAAAA,a;;AA/ChB;;AACA;;;;;;AAEA,IAAMC,cAAcH,cAAcI,eAAd,EAAqB,OAArB,CAApB;;AAEO,SAASN,UAAT,CAAoBO,eAApB,EAAqC;AAC1C,SACEA,mBAAmB,GAAGC,QAAH,CAAYC,IAAZ,CAAiBF,eAAjB,MAAsC,mBAD3D;AAGD;;AAEM,SAASN,KAAT,CAAeS,SAAf,EAA0B;AAC/B,MAAMC,SAAS,kGAAf;AACA,MAAIC,MAAMF,UAAUG,KAAV,CAAgBF,MAAhB,CAAV;AACA,MAAIC,QAAQ,IAAZ,EAAkB,OAAO,KAAP,CAAlB,KACK,OAAO,IAAP;AACN;;AAED;;;;;AAKO,SAASV,aAAT,CAAuBY,KAAvB,EAA8BC,QAA9B,EAAwC;AAC7C,SAAOD,MAAME,MAAN,CAAa,UAACC,GAAD,EAAMC,IAAN,EAAe;AACjCD,QAAIC,KAAKH,QAAL,CAAJ,IAAsBG,IAAtB;AACA,WAAOD,GAAP;AACD,GAHM,EAGJ,EAHI,CAAP;AAID;;AAED;;;;;AAKO,SAASd,UAAT,CAAoBgB,GAApB,EAAyB;AAC9B,MAAI,CAACA,GAAL,EAAU,OAAO,EAAP;AACV,SAAOA,IAAIC,OAAJ,CAAY,SAAZ,EAAuB,UAASC,CAAT,EAAY;AACxC,WAAO,OAAOA,EAAEC,UAAF,CAAa,CAAb,CAAP,GAAyB,GAAhC;AACD,GAFM,CAAP;AAGD;;AAED;;;;;AAKO,SAASlB,aAAT,CAAuBmB,OAAvB,EAAgCC,OAAhC,EAAyC;AAC9C,MAAIC,aAAaF,OAAjB;AACA,MAAIE,WAAWC,OAAX,CAAmBC,qBAAnB,MAAoC,CAAC,CAAzC,EAA4C;AAC1CF,iBAAaA,WAAWG,KAAX,CAAiBD,qBAAjB,CAAb;AACAF,eAAWI,GAAX;AACAJ,iBAAaA,WAAWK,IAAX,CAAgB,EAAhB,CAAb;AACD;;AAED,SAAO3B,WAAWsB,UAAX,EAAuBL,OAAvB,CAA+BW,gBAA/B,EAAuC,UAASC,CAAT,EAAYC,CAAZ,EAAe;AAC3D,QAAMC,MAAMF,EAAEG,KAAF,CAAQ,CAAR,EAAW,CAAC,CAAZ,CAAZ;;AAEA;AACA;AACA,QAAIlC,MAAMiC,GAAN,CAAJ,EAAgB;AACd,kCAAyBA,GAAzB,iBAAsCA,GAAtC;AACD;AACD,QAAME,QAAQ/B,YAAY6B,GAAZ,IAAmB7B,YAAY6B,GAAZ,EAAiBE,KAApC,GAA4CF,GAA1D;AACA,2BAAoBG,gBAApB,GAAgCD,KAAhC,SAAyCE,UAAzC,iBAAsDF,KAAtD;AACD,GAVM,CAAP;AAWD","file":"helper.js","sourcesContent":["import { REGEXP, IMAGE_SPLIT } from \"./constant\";\r\nimport emoji, { prefixUrl, ext } from \"./emoji\";\r\n\r\nconst emojiObejct = arrayToObject(emoji, \"title\");\r\n\r\nexport function isFunction(functionToCheck) {\r\n  return (\r\n    functionToCheck && {}.toString.call(functionToCheck) === \"[object Function]\"\r\n  );\r\n}\r\n\r\nexport function isUrl(userInput) {\r\n  const regexp = /(http(s)?:\\/\\/.)?(www\\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/g;\r\n  var res = userInput.match(regexp);\r\n  if (res === null) return false;\r\n  else return true;\r\n}\r\n\r\n/**\r\n * 将对象数组转换为对象\r\n * @param {array} array Array of Objects\r\n * @param {string} keyField string\r\n */\r\nexport function arrayToObject(array, keyField) {\r\n  return array.reduce((obj, item) => {\r\n    obj[item[keyField]] = item;\r\n    return obj;\r\n  }, {});\r\n}\r\n\r\n/**\r\n * HTML 编码\r\n * 将 < > 等字符串进行编码\r\n * @param {string} str 文本\r\n */\r\nexport function htmlEncode(str) {\r\n  if (!str) return \"\";\r\n  return str.replace(/[<>]/gim, function(i) {\r\n    return \"&#\" + i.charCodeAt(0) + \";\";\r\n  });\r\n}\r\n\r\n/**\r\n * 渲染编辑器\r\n * [x] => <img src=\"x\" />\r\n * @param {strig} content\r\n */\r\nexport function renderContent(content, onClick) {\r\n  let newContent = content;\r\n  if (newContent.indexOf(IMAGE_SPLIT) !== -1) {\r\n    newContent = newContent.split(IMAGE_SPLIT);\r\n    newContent.pop();\r\n    newContent = newContent.join(\"\");\r\n  }\r\n\r\n  return htmlEncode(newContent).replace(REGEXP, function(a, b) {\r\n    const src = a.slice(1, -1);\r\n\r\n    // 兼容旧的评\r\n    // 因为旧的评论用 [img url] 方式存储的\r\n    if (isUrl(src)) {\r\n      return `<br/><img src=\"${src}\" alt=\"${src}\" style=\"max-width: 100%\" />`;\r\n    }\r\n    const value = emojiObejct[src] ? emojiObejct[src].value : src;\r\n    return `<img src=\"${prefixUrl}${value}.${ext}\" alt=\"${value}\" />`;\r\n  });\r\n}\r\n"]}

+ 12
- 2
lib/index.js Visa fil

@@ -74,8 +74,18 @@ var Index = function (_Component) {
74 74
       // 最简单的用法
75 75
       return _react2.default.createElement(
76 76
         _App2.default,
77
-        { type: 1, businessId: "test" },
78
-        _react2.default.createElement(_App.Editor, { maxUpload: 4 })
77
+        {
78
+          type: 1,
79
+          businessId: "test",
80
+          showAlertComment: true,
81
+          showAlertReply: true,
82
+          showAlertFavor: true,
83
+          showError: false
84
+        },
85
+        _react2.default.createElement(_App.Editor, {
86
+          maxUpload: 4,
87
+          showError: false
88
+        })
79 89
       );
80 90
 
81 91
       // e.g.

+ 1
- 1
lib/index.js.map Visa fil

@@ -1 +1 @@
1
-{"version":3,"sources":["../src/index.js"],"names":["Index","props","state","value","handleChangeValue","bind","handleChangeSubmit","setState","console","log","text","files","loading","setTimeout","Component","ReactDOM","render","document","getElementById"],"mappings":";;;;AAAA;;;;AACA;;;;AAIA;;;;AACA;;;;;;;;;;;AAJA;AACA;AACA;;;IAIMA,K;;;AACJ,iBAAYC,KAAZ,EAAmB;AAAA;;AAAA,8GACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa;AACXC,aAAO;AADI,KAAb;AAGA,UAAKC,iBAAL,GAAyB,MAAKA,iBAAL,CAAuBC,IAAvB,OAAzB;AACA,UAAKC,kBAAL,GAA0B,MAAKA,kBAAL,CAAwBD,IAAxB,OAA1B;AANiB;AAOlB;;;;sCAEiBF,K,EAAO;AACvB,WAAKI,QAAL,CAAc,EAAEJ,YAAF,EAAd;AACAK,cAAQC,GAAR,CAAY,2BAAZ,EAAyCN,KAAzC;AACD;;;6CAEmC;AAAA;;AAAA,UAAfO,IAAe,QAAfA,IAAe;AAAA,UAATC,KAAS,QAATA,KAAS;;AAClC,WAAKJ,QAAL,CAAc,EAAEK,SAAS,IAAX,EAAd,EAAiC,YAAM;AACrCC,mBAAW,YAAM;AACf,iBAAKN,QAAL,CAAc,EAAEK,SAAS,KAAX,EAAd;AACD,SAFD,EAEG,IAFH;AAGD,OAJD;AAKAJ,cAAQC,GAAR,CAAY,eAAZ,EAA6BC,IAA7B;AACAF,cAAQC,GAAR,CAAY,gBAAZ,EAA8BE,KAA9B;AACD;;;6BAEQ;AACP;AACA,aACE;AAAC,qBAAD;AAAA,UAAK,MAAM,CAAX,EAAc,YAAW,MAAzB;AACE,sCAAC,WAAD,IAAQ,WAAW,CAAnB;AADF,OADF;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACD;;;;EAxEiBG,gB;;AA2EpBC,mBAASC,MAAT,CAAgB,8BAAC,KAAD,OAAhB,EAA2BC,SAASC,cAAT,CAAwB,cAAxB,CAA3B;AACA","file":"index.js","sourcesContent":["import React, { Component } from \"react\";\nimport ReactDOM from \"react-dom\";\n// e.g.\n// import { Button, Icon } from \"antd\";\n// import App, { Editor, RenderText } from \"./App\";\nimport App, { Editor } from \"./App\";\nimport registerServiceWorker from \"./registerServiceWorker\";\n\nclass Index extends Component {\n  constructor(props) {\n    super(props);\n    this.state = {\n      value: \"\"\n    };\n    this.handleChangeValue = this.handleChangeValue.bind(this);\n    this.handleChangeSubmit = this.handleChangeSubmit.bind(this);\n  }\n\n  handleChangeValue(value) {\n    this.setState({ value });\n    console.log(\"handleChangeValue value: \", value);\n  }\n\n  handleChangeSubmit({ text, files }) {\n    this.setState({ loading: true }, () => {\n      setTimeout(() => {\n        this.setState({ loading: false });\n      }, 2000);\n    });\n    console.log(\"submit text: \", text);\n    console.log(\"submit files: \", files);\n  }\n\n  render() {\n    // 最简单的用法\n    return (\n      <App type={1} businessId=\"test\">\n        <Editor maxUpload={4} />\n      </App>\n    );\n\n    // e.g.\n    // 复杂的用户法\n    // const props = {\n    //   type: 1,\n    //   businessId: \"1\",\n    //   API: \"http://api.links123.net/comment/v1\",\n    //   showList: true\n    // };\n\n    // const editorProps = {\n    //   showEmoji: true,\n    //   placeholder: \"说点什么吧\",\n    //   rows: 5,\n    //   btnLoading: this.state.loading,\n    //   btnDisable: this.state.loading,\n    //   btnSubmitText: \"提交\",\n    //   value: this.state.value,\n    //   onChange: v => this.handleChangeValue(v),\n    //   onSubmit: v => this.handleChangeSubmit(v),\n    //   button: (\n    //     <Button\n    //       type=\"primary\"\n    //       ghost\n    //       // onClick={() => console.log('click btn: ', this.state.value)}\n    //     >\n    //       自定义按钮\n    //     </Button>\n    //   ),\n    //   emojiToolIcon: <Icon type=\"smile\" style={{ fontSize: 23 }} />,\n    //   imageToolIcon: (\n    //     <Icon type=\"cloud-upload-o\" style={{ fontSize: 25, marginLeft: 10 }} />\n    //   )\n    // };\n\n    // return (\n    //   <App {...props}>\n    //     <Editor {...editorProps} />\n    //   </App>\n    // );\n  }\n}\n\nReactDOM.render(<Index />, document.getElementById(\"root-comment\"));\nregisterServiceWorker();\n"]}
1
+{"version":3,"sources":["../src/index.js"],"names":["Index","props","state","value","handleChangeValue","bind","handleChangeSubmit","setState","console","log","text","files","loading","setTimeout","Component","ReactDOM","render","document","getElementById"],"mappings":";;;;AAAA;;;;AACA;;;;AAIA;;;;AACA;;;;;;;;;;;AAJA;AACA;AACA;;;IAIMA,K;;;AACJ,iBAAYC,KAAZ,EAAmB;AAAA;;AAAA,8GACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa;AACXC,aAAO;AADI,KAAb;AAGA,UAAKC,iBAAL,GAAyB,MAAKA,iBAAL,CAAuBC,IAAvB,OAAzB;AACA,UAAKC,kBAAL,GAA0B,MAAKA,kBAAL,CAAwBD,IAAxB,OAA1B;AANiB;AAOlB;;;;sCAEiBF,K,EAAO;AACvB,WAAKI,QAAL,CAAc,EAAEJ,YAAF,EAAd;AACAK,cAAQC,GAAR,CAAY,2BAAZ,EAAyCN,KAAzC;AACD;;;6CAEmC;AAAA;;AAAA,UAAfO,IAAe,QAAfA,IAAe;AAAA,UAATC,KAAS,QAATA,KAAS;;AAClC,WAAKJ,QAAL,CAAc,EAAEK,SAAS,IAAX,EAAd,EAAiC,YAAM;AACrCC,mBAAW,YAAM;AACf,iBAAKN,QAAL,CAAc,EAAEK,SAAS,KAAX,EAAd;AACD,SAFD,EAEG,IAFH;AAGD,OAJD;AAKAJ,cAAQC,GAAR,CAAY,eAAZ,EAA6BC,IAA7B;AACAF,cAAQC,GAAR,CAAY,gBAAZ,EAA8BE,KAA9B;AACD;;;6BAEQ;AACP;AACA,aACE;AAAC,qBAAD;AAAA;AACE,gBAAM,CADR;AAEE,sBAAW,MAFb;AAGE,gCAHF;AAIE,8BAJF;AAKE,8BALF;AAME,qBAAW;AANb;AAQE,sCAAC,WAAD;AACE,qBAAW,CADb;AAEE,qBAAW;AAFb;AARF,OADF;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACD;;;;EAlFiBG,gB;;AAqFpBC,mBAASC,MAAT,CAAgB,8BAAC,KAAD,OAAhB,EAA2BC,SAASC,cAAT,CAAwB,cAAxB,CAA3B;AACA","file":"index.js","sourcesContent":["import React, { Component } from \"react\";\r\nimport ReactDOM from \"react-dom\";\r\n// e.g.\r\n// import { Button, Icon } from \"antd\";\r\n// import App, { Editor, RenderText } from \"./App\";\r\nimport App, { Editor } from \"./App\";\r\nimport registerServiceWorker from \"./registerServiceWorker\";\r\n\r\nclass Index extends Component {\r\n  constructor(props) {\r\n    super(props);\r\n    this.state = {\r\n      value: \"\"\r\n    };\r\n    this.handleChangeValue = this.handleChangeValue.bind(this);\r\n    this.handleChangeSubmit = this.handleChangeSubmit.bind(this);\r\n  }\r\n\r\n  handleChangeValue(value) {\r\n    this.setState({ value });\r\n    console.log(\"handleChangeValue value: \", value);\r\n  }\r\n\r\n  handleChangeSubmit({ text, files }) {\r\n    this.setState({ loading: true }, () => {\r\n      setTimeout(() => {\r\n        this.setState({ loading: false });\r\n      }, 2000);\r\n    });\r\n    console.log(\"submit text: \", text);\r\n    console.log(\"submit files: \", files);\r\n  }\r\n\r\n  render() {\r\n    // 最简单的用法\r\n    return (\r\n      <App\r\n        type={1}\r\n        businessId=\"test\"\r\n        showAlertComment\r\n        showAlertReply\r\n        showAlertFavor\r\n        showError={false}\r\n      >\r\n        <Editor\r\n          maxUpload={4}\r\n          showError={false}\r\n        />\r\n      </App>\r\n    );\r\n\r\n    // e.g.\r\n    // 复杂的用户法\r\n    // const props = {\r\n    //   type: 1,\r\n    //   businessId: \"1\",\r\n    //   API: \"http://api.links123.net/comment/v1\",\r\n    //   showList: true\r\n    // };\r\n\r\n    // const editorProps = {\r\n    //   showEmoji: true,\r\n    //   placeholder: \"说点什么吧\",\r\n    //   rows: 5,\r\n    //   btnLoading: this.state.loading,\r\n    //   btnDisable: this.state.loading,\r\n    //   btnSubmitText: \"提交\",\r\n    //   value: this.state.value,\r\n    //   onChange: v => this.handleChangeValue(v),\r\n    //   onSubmit: v => this.handleChangeSubmit(v),\r\n    //   button: (\r\n    //     <Button\r\n    //       type=\"primary\"\r\n    //       ghost\r\n    //       // onClick={() => console.log('click btn: ', this.state.value)}\r\n    //     >\r\n    //       自定义按钮\r\n    //     </Button>\r\n    //   ),\r\n    //   emojiToolIcon: <Icon type=\"smile\" style={{ fontSize: 23 }} />,\r\n    //   imageToolIcon: (\r\n    //     <Icon type=\"cloud-upload-o\" style={{ fontSize: 25, marginLeft: 10 }} />\r\n    //   )\r\n    // };\r\n\r\n    // return (\r\n    //   <App {...props}>\r\n    //     <Editor {...editorProps} />\r\n    //   </App>\r\n    // );\r\n  }\r\n}\r\n\r\nReactDOM.render(<Index />, document.getElementById(\"root-comment\"));\r\nregisterServiceWorker();\r\n"]}

+ 1
- 1
lib/lang/index.js.map Visa fil

@@ -1 +1 @@
1
-{"version":3,"sources":["../../src/lang/index.js"],"names":["data"],"mappings":";;;;;AAAA;AACA;AACA,IAAMA,OAAO;AACX,eAAa,MADF;AAEX,iBAAe,MAFJ;AAGX,2BAAyB,QAHd;AAIX,0BAAwB,QAJb;AAKX,iCAA+B,UALpB;AAMX,yBAAuB,UANZ;AAOX,yBAAuB,QAPZ;AAQX,wBAAsB,QARX;AASX,+BAA6B,UATlB;AAUX,wBAAsB;AAVX,CAAb;;kBAaeA,I","file":"index.js","sourcesContent":["// 语言包\n// 英文短语和中文提示的对应\nconst data = {\n  \"not found\": \"没有数据\",\n  \"auth failed\": \"请先登录\",\n  \"create comment failed\": \"创建评论失败\",\n  \"comment favor failed\": \"评论点赞失败\",\n  \"delete comment favor failed\": \"评论取消点赞失败\",\n  \"get comments failed\": \"获取评论列表失败\",\n  \"create reply failed\": \"创建回复失败\",\n  \"reply favor failed\": \"回复点赞失败\",\n  \"delete reply favor failed\": \"删除回复点赞失败\",\n  \"get replies failed\": \"获取回复列表失败\"\n};\n\nexport default data;\n"]}
1
+{"version":3,"sources":["../../src/lang/index.js"],"names":["data"],"mappings":";;;;;AAAA;AACA;AACA,IAAMA,OAAO;AACX,eAAa,MADF;AAEX,iBAAe,MAFJ;AAGX,2BAAyB,QAHd;AAIX,0BAAwB,QAJb;AAKX,iCAA+B,UALpB;AAMX,yBAAuB,UANZ;AAOX,yBAAuB,QAPZ;AAQX,wBAAsB,QARX;AASX,+BAA6B,UATlB;AAUX,wBAAsB;AAVX,CAAb;;kBAaeA,I","file":"index.js","sourcesContent":["// 语言包\r\n// 英文短语和中文提示的对应\r\nconst data = {\r\n  \"not found\": \"没有数据\",\r\n  \"auth failed\": \"请先登录\",\r\n  \"create comment failed\": \"创建评论失败\",\r\n  \"comment favor failed\": \"评论点赞失败\",\r\n  \"delete comment favor failed\": \"评论取消点赞失败\",\r\n  \"get comments failed\": \"获取评论列表失败\",\r\n  \"create reply failed\": \"创建回复失败\",\r\n  \"reply favor failed\": \"回复点赞失败\",\r\n  \"delete reply favor failed\": \"删除回复点赞失败\",\r\n  \"get replies failed\": \"获取回复列表失败\"\r\n};\r\n\r\nexport default data;\r\n"]}

+ 35
- 25
src/App.js Visa fil

@@ -1,6 +1,6 @@
1 1
 import React, { Component } from "react";
2 2
 import PropTypes from "prop-types";
3
-import { message } from "antd";
3
+import { message as antdMessage } from "antd";
4 4
 import axios from "axios";
5 5
 import { ERROR_DEFAULT, LIMIT } from "./constant";
6 6
 import { CommentContext } from "./Comment";
@@ -36,6 +36,14 @@ class App extends Component {
36 36
     this.sCommentFavor = this.sCommentFavor.bind(this);
37 37
     this.sReplyFavor = this.sReplyFavor.bind(this);
38 38
     this.sOssSts = this.sOssSts.bind(this);
39
+    this.message = {
40
+      ...antdMessage,
41
+      error: (...args) => {
42
+        if (this.props.showError) {
43
+          antdMessage.error(...args);
44
+        }
45
+      }
46
+    };
39 47
   }
40 48
 
41 49
   componentWillMount() {
@@ -87,7 +95,7 @@ class App extends Component {
87 95
             total
88 96
           });
89 97
         } else {
90
-          message.info("没有更多评论了");
98
+          this.message.info("没有更多评论了");
91 99
           this.setState({
92 100
             isNoMoreComment: true
93 101
           });
@@ -95,10 +103,10 @@ class App extends Component {
95 103
       })
96 104
       .catch(error => {
97 105
         if (error.response && error.response.data && error.response.data.msg) {
98
-          message.error(lang[error.response.data.msg] || ERROR_DEFAULT);
106
+          this.message.error(lang[error.response.data.msg] || ERROR_DEFAULT);
99 107
           return;
100 108
         }
101
-        message.error(lang[error.message] || ERROR_DEFAULT);
109
+        this.message.error(lang[error.message] || ERROR_DEFAULT);
102 110
       })
103 111
       .finally(() => {
104 112
         this.handleChangeLoading("sGetComment", false);
@@ -115,7 +123,7 @@ class App extends Component {
115 123
       .get(`${API}/replies?comment_id=${commentId}&page=${page}&limit=${LIMIT}`)
116 124
       .then(response => {
117 125
         if (!response.data.list) {
118
-          message.info("没有更多数据了!");
126
+          this.message.info("没有更多数据了!");
119 127
         }
120 128
         const list = this.state.list.map(item => {
121 129
           if (item.id === commentId) {
@@ -143,10 +151,10 @@ class App extends Component {
143 151
       })
144 152
       .catch(error => {
145 153
         if (error.response && error.response.data && error.response.data.msg) {
146
-          message.error(lang[error.response.data.msg] || ERROR_DEFAULT);
154
+          this.message.error(lang[error.response.data.msg] || ERROR_DEFAULT);
147 155
           return;
148 156
         }
149
-        message.error(lang[error.message] || ERROR_DEFAULT);
157
+        this.message.error(lang[error.message] || ERROR_DEFAULT);
150 158
       })
151 159
       .finally(() => {
152 160
         this.handleChangeLoading("sGetReply", false);
@@ -158,7 +166,7 @@ class App extends Component {
158 166
    * @param {object} {content} comment content
159 167
    */
160 168
   sCreateComment({ content } = {}, cb) {
161
-    if (!content) return message.error("评论内容不能为空 ");
169
+    if (!content) return this.message.error("评论内容不能为空 ");
162 170
     this.handleChangeLoading("sCreateComment", true);
163 171
     const { API, type, businessId } = this.props;
164 172
     this.axios(`${API}/comments`, {
@@ -172,7 +180,7 @@ class App extends Component {
172 180
     })
173 181
       .then(response => {
174 182
         if (this.props.showAlertComment) {
175
-          message.success("评论成功!");
183
+          this.message.success("评论成功!");
176 184
         }
177 185
         if (isFunction(cb)) cb();
178 186
         // 将数据写入到 list 中
@@ -187,10 +195,10 @@ class App extends Component {
187 195
       })
188 196
       .catch(error => {
189 197
         if (error.response && error.response.data && error.response.data.msg) {
190
-          message.error(lang[error.response.data.msg] || ERROR_DEFAULT);
198
+          this.message.error(lang[error.response.data.msg] || ERROR_DEFAULT);
191 199
           return;
192 200
         }
193
-        message.error(lang[error.message] || ERROR_DEFAULT);
201
+        this.message.error(lang[error.message] || ERROR_DEFAULT);
194 202
       })
195 203
       .finally(() => {
196 204
         this.handleChangeLoading("sCreateComment", false);
@@ -203,7 +211,7 @@ class App extends Component {
203 211
    * @param {object} data { comment_id, content, [reply_id] }
204 212
    */
205 213
   sCreateReply(data, cb) {
206
-    if (!data.content) return message.error("回复内容不能为空 ");
214
+    if (!data.content) return this.message.error("回复内容不能为空 ");
207 215
     this.handleChangeLoading("sCreateReply", true);
208 216
     const { API } = this.props;
209 217
     this.axios(`${API}/replies`, {
@@ -213,7 +221,7 @@ class App extends Component {
213 221
     })
214 222
       .then(response => {
215 223
         if (this.props.showAlertReply) {
216
-          message.success("回复成功!");
224
+          this.message.success("回复成功!");
217 225
         }
218 226
         if (isFunction(cb)) cb();
219 227
         // 将数据写入到 list 中
@@ -234,10 +242,10 @@ class App extends Component {
234 242
       })
235 243
       .catch(error => {
236 244
         if (error.response && error.response.data && error.response.data.msg) {
237
-          message.error(lang[error.response.data.msg] || ERROR_DEFAULT);
245
+          this.message.error(lang[error.response.data.msg] || ERROR_DEFAULT);
238 246
           return;
239 247
         }
240
-        message.error(lang[error.message] || ERROR_DEFAULT);
248
+        this.message.error(lang[error.message] || ERROR_DEFAULT);
241 249
       })
242 250
       .finally(() => {
243 251
         this.handleChangeLoading("sCreateReply", false);
@@ -258,7 +266,7 @@ class App extends Component {
258 266
     })
259 267
       .then(response => {
260 268
         if (this.props.showAlertFavor) {
261
-          message.success(favored ? "取消点赞成功!" : "点赞成功!");
269
+          this.message.success(favored ? "取消点赞成功!" : "点赞成功!");
262 270
         }
263 271
         // 更新 list 中的该项数据的 favored
264 272
         const list = this.state.list.map(item => {
@@ -272,10 +280,10 @@ class App extends Component {
272 280
       })
273 281
       .catch(error => {
274 282
         if (error.response && error.response.data && error.response.data.msg) {
275
-          message.error(lang[error.response.data.msg] || ERROR_DEFAULT);
283
+          this.message.error(lang[error.response.data.msg] || ERROR_DEFAULT);
276 284
           return;
277 285
         }
278
-        message.error(lang[error.message] || ERROR_DEFAULT);
286
+        this.message.error(lang[error.message] || ERROR_DEFAULT);
279 287
       })
280 288
       .finally(() => {
281 289
         this.handleChangeLoading("sCommentFavor", false);
@@ -299,7 +307,7 @@ class App extends Component {
299 307
       withCredentials: true
300 308
     })
301 309
       .then(response => {
302
-        message.success(favored ? "取消点赞成功!" : "点赞成功!");
310
+        this.message.success(favored ? "取消点赞成功!" : "点赞成功!");
303 311
         // 更新 list 中的该项数据的 favored
304 312
         const list = this.state.list.map(item => {
305 313
           if (item.id === commentId) {
@@ -320,10 +328,10 @@ class App extends Component {
320 328
       })
321 329
       .catch(error => {
322 330
         if (error.response && error.response.data && error.response.data.msg) {
323
-          message.error(lang[error.response.data.msg] || ERROR_DEFAULT);
331
+          this.message.error(lang[error.response.data.msg] || ERROR_DEFAULT);
324 332
           return;
325 333
         }
326
-        message.error(lang[error.message] || ERROR_DEFAULT);
334
+        this.message.error(lang[error.message] || ERROR_DEFAULT);
327 335
       })
328 336
       .finally(() => {
329 337
         this.handleChangeLoading("sReplyFavor", false);
@@ -343,10 +351,10 @@ class App extends Component {
343 351
       })
344 352
       .catch(error => {
345 353
         if (error.response && error.response.data && error.response.data.msg) {
346
-          message.error(lang[error.response.data.msg] || ERROR_DEFAULT);
354
+          this.message.error(lang[error.response.data.msg] || ERROR_DEFAULT);
347 355
           return;
348 356
         }
349
-        message.error(lang[error.message] || ERROR_DEFAULT);
357
+        this.message.error(lang[error.message] || ERROR_DEFAULT);
350 358
       })
351 359
       .finally(() => {
352 360
         this.handleChangeLoading("sOssSts", false);
@@ -392,7 +400,8 @@ App.propTypes = {
392 400
   showEditor: PropTypes.bool, // 是否显示评论输入框
393 401
   showAlertComment: PropTypes.bool, // 评论成功之后,是否通过 Antd 的 Message 组件进行提示
394 402
   showAlertReply: PropTypes.bool, // 回复成功之后,是否通过 Antd 的 Message 组件进行提示
395
-  showAlertFavor: PropTypes.bool // 点赞/取消点赞成功之后,是否通过 Antd 的 Message 组件进行提示
403
+  showAlertFavor: PropTypes.bool, // 点赞/取消点赞成功之后,是否通过 Antd 的 Message 组件进行提示
404
+  showError: PropTypes.bool // 是否使用Antd的Message组件提示错误信息
396 405
 };
397 406
 
398 407
 App.defaultProps = {
@@ -401,7 +410,8 @@ App.defaultProps = {
401 410
   showEditor: true,
402 411
   showAlertComment: false,
403 412
   showAlertReply: false,
404
-  showAlertFavor: false
413
+  showAlertFavor: false,
414
+  showError: true
405 415
 };
406 416
 
407 417
 export { Editor, RenderText };

+ 3
- 1
src/components/Editor/Upload.js Visa fil

@@ -88,7 +88,9 @@ class App extends React.Component {
88 88
           this.props.onUpload({ path: data.name, uid: file.uid });
89 89
         })
90 90
         .catch(e => {
91
-          message.error(e.message || ERROR_DEFAULT);
91
+          if (this.props.showError) {
92
+            message.error(e.message || ERROR_DEFAULT);
93
+          }
92 94
           info.onError(e);
93 95
         });
94 96
     };

+ 5
- 2
src/components/Editor/index.js Visa fil

@@ -239,6 +239,7 @@ class Editor extends React.Component {
239 239
                         onUpload={this.handleUpload}
240 240
                         maxUpload={maxUpload}
241 241
                         fileList={this.state.fileList}
242
+                        showError={this.props.showError}
242 243
                       />
243 244
                     </div>
244 245
                   }
@@ -319,7 +320,8 @@ Editor.propTypes = {
319 320
   btnDisabled: PropTypes.bool,
320 321
   button: PropTypes.node,
321 322
   emojiToolIcon: PropTypes.node,
322
-  imageToolIcon: PropTypes.node
323
+  imageToolIcon: PropTypes.node,
324
+  showError: PropTypes.bool
323 325
 };
324 326
 
325 327
 Editor.defaultProps = {
@@ -331,7 +333,8 @@ Editor.defaultProps = {
331 333
   maxUpload: 1,
332 334
   btnSubmitText: "发表",
333 335
   btnLoading: false,
334
-  btnDisabled: false
336
+  btnDisabled: false,
337
+  showError: true
335 338
 };
336 339
 
337 340
 export default Editor;

+ 9
- 2
src/index.js Visa fil

@@ -34,8 +34,15 @@ class Index extends Component {
34 34
   render() {
35 35
     // 最简单的用法
36 36
     return (
37
-      <App type={1} businessId="test">
38
-        <Editor maxUpload={4} />
37
+      <App
38
+        type={1}
39
+        businessId="test"
40
+        showAlertComment
41
+        showAlertReply
42
+        showAlertFavor
43
+        showError={false}
44
+      >
45
+        <Editor maxUpload={4} showError={false} />
39 46
       </App>
40 47
     );
41 48