浏览代码

Merge branch 'master' of node/npmcomment into master

narrowizard 6 年前
父节点
当前提交
ca54428423
共有 53 个文件被更改,包括 679 次插入325 次删除
  1. 5
    0
      CHANGELOG.md
  2. 5
    1
      README.md
  3. 2
    0
      assets/static/js/main.f8cafc1c.js
  4. 1
    0
      assets/static/js/main.f8cafc1c.js.map
  5. 109
    57
      lib/App.js
  6. 1
    1
      lib/App.js.map
  7. 0
    12
      lib/CHANGELOG.md
  8. 1
    1
      lib/Comment.js.map
  9. 1
    1
      lib/avatar.js.map
  10. 1
    1
      lib/axios.js.map
  11. 7
    2
      lib/components/CommentBox/index.js
  12. 1
    1
      lib/components/CommentBox/index.js.map
  13. 1
    1
      lib/components/CommentInput/index.js.map
  14. 6
    4
      lib/components/CommentList/index.js
  15. 1
    1
      lib/components/CommentList/index.js.map
  16. 23
    10
      lib/components/ContentItem/index.js
  17. 1
    1
      lib/components/ContentItem/index.js.map
  18. 1
    1
      lib/components/Editor/Emoji.js.map
  19. 5
    1
      lib/components/Editor/Upload.js
  20. 1
    1
      lib/components/Editor/Upload.js.map
  21. 15
    11
      lib/components/Editor/index.js
  22. 1
    1
      lib/components/Editor/index.js.map
  23. 7
    2
      lib/components/ImagePreviewer/ImagePreviewer.js
  24. 1
    1
      lib/components/ImagePreviewer/ImagePreviewer.js.map
  25. 1
    1
      lib/components/RenderText/index.js.map
  26. 1
    1
      lib/constant.js.map
  27. 1
    1
      lib/helper.js.map
  28. 1
    1
      lib/index.example.js.map
  29. 6
    0
      lib/index.js
  30. 1
    1
      lib/index.js.map
  31. 43
    0
      lib/lang/en-US.js
  32. 1
    0
      lib/lang/en-US.js.map
  33. 37
    15
      lib/lang/index.js
  34. 1
    1
      lib/lang/index.js.map
  35. 43
    0
      lib/lang/zh-CN.js
  36. 1
    0
      lib/lang/zh-CN.js.map
  37. 0
    72
      lib/mock.js
  38. 0
    1
      lib/mock.js.map
  39. 1
    1
      lib/registerServiceWorker.js.map
  40. 2
    1
      package.json
  41. 21
    0
      public/locales/en-US.json
  42. 21
    0
      public/locales/zh-CN.json
  43. 78
    27
      src/App.js
  44. 10
    10
      src/components/CommentBox/index.js
  45. 4
    2
      src/components/CommentList/index.js
  46. 67
    53
      src/components/ContentItem/index.js
  47. 2
    1
      src/components/Editor/Upload.js
  48. 15
    7
      src/components/Editor/index.js
  49. 3
    2
      src/components/ImagePreviewer/ImagePreviewer.jsx
  50. 6
    0
      src/index.js
  51. 38
    0
      src/lang/en-US.js
  52. 40
    15
      src/lang/index.js
  53. 37
    0
      src/lang/zh-CN.js

+ 5
- 0
CHANGELOG.md 查看文件

@@ -1,10 +1,15 @@
1 1
 # CHANGELOG
2 2
 
3
+## 1.0.0
4
+
5
+- [x] 完成通用评论国际化
6
+
3 7
 ## 0.6.0
4 8
 
5 9
 - [x] 添加pageType slice,用于截断评论,点击查看更多回调进行跳转
6 10
 
7 11
 ## 0.5.14
12
+
8 13
 - [x] 增加onDelete回调
9 14
 
10 15
 ## 0.5.13

+ 5
- 1
README.md 查看文件

@@ -177,8 +177,11 @@ main();
177 177
 解决办法就是使用 [`fix/classname`](https://git.links123.net/node/npmcomment/src/branch/fix/classname) 分支中的静态文件:
178 178
 
179 179
 - [https://git.links123.net/node/npmcomment/src/branch/fix/classname](https://git.links123.net/node/npmcomment/src/branch/fix/classname)
180
+- static: [https://git.links123.net/node/npmcomment/src/branch/fix/classname/assets/static](https://git.links123.net/node/npmcomment/src/branch/fix/classname/assets/static)
181
+
182
+
183
+> 尝试过使用 CSS Module 进行修改,不过改造量较大,改动的过程中影响了其他样式,所以暂时放弃了。
180 184
 
181
-尝试过使用 CSS Module 进行修改,不过改造量较大,改动的过程中影响了其他样式,所以暂时放弃了。
182 185
 
183 186
 ## Comment
184 187
 
@@ -205,6 +208,7 @@ main();
205 208
 | onGetMoreBtnClick      | function() |                                    | false    | 点击查看更多按钮的回调                            |
206 209
 | onPageChange     | function(page) |                                    | false    | 页码发生变化时的回调,注意:分页数据获取还是在组件内部处理的                            |
207 210
 | onDelete         | function(type) |                                    | false    | 评论或回复删除成功后的回调, type: "comment" \| "reply" , 用于区分删除的是评论还是回复 |
211
+| locales          | string         | 语言                                | false    | 语言,zh-CN/en-US。默认根据 url 中的 lang 参数来获取。所以一般情况可不传入       
208 212
 
209 213
 
210 214
 ## Editor

+ 2
- 0
assets/static/js/main.f8cafc1c.js
文件差异内容过多而无法显示
查看文件


+ 1
- 0
assets/static/js/main.f8cafc1c.js.map
文件差异内容过多而无法显示
查看文件


+ 109
- 57
lib/App.js 查看文件

@@ -27,6 +27,10 @@ var _axios = require("axios");
27 27
 
28 28
 var _axios2 = _interopRequireDefault(_axios);
29 29
 
30
+var _reactIntlUniversal = require("react-intl-universal");
31
+
32
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
33
+
30 34
 var _constant = require("./constant");
31 35
 
32 36
 var _Comment = require("./Comment");
@@ -51,19 +55,30 @@ var _RenderText2 = _interopRequireDefault(_RenderText);
51 55
 
52 56
 var _lang = require("./lang");
53 57
 
54
-var _lang2 = _interopRequireDefault(_lang);
58
+var _enUS = require("./lang/en-US.js");
59
+
60
+var _enUS2 = _interopRequireDefault(_enUS);
61
+
62
+var _zhCN = require("./lang/zh-CN.js");
63
+
64
+var _zhCN2 = _interopRequireDefault(_zhCN);
55 65
 
56 66
 require("./App.css");
57 67
 
58 68
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
59 69
 
70
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
71
+
60 72
 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
61 73
 
62 74
 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
63 75
 
64 76
 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
65 77
 
66
-// import styles from "./App.module.css";
78
+var LOCALES = {
79
+  "zh-CN": _zhCN2.default,
80
+  "en-US": _enUS2.default
81
+};
67 82
 
68 83
 var App = function (_Component) {
69 84
   _inherits(App, _Component);
@@ -84,7 +99,9 @@ var App = function (_Component) {
84 99
       page: 1,
85 100
       total: 0,
86 101
       // 是否没有更多评论了
87
-      isNoMoreComment: false
102
+      isNoMoreComment: false,
103
+      initDone: false,
104
+      locale: "zh-CN"
88 105
     };
89 106
     _this.handleChangeLoading = _this.handleChangeLoading.bind(_this);
90 107
     _this.sCreateComment = _this.sCreateComment.bind(_this);
@@ -111,7 +128,38 @@ var App = function (_Component) {
111 128
     }
112 129
   }, {
113 130
     key: "componentDidMount",
114
-    value: function componentDidMount() {}
131
+    value: function componentDidMount() {
132
+      this.loadLocales();
133
+    }
134
+
135
+    /**
136
+     * 加载语言包
137
+     * 只能根据url或者传入的props来确定加载哪个语言包
138
+     * 优先级:传入的props > url
139
+     */
140
+
141
+  }, {
142
+    key: "loadLocales",
143
+    value: function loadLocales() {
144
+      var _this2 = this;
145
+
146
+      var currentLocale = this.props.locales;
147
+
148
+      if (!currentLocale) {
149
+        currentLocale = _reactIntlUniversal2.default.determineLocale({
150
+          urlLocaleKey: "lang"
151
+        });
152
+      }
153
+      currentLocale = _lang.SUPPORT_LOCALES.find(function (item) {
154
+        return item.value === currentLocale;
155
+      }) ? currentLocale : "zh-CN";
156
+      _reactIntlUniversal2.default.init({
157
+        currentLocale: currentLocale,
158
+        locales: _defineProperty({}, currentLocale, LOCALES[currentLocale])
159
+      }).then(function () {
160
+        _this2.setState({ initDone: true, locale: currentLocale });
161
+      });
162
+    }
115 163
   }, {
116 164
     key: "error",
117 165
     value: function error(msg) {
@@ -127,13 +175,16 @@ var App = function (_Component) {
127 175
   }, {
128 176
     key: "errorHandler",
129 177
     value: function errorHandler(error) {
178
+      var locale = this.state.locale;
179
+
180
+      var localResponse = _lang.LOCALES_RESPONSE[locale];
130 181
       if (error.response && error.response.data && error.response.data.msg) {
131
-        this.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT, {
182
+        this.error(localResponse[error.response.data.msg] || _constant.ERROR_DEFAULT, {
132 183
           response: error.response
133 184
         });
134 185
         return;
135 186
       }
136
-      this.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT, {
187
+      this.error(localResponse[error.response.data.msg] || _constant.ERROR_DEFAULT, {
137 188
         response: error.response
138 189
       });
139 190
     }
@@ -160,7 +211,7 @@ var App = function (_Component) {
160 211
   }, {
161 212
     key: "sGetComment",
162 213
     value: function sGetComment() {
163
-      var _this2 = this;
214
+      var _this3 = this;
164 215
 
165 216
       var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
166 217
           _ref$page = _ref.page,
@@ -183,7 +234,7 @@ var App = function (_Component) {
183 234
 
184 235
         if (list) {
185 236
           var newList = list;
186
-          var oldList = _this2.state.list;
237
+          var oldList = _this3.state.list;
187 238
 
188 239
           if (pageType === "more") {
189 240
             if (page > 1) {
@@ -198,19 +249,19 @@ var App = function (_Component) {
198 249
             window.scrollTo(0, 0);
199 250
           }
200 251
 
201
-          _this2.setState({
252
+          _this3.setState({
202 253
             list: newList,
203 254
             page: page,
204 255
             total: total
205 256
           });
206 257
         } else {
207
-          _message3.default.info("没有更多评论了");
208
-          _this2.setState({
258
+          _message3.default.info(_reactIntlUniversal2.default.get("message.noMoreComment"));
259
+          _this3.setState({
209 260
             isNoMoreComment: true
210 261
           });
211 262
         }
212 263
       }).catch(this.errorHandler).finally(function () {
213
-        _this2.handleChangeLoading("sGetComment", false);
264
+        _this3.handleChangeLoading("sGetComment", false);
214 265
       });
215 266
     }
216 267
 
@@ -221,7 +272,7 @@ var App = function (_Component) {
221 272
   }, {
222 273
     key: "sGetReply",
223 274
     value: function sGetReply() {
224
-      var _this3 = this;
275
+      var _this4 = this;
225 276
 
226 277
       var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
227 278
           commentId = _ref2.commentId,
@@ -235,9 +286,9 @@ var App = function (_Component) {
235 286
 
236 287
       this.axios.get(API + "/replies?comment_id=" + commentId + "&page=" + page + "&limit=" + limit).then(function (response) {
237 288
         if (!response.data.list) {
238
-          _message3.default.info("没有更多数据了!");
289
+          _message3.default.info(_reactIntlUniversal2.default.get("message.noMoreData"));
239 290
         }
240
-        var list = _this3.state.list.map(function (item) {
291
+        var list = _this4.state.list.map(function (item) {
241 292
           if (item.id === commentId) {
242 293
             if (!item.replies) item.replies = [];
243 294
             if (response.data.list) {
@@ -259,9 +310,9 @@ var App = function (_Component) {
259 310
           }
260 311
           return item;
261 312
         });
262
-        _this3.setState({ list: list });
313
+        _this4.setState({ list: list });
263 314
       }).catch(this.errorHandler).finally(function () {
264
-        _this3.handleChangeLoading("sGetReply", false);
315
+        _this4.handleChangeLoading("sGetReply", false);
265 316
       });
266 317
     }
267 318
 
@@ -273,14 +324,14 @@ var App = function (_Component) {
273 324
   }, {
274 325
     key: "sCreateComment",
275 326
     value: function sCreateComment() {
276
-      var _this4 = this;
327
+      var _this5 = this;
277 328
 
278 329
       var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
279 330
           content = _ref3.content;
280 331
 
281 332
       var cb = arguments[1];
282 333
 
283
-      if (!content) return this.error("评论内容不能为空 ");
334
+      if (!content) return this.error(_reactIntlUniversal2.default.get("message.notNull"));
284 335
       this.handleChangeLoading("sCreateComment", true);
285 336
       var _props3 = this.props,
286 337
           API = _props3.API,
@@ -296,23 +347,23 @@ var App = function (_Component) {
296 347
         },
297 348
         withCredentials: true
298 349
       }).then(function (response) {
299
-        if (_this4.props.showAlertComment) {
300
-          _message3.default.success("评论成功!");
350
+        if (_this5.props.showAlertComment) {
351
+          _message3.default.success(_reactIntlUniversal2.default.get("message.success"));
301 352
         }
302 353
         if ((0, _helper.isFunction)(cb)) cb();
303 354
         // 将数据写入到 list 中
304 355
         // 临时插入
305 356
         // 等到获取数据之后,删除临时数据
306
-        var _state = _this4.state,
357
+        var _state = _this5.state,
307 358
             list = _state.list,
308 359
             total = _state.total;
309 360
 
310 361
         list.unshift(_extends({}, response.data, {
311 362
           isTemporary: true // 临时的数据
312 363
         }));
313
-        _this4.setState({ list: list, total: total + 1 });
364
+        _this5.setState({ list: list, total: total + 1 });
314 365
       }).catch(this.errorHandler).finally(function () {
315
-        _this4.handleChangeLoading("sCreateComment", false);
366
+        _this5.handleChangeLoading("sCreateComment", false);
316 367
       });
317 368
     }
318 369
 
@@ -323,7 +374,7 @@ var App = function (_Component) {
323 374
   }, {
324 375
     key: "sDeleteComment",
325 376
     value: function sDeleteComment(commentId) {
326
-      var _this5 = this;
377
+      var _this6 = this;
327 378
 
328 379
       this.handleChangeLoading("sDeleteComment", true);
329 380
       var API = this.props.API;
@@ -332,17 +383,17 @@ var App = function (_Component) {
332 383
         method: "delete",
333 384
         withCredentials: true
334 385
       }).then(function () {
335
-        var _state2 = _this5.state,
386
+        var _state2 = _this6.state,
336 387
             list = _state2.list,
337 388
             total = _state2.total;
338 389
 
339 390
         var res = list.filter(function (item) {
340 391
           return item.id !== commentId;
341 392
         });
342
-        _this5.setState({ list: res, total: total - 1 });
343
-        _this5.props.onDelete(_constant.COMMENT_TYPE.COMMENT);
393
+        _this6.setState({ list: res, total: total - 1 });
394
+        _this6.props.onDelete(_constant.COMMENT_TYPE.COMMENT);
344 395
       }).catch(this.errorHandler).finally(function () {
345
-        _this5.handleChangeLoading("sDeleteComment", false);
396
+        _this6.handleChangeLoading("sDeleteComment", false);
346 397
       });
347 398
     }
348 399
 
@@ -355,9 +406,9 @@ var App = function (_Component) {
355 406
   }, {
356 407
     key: "sCreateReply",
357 408
     value: function sCreateReply(data, cb) {
358
-      var _this6 = this;
409
+      var _this7 = this;
359 410
 
360
-      if (!data.content) return this.error("回复内容不能为空 ");
411
+      if (!data.content) return this.error(_reactIntlUniversal2.default.get("message.replyNoNull"));
361 412
       this.handleChangeLoading("sCreateReply", true);
362 413
       var API = this.props.API;
363 414
 
@@ -366,14 +417,14 @@ var App = function (_Component) {
366 417
         data: data,
367 418
         withCredentials: true
368 419
       }).then(function (response) {
369
-        if (_this6.props.showAlertReply) {
370
-          _message3.default.success("回复成功!");
420
+        if (_this7.props.showAlertReply) {
421
+          _message3.default.success(_reactIntlUniversal2.default.get("message.replySuccess"));
371 422
         }
372 423
         if ((0, _helper.isFunction)(cb)) cb();
373 424
         // 将数据写入到 list 中
374 425
         // 临时插入
375 426
         // 等到获取数据之后,删除临时数据
376
-        var list = _this6.state.list.map(function (item) {
427
+        var list = _this7.state.list.map(function (item) {
377 428
           if (item.id === data.comment_id) {
378 429
             if (!item.replies) item.replies = [];
379 430
             item.replies.push(_extends({}, response.data, {
@@ -383,9 +434,9 @@ var App = function (_Component) {
383 434
           }
384 435
           return item;
385 436
         });
386
-        _this6.setState({ list: list });
437
+        _this7.setState({ list: list });
387 438
       }).catch(this.errorHandler).finally(function () {
388
-        _this6.handleChangeLoading("sCreateReply", false);
439
+        _this7.handleChangeLoading("sCreateReply", false);
389 440
       });
390 441
     }
391 442
 
@@ -398,7 +449,7 @@ var App = function (_Component) {
398 449
   }, {
399 450
     key: "sDeleteReply",
400 451
     value: function sDeleteReply(replyId, commentId) {
401
-      var _this7 = this;
452
+      var _this8 = this;
402 453
 
403 454
       this.handleChangeLoading("sDeleteReply", true);
404 455
       var API = this.props.API;
@@ -407,7 +458,7 @@ var App = function (_Component) {
407 458
         method: "delete",
408 459
         withCredentials: true
409 460
       }).then(function () {
410
-        var list = _this7.state.list.map(function (item) {
461
+        var list = _this8.state.list.map(function (item) {
411 462
           if (item.id === commentId) {
412 463
             var replies = item.replies.filter(function (item) {
413 464
               return item.id !== replyId;
@@ -417,10 +468,10 @@ var App = function (_Component) {
417 468
           }
418 469
           return item;
419 470
         });
420
-        _this7.setState({ list: list });
421
-        _this7.props.onDelete(_constant.COMMENT_TYPE.REPLY);
471
+        _this8.setState({ list: list });
472
+        _this8.props.onDelete(_constant.COMMENT_TYPE.REPLY);
422 473
       }).catch(this.errorHandler).finally(function () {
423
-        _this7.handleChangeLoading("sDeleteReply", false);
474
+        _this8.handleChangeLoading("sDeleteReply", false);
424 475
       });
425 476
     }
426 477
 
@@ -433,7 +484,7 @@ var App = function (_Component) {
433 484
   }, {
434 485
     key: "sCommentFavor",
435 486
     value: function sCommentFavor(commentId, favored) {
436
-      var _this8 = this;
487
+      var _this9 = this;
437 488
 
438 489
       this.handleChangeLoading("sCommentFavor", true);
439 490
       var API = this.props.API;
@@ -442,20 +493,20 @@ var App = function (_Component) {
442 493
         method: favored ? "delete" : "put",
443 494
         withCredentials: true
444 495
       }).then(function (response) {
445
-        if (_this8.props.showAlertFavor) {
446
-          _message3.default.success(favored ? "取消点赞成功!" : "点赞成功!");
496
+        if (_this9.props.showAlertFavor) {
497
+          _message3.default.success(favored ? _reactIntlUniversal2.default.get("message.cancelLickSuccess") : _reactIntlUniversal2.default.get("message.likeSuccess"));
447 498
         }
448 499
         // 更新 list 中的该项数据的 favored
449
-        var list = _this8.state.list.map(function (item) {
500
+        var list = _this9.state.list.map(function (item) {
450 501
           if (item.id === commentId) {
451 502
             item.favored = !favored;
452 503
             item.favor_count += favored ? -1 : 1;
453 504
           }
454 505
           return item;
455 506
         });
456
-        _this8.setState({ list: list });
507
+        _this9.setState({ list: list });
457 508
       }).catch(this.errorHandler).finally(function () {
458
-        _this8.handleChangeLoading("sCommentFavor", false);
509
+        _this9.handleChangeLoading("sCommentFavor", false);
459 510
       });
460 511
     }
461 512
 
@@ -469,7 +520,7 @@ var App = function (_Component) {
469 520
   }, {
470 521
     key: "sReplyFavor",
471 522
     value: function sReplyFavor(replyId, commentId, favored) {
472
-      var _this9 = this;
523
+      var _this10 = this;
473 524
 
474 525
       this.handleChangeLoading("sReplyFavor", true);
475 526
       var API = this.props.API;
@@ -481,9 +532,9 @@ var App = function (_Component) {
481 532
         },
482 533
         withCredentials: true
483 534
       }).then(function (response) {
484
-        _message3.default.success(favored ? "取消点赞成功!" : "点赞成功!");
535
+        _message3.default.success(favored ? _reactIntlUniversal2.default.get("message.cancelLickSuccess") : _reactIntlUniversal2.default.get("message.likeSuccess"));
485 536
         // 更新 list 中的该项数据的 favored
486
-        var list = _this9.state.list.map(function (item) {
537
+        var list = _this10.state.list.map(function (item) {
487 538
           if (item.id === commentId) {
488 539
             item.replies = item.replies.map(function (r) {
489 540
               if (r.id === replyId) {
@@ -498,9 +549,9 @@ var App = function (_Component) {
498 549
           }
499 550
           return item;
500 551
         });
501
-        _this9.setState({ list: list });
552
+        _this10.setState({ list: list });
502 553
       }).catch(this.errorHandler).finally(function () {
503
-        _this9.handleChangeLoading("sReplyFavor", false);
554
+        _this10.handleChangeLoading("sReplyFavor", false);
504 555
       });
505 556
     }
506 557
 
@@ -511,15 +562,15 @@ var App = function (_Component) {
511 562
   }, {
512 563
     key: "sOssSts",
513 564
     value: function sOssSts() {
514
-      var _this10 = this;
565
+      var _this11 = this;
515 566
 
516 567
       this.handleChangeLoading("sOssSts", true);
517 568
       var API = this.props.API;
518 569
 
519 570
       this.axios.get(API + "/oss/sts").then(function (response) {
520
-        _this10.setState({ oss: _extends({}, response.data) });
571
+        _this11.setState({ oss: _extends({}, response.data) });
521 572
       }).catch(this.errorHandler).finally(function () {
522
-        _this10.handleChangeLoading("sOssSts", false);
573
+        _this11.handleChangeLoading("sOssSts", false);
523 574
       });
524 575
     }
525 576
   }, {
@@ -538,7 +589,7 @@ var App = function (_Component) {
538 589
         sDeleteReply: this.sDeleteReply
539 590
       });
540 591
 
541
-      return _react2.default.createElement(
592
+      return this.state.initDone && _react2.default.createElement(
542 593
         _Comment.CommentContext.Provider,
543 594
         { value: value },
544 595
         _react2.default.createElement(
@@ -575,7 +626,8 @@ App.propTypes = {
575 626
   limit: _propTypes2.default.number, // 一次加载评论数量
576 627
   onPageChange: _propTypes2.default.func, // 页码变化回调
577 628
   onGetMoreBtnClick: _propTypes2.default.func, // 点击查看更多按钮回调
578
-  onDelete: _propTypes2.default.func
629
+  onDelete: _propTypes2.default.func,
630
+  locales: _propTypes2.default.string //  传入的语言环境, en-US/zh-CN
579 631
 };
580 632
 
581 633
 App.defaultProps = {

+ 1
- 1
lib/App.js.map
文件差异内容过多而无法显示
查看文件


+ 0
- 12
lib/CHANGELOG.md 查看文件

@@ -1,12 +0,0 @@
1
-# CHANGELOG
2
-
3
-
4
-## 0.1.0
5
-
6
-- [x] 不兼容更新。
7
-- [x] 添加了很多 `Props`
8
-- [x] 组件导出为 `Comment` 和 `Editor`
9
-
10
-
11
-
12
-

+ 1
- 1
lib/Comment.js.map 查看文件

@@ -1 +1 @@
1
-{"version":3,"sources":["../src/Comment.js"],"names":["Comment","CommentContext","React","createContext","Component","props","app"],"mappings":";;;;;;;;;QAKgBA,O,GAAAA,O;;AALhB;;;;;;AAEA,IAAMC,iBAAiBC,gBAAMC,aAAN,EAAvB;;AAEA;AACO,SAASH,OAAT,CAAiBI,SAAjB,EAA4B;AACjC;AACA,SAAO,UAASC,KAAT,EAAgB;AACrB;AACA;AACA,WACE;AAAC,oBAAD,CAAgB,QAAhB;AAAA;AACG;AAAA,eAAO,8BAAC,SAAD,eAAeA,KAAf,IAAsB,KAAKC,GAA3B,IAAP;AAAA;AADH,KADF;AAKD,GARD;AASD;;QAEQL,c,GAAAA,c;kBAEMD,O","file":"Comment.js","sourcesContent":["import React from \"react\";\n\nconst CommentContext = React.createContext();\n\n// This function takes a component...\nexport function Comment(Component) {\n  // ...and returns another component...\n  return function(props) {\n    // ... and renders the wrapped component with the context theme!\n    // Notice that we pass through any additional props as well\n    return (\n      <CommentContext.Consumer>\n        {app => <Component {...props} app={app} />}\n      </CommentContext.Consumer>\n    );\n  };\n}\n\nexport { CommentContext };\n\nexport default Comment;\n"]}
1
+{"version":3,"sources":["../src/Comment.js"],"names":["Comment","CommentContext","React","createContext","Component","props","app"],"mappings":";;;;;;;;;QAKgBA,O,GAAAA,O;;AALhB;;;;;;AAEA,IAAMC,iBAAiBC,gBAAMC,aAAN,EAAvB;;AAEA;AACO,SAASH,OAAT,CAAiBI,SAAjB,EAA4B;AACjC;AACA,SAAO,UAASC,KAAT,EAAgB;AACrB;AACA;AACA,WACE;AAAC,oBAAD,CAAgB,QAAhB;AAAA;AACG;AAAA,eAAO,8BAAC,SAAD,eAAeA,KAAf,IAAsB,KAAKC,GAA3B,IAAP;AAAA;AADH,KADF;AAKD,GARD;AASD;;QAEQL,c,GAAAA,c;kBAEMD,O","file":"Comment.js","sourcesContent":["import React from \"react\";\r\n\r\nconst CommentContext = React.createContext();\r\n\r\n// This function takes a component...\r\nexport function Comment(Component) {\r\n  // ...and returns another component...\r\n  return function(props) {\r\n    // ... and renders the wrapped component with the context theme!\r\n    // Notice that we pass through any additional props as well\r\n    return (\r\n      <CommentContext.Consumer>\r\n        {app => <Component {...props} app={app} />}\r\n      </CommentContext.Consumer>\r\n    );\r\n  };\r\n}\r\n\r\nexport { CommentContext };\r\n\r\nexport default Comment;\r\n"]}

+ 1
- 1
lib/avatar.js.map
文件差异内容过多而无法显示
查看文件


+ 1
- 1
lib/axios.js.map 查看文件

@@ -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"]}

+ 7
- 2
lib/components/CommentBox/index.js 查看文件

@@ -20,6 +20,10 @@ var _propTypes = require("prop-types");
20 20
 
21 21
 var _propTypes2 = _interopRequireDefault(_propTypes);
22 22
 
23
+var _reactIntlUniversal = require("react-intl-universal");
24
+
25
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
26
+
23 27
 var _Comment = require("../../Comment");
24 28
 
25 29
 var _Comment2 = _interopRequireDefault(_Comment);
@@ -122,7 +126,7 @@ var CommentBox = function (_Component) {
122 126
                       return _this2.handleGetMoreReply(commentId);
123 127
                     }
124 128
                   },
125
-                  "\u67E5\u770B\u66F4\u591A\u56DE\u590D"
129
+                  _reactIntlUniversal2.default.get("reply.moreReply")
126 130
                 ),
127 131
                 _react2.default.createElement(
128 132
                   "a",
@@ -131,7 +135,8 @@ var CommentBox = function (_Component) {
131 135
                     onClick: _this2.handleToggleReply
132 136
                   },
133 137
                   _react2.default.createElement(_icon2.default, { type: "up" }),
134
-                  " \u6536\u8D77\u56DE\u590D"
138
+                  " ",
139
+                  _reactIntlUniversal2.default.get("reply.collapse")
135 140
                 )
136 141
               )];
137 142
             }

+ 1
- 1
lib/components/CommentBox/index.js.map
文件差异内容过多而无法显示
查看文件


+ 1
- 1
lib/components/CommentInput/index.js.map
文件差异内容过多而无法显示
查看文件


+ 6
- 4
lib/components/CommentList/index.js 查看文件

@@ -22,6 +22,10 @@ var _react = require("react");
22 22
 
23 23
 var _react2 = _interopRequireDefault(_react);
24 24
 
25
+var _reactIntlUniversal = require("react-intl-universal");
26
+
27
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
28
+
25 29
 var _Comment = require("../../Comment");
26 30
 
27 31
 var _Comment2 = _interopRequireDefault(_Comment);
@@ -96,7 +100,7 @@ var CommentList = function (_Component) {
96 100
             _react2.default.createElement(
97 101
               "span",
98 102
               null,
99
-              "\u67E5\u770B\u66F4\u591A\u8BC4\u8BBA"
103
+              _reactIntlUniversal2.default.get("comment.moreComment")
100 104
             )
101 105
           );
102 106
         } else {
@@ -137,9 +141,7 @@ var CommentList = function (_Component) {
137 141
           _react2.default.createElement(
138 142
             "div",
139 143
             null,
140
-            "\u5171 ",
141
-            total,
142
-            " \u6761\u8BC4\u8BBA"
144
+            _reactIntlUniversal2.default.get("comment.totalComment", { total: total })
143 145
           ),
144 146
           list.map(function (item) {
145 147
             return _react2.default.createElement(_CommentBox2.default, { content: item, key: item.id, commentId: item.id });

+ 1
- 1
lib/components/CommentList/index.js.map 查看文件

@@ -1 +1 @@
1
-{"version":3,"sources":["../../../src/components/CommentList/index.js"],"names":["CommentList","props","state","app","sGetComment","page","list","total","pageType","limit","isNoMoreComment","onPageChange","onGetMoreBtnClick","length","p","loading","spinning","Boolean","sCommentFavor","sReplyFavor","map","item","id","renderPagination","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,CAA2B,EAAEC,MAAM,KAAKJ,KAAL,CAAWE,GAAX,CAAeE,IAAvB,EAA3B;AACD;;;uCAEkB;AAAA,uBAWb,KAAKJ,KAAL,CAAWE,GAXE;AAAA,UAEfG,IAFe,cAEfA,IAFe;AAAA,UAGfC,KAHe,cAGfA,KAHe;AAAA,UAIfF,IAJe,cAIfA,IAJe;AAAA,UAKfG,QALe,cAKfA,QALe;AAAA,UAMfC,KANe,cAMfA,KANe;AAAA,UAOfC,eAPe,cAOfA,eAPe;AAAA,UAQfN,WARe,cAQfA,WARe;AAAA,UASfO,YATe,cASfA,YATe;AAAA,UAUfC,iBAVe,cAUfA,iBAVe;;AAYjB,UAAIJ,aAAa,OAAjB,EAA0B;AACxB;AACA,eACE;AAAA;AAAA,YAAK,WAAU,wBAAf,EAAwC,SAASI,iBAAjD;AACE;AAAA;AAAA;AAAA;AAAA;AADF,SADF;AAKD,OAPD,MAOO,IAAIJ,aAAa,MAAjB,EAAyB;AAC9B,YAAI,CAACE,eAAD,IAAoBJ,KAAKO,MAAL,KAAgBN,KAAxC,EAA+C;AAC7C,iBACE;AAAA;AAAA;AACE,yBAAU,wBADZ;AAEE,uBAAS,mBAAM;AACbH,4BAAY,EAAEC,MAAMA,OAAO,CAAf,EAAZ;AACAM,6BAAaN,OAAO,CAApB;AACD;AALH;AAOE;AAAA;AAAA;AAAA;AAAA;AAPF,WADF;AAWD,SAZD,MAYO;AACL,iBAAO,IAAP;AACD;AACF,OAhBM,MAgBA,IAAIG,aAAa,YAAjB,EAA+B;AACpC,eACE;AAAA;AAAA,YAAK,WAAU,yBAAf;AACE;AACE,sBAAUC,KADZ;AAEE,qBAASJ,IAFX;AAGE,mBAAOE,KAHT;AAIE,sBAAU,qBAAK;AACbH,0BAAY,EAAEC,MAAMS,CAAR,EAAZ;AACAH,2BAAaG,CAAb;AACD;AAPH;AADF,SADF;AAaD;AACF;;;6BAEQ;AAAA,wBAC0B,KAAKb,KAAL,CAAWE,GADrC;AAAA,UACCG,IADD,eACCA,IADD;AAAA,UACOC,KADP,eACOA,KADP;AAAA,UACcQ,OADd,eACcA,OADd;;;AAGP,UAAMC,WAAWC,QACfF,QAAQX,WAAR,IAAuBW,QAAQG,aAA/B,IAAgDH,QAAQI,WADzC,CAAjB;AAGA,aACE;AAAA;AAAA;AACE;AAAA;AAAA,YAAM,UAAUH,QAAhB;AACE;AAAA;AAAA;AAAA;AAAQT,iBAAR;AAAA;AAAA,WADF;AAEGD,eAAKc,GAAL,CAAS;AAAA,mBACR,8BAAC,oBAAD,IAAY,SAASC,IAArB,EAA2B,KAAKA,KAAKC,EAArC,EAAyC,WAAWD,KAAKC,EAAzD,GADQ;AAAA,WAAT,CAFH;AAKG,eAAKC,gBAAL;AALH;AADF,OADF;AAWD;;;;EA/EuBC,gB;;AAkF1BxB,YAAYyB,SAAZ,GAAwB,EAAxB;;kBAEe,uBAAQzB,WAAR,C","file":"index.js","sourcesContent":["import React, { Component } from \"react\";\nimport { Spin, Pagination } 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({ page: this.props.app.page });\n  }\n\n  renderPagination() {\n    const {\n      list,\n      total,\n      page,\n      pageType,\n      limit,\n      isNoMoreComment,\n      sGetComment,\n      onPageChange,\n      onGetMoreBtnClick\n    } = this.props.app;\n    if (pageType === \"slice\") {\n      // 截断多余评论,通过点击查看更多跳转\n      return (\n        <div className=\"comment-list-show-more\" onClick={onGetMoreBtnClick}>\n          <span>查看更多</span>\n        </div>\n      );\n    } else if (pageType === \"more\") {\n      if (!isNoMoreComment && list.length !== total) {\n        return (\n          <div\n            className=\"comment-list-show-more\"\n            onClick={() => {\n              sGetComment({ page: page + 1 });\n              onPageChange(page + 1);\n            }}\n          >\n            <span>查看更多评论</span>\n          </div>\n        );\n      } else {\n        return null;\n      }\n    } else if (pageType === \"pagination\") {\n      return (\n        <div className=\"comment-list-pagination\">\n          <Pagination\n            pageSize={limit}\n            current={page}\n            total={total}\n            onChange={p => {\n              sGetComment({ page: p });\n              onPageChange(p);\n            }}\n          />\n        </div>\n      );\n    }\n  }\n\n  render() {\n    const { list, total, loading } = 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          {this.renderPagination()}\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","page","list","total","pageType","limit","isNoMoreComment","onPageChange","onGetMoreBtnClick","length","intl","get","p","loading","spinning","Boolean","sCommentFavor","sReplyFavor","map","item","id","renderPagination","Component","propTypes"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;AAEA;;;;AACA;;;;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,CAA2B,EAAEC,MAAM,KAAKJ,KAAL,CAAWE,GAAX,CAAeE,IAAvB,EAA3B;AACD;;;uCAEkB;AAAA,uBAWb,KAAKJ,KAAL,CAAWE,GAXE;AAAA,UAEfG,IAFe,cAEfA,IAFe;AAAA,UAGfC,KAHe,cAGfA,KAHe;AAAA,UAIfF,IAJe,cAIfA,IAJe;AAAA,UAKfG,QALe,cAKfA,QALe;AAAA,UAMfC,KANe,cAMfA,KANe;AAAA,UAOfC,eAPe,cAOfA,eAPe;AAAA,UAQfN,WARe,cAQfA,WARe;AAAA,UASfO,YATe,cASfA,YATe;AAAA,UAUfC,iBAVe,cAUfA,iBAVe;;AAYjB,UAAIJ,aAAa,OAAjB,EAA0B;AACxB;AACA,eACE;AAAA;AAAA,YAAK,WAAU,wBAAf,EAAwC,SAASI,iBAAjD;AACE;AAAA;AAAA;AAAA;AAAA;AADF,SADF;AAKD,OAPD,MAOO,IAAIJ,aAAa,MAAjB,EAAyB;AAC9B,YAAI,CAACE,eAAD,IAAoBJ,KAAKO,MAAL,KAAgBN,KAAxC,EAA+C;AAC7C,iBACE;AAAA;AAAA;AACE,yBAAU,wBADZ;AAEE,uBAAS,mBAAM;AACbH,4BAAY,EAAEC,MAAMA,OAAO,CAAf,EAAZ;AACAM,6BAAaN,OAAO,CAApB;AACD;AALH;AAOE;AAAA;AAAA;AAAOS,2CAAKC,GAAL,CAAS,qBAAT;AAAP;AAPF,WADF;AAWD,SAZD,MAYO;AACL,iBAAO,IAAP;AACD;AACF,OAhBM,MAgBA,IAAIP,aAAa,YAAjB,EAA+B;AACpC,eACE;AAAA;AAAA,YAAK,WAAU,yBAAf;AACE;AACE,sBAAUC,KADZ;AAEE,qBAASJ,IAFX;AAGE,mBAAOE,KAHT;AAIE,sBAAU,qBAAK;AACbH,0BAAY,EAAEC,MAAMW,CAAR,EAAZ;AACAL,2BAAaK,CAAb;AACD;AAPH;AADF,SADF;AAaD;AACF;;;6BAEQ;AAAA,wBAC0B,KAAKf,KAAL,CAAWE,GADrC;AAAA,UACCG,IADD,eACCA,IADD;AAAA,UACOC,KADP,eACOA,KADP;AAAA,UACcU,OADd,eACcA,OADd;;;AAGP,UAAMC,WAAWC,QACfF,QAAQb,WAAR,IAAuBa,QAAQG,aAA/B,IAAgDH,QAAQI,WADzC,CAAjB;AAGA,aACE;AAAA;AAAA;AACE;AAAA;AAAA,YAAM,UAAUH,QAAhB;AAEE;AAAA;AAAA;AAAMJ,yCAAKC,GAAL,CAAS,sBAAT,EAAiC,EAAER,YAAF,EAAjC;AAAN,WAFF;AAGGD,eAAKgB,GAAL,CAAS;AAAA,mBACR,8BAAC,oBAAD,IAAY,SAASC,IAArB,EAA2B,KAAKA,KAAKC,EAArC,EAAyC,WAAWD,KAAKC,EAAzD,GADQ;AAAA,WAAT,CAHH;AAMG,eAAKC,gBAAL;AANH;AADF,OADF;AAYD;;;;EAhFuBC,gB;;AAmF1B1B,YAAY2B,SAAZ,GAAwB,EAAxB;;kBAEe,uBAAQ3B,WAAR,C","file":"index.js","sourcesContent":["import React, { Component } from \"react\";\r\nimport { Spin, Pagination } from \"antd\";\r\nimport intl from \"react-intl-universal\";\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({ page: this.props.app.page });\r\n  }\r\n\r\n  renderPagination() {\r\n    const {\r\n      list,\r\n      total,\r\n      page,\r\n      pageType,\r\n      limit,\r\n      isNoMoreComment,\r\n      sGetComment,\r\n      onPageChange,\r\n      onGetMoreBtnClick\r\n    } = this.props.app;\r\n    if (pageType === \"slice\") {\r\n      // 截断多余评论,通过点击查看更多跳转\r\n      return (\r\n        <div className=\"comment-list-show-more\" onClick={onGetMoreBtnClick}>\r\n          <span>查看更多</span>\r\n        </div>\r\n      );\r\n    } else if (pageType === \"more\") {\r\n      if (!isNoMoreComment && list.length !== total) {\r\n        return (\r\n          <div\r\n            className=\"comment-list-show-more\"\r\n            onClick={() => {\r\n              sGetComment({ page: page + 1 });\r\n              onPageChange(page + 1);\r\n            }}\r\n          >\r\n            <span>{intl.get(\"comment.moreComment\")}</span>\r\n          </div>\r\n        );\r\n      } else {\r\n        return null;\r\n      }\r\n    } else if (pageType === \"pagination\") {\r\n      return (\r\n        <div className=\"comment-list-pagination\">\r\n          <Pagination\r\n            pageSize={limit}\r\n            current={page}\r\n            total={total}\r\n            onChange={p => {\r\n              sGetComment({ page: p });\r\n              onPageChange(p);\r\n            }}\r\n          />\r\n        </div>\r\n      );\r\n    }\r\n  }\r\n\r\n  render() {\r\n    const { list, total, loading } = 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          <div>{intl.get(\"comment.totalComment\", { total })}</div>\r\n          {list.map(item => (\r\n            <CommentBox content={item} key={item.id} commentId={item.id} />\r\n          ))}\r\n          {this.renderPagination()}\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"]}

+ 23
- 10
lib/components/ContentItem/index.js 查看文件

@@ -48,6 +48,10 @@ var _relativeTime = require("dayjs/plugin/relativeTime");
48 48
 
49 49
 var _relativeTime2 = _interopRequireDefault(_relativeTime);
50 50
 
51
+var _reactIntlUniversal = require("react-intl-universal");
52
+
53
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
54
+
51 55
 var _Comment = require("../../Comment");
52 56
 
53 57
 var _Comment2 = _interopRequireDefault(_Comment);
@@ -79,10 +83,16 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
79 83
 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
80 84
 
81 85
 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
86
+// import 'dayjs/locale/es';
87
+
82 88
 
83
-_dayjs2.default.locale("zh-cn");
89
+// dayjs.locale("zh-cn");
84 90
 _dayjs2.default.extend(_relativeTime2.default);
85 91
 
92
+var LOCALES = {
93
+  "zh-CN": "zh-cn"
94
+};
95
+
86 96
 var CommentItem = function (_Component) {
87 97
   _inherits(CommentItem, _Component);
88 98
 
@@ -159,6 +169,7 @@ var CommentItem = function (_Component) {
159 169
           showReply = _props.showReply,
160 170
           onShowReply = _props.onShowReply,
161 171
           app = _props.app;
172
+      var locale = this.props.app.locale;
162 173
       var showInput = this.state.showInput;
163 174
 
164 175
 
@@ -201,7 +212,7 @@ var CommentItem = function (_Component) {
201 212
             _react2.default.createElement(
202 213
               "strong",
203 214
               null,
204
-              content.user_name || "游客"
215
+              content.user_name || _reactIntlUniversal2.default.get("comment.tourist")
205 216
             ),
206 217
             _react2.default.createElement(
207 218
               "span",
@@ -212,7 +223,7 @@ var CommentItem = function (_Component) {
212 223
                   placement: "top",
213 224
                   title: (0, _dayjs2.default)(content.created * 1000).format("YYYY-MM-DD HH:mm:ss")
214 225
                 },
215
-                (0, _dayjs2.default)(content.created * 1000).fromNow()
226
+                LOCALES[locale] ? (0, _dayjs2.default)(content.created * 1000).locale(LOCALES[locale]).fromNow() : (0, _dayjs2.default)(content.created * 1000).fromNow()
216 227
               )
217 228
             )
218 229
           ),
@@ -274,15 +285,15 @@ var CommentItem = function (_Component) {
274 285
               _react2.default.createElement(
275 286
                 "a",
276 287
                 { className: "comment-item-bottom-left", onClick: onShowReply },
277
-                content.reply_count,
278
-                " \u6761\u56DE\u590D",
288
+                _reactIntlUniversal2.default.get("reply.totalReply", { total: content.reply_count }),
279 289
                 showReply ? _react2.default.createElement(_icon2.default, { type: "up" }) : _react2.default.createElement(_icon2.default, { type: "down" })
280 290
               )
281 291
             ) : null,
282 292
             app.userId === content.user_id && _react2.default.createElement(
283 293
               _popconfirm2.default,
284 294
               {
285
-                title: "\u786E\u5B9A\u8981\u5220\u9664\u5417?",
295
+                // title="确定要删除吗?"
296
+                title: _reactIntlUniversal2.default.get("popConfirm.title"),
286 297
                 onConfirm: function onConfirm() {
287 298
                   if (replyId) {
288 299
                     app.sDeleteReply(content.id, commentId);
@@ -290,13 +301,14 @@ var CommentItem = function (_Component) {
290 301
                   }
291 302
                   app.sDeleteComment(content.id);
292 303
                 },
293
-                okText: "\u786E\u5B9A",
294
-                cancelText: "\u53D6\u6D88"
304
+                okText: _reactIntlUniversal2.default.get("popConfirm.ok"),
305
+                cancelText: _reactIntlUniversal2.default.get("popConfirm.cancel")
295 306
               },
296 307
               _react2.default.createElement(
297 308
                 "a",
298 309
                 { className: "comment-item-bottom-right" },
299
-                "\xA0 \u5220\u9664"
310
+                "\xA0 ",
311
+                _reactIntlUniversal2.default.get("popConfirm.delete")
300 312
               )
301 313
             ),
302 314
             _react2.default.createElement(
@@ -305,7 +317,8 @@ var CommentItem = function (_Component) {
305 317
                 onClick: this.handleToggleInput,
306 318
                 className: "comment-item-bottom-right"
307 319
               },
308
-              "\xA0 \u56DE\u590D"
320
+              "\xA0 ",
321
+              _reactIntlUniversal2.default.get("comment.reply")
309 322
             ),
310 323
             _react2.default.createElement(
311 324
               "div",

+ 1
- 1
lib/components/ContentItem/index.js.map
文件差异内容过多而无法显示
查看文件


+ 1
- 1
lib/components/Editor/Emoji.js.map 查看文件

@@ -1 +1 @@
1
-{"version":3,"sources":["../../../src/components/Editor/Emoji.js"],"names":["Emoji","carousel","next","prev","onClick","props","content","curPage","i","length","push","emoji","node","map","page","index","item","value","prefixUrl","ext","title","display","React","Component"],"mappings":";;;;;;;;;;;;;;AAAA;;;;AAEA;;;;AACA;;;;;;;;;;AACA;AACA;;AAEA;;IAEMA,K;;;;;;;;;;;2BACG;AACL,UAAI,KAAKC,QAAT,EAAmB;AACjB,aAAKA,QAAL,CAAcC,IAAd;AACD;AACF;;;2BAEM;AACL,UAAI,KAAKD,QAAT,EAAmB;AACjB,aAAKA,QAAL,CAAcE,IAAd;AACD;AACF;;;6BAEQ;AAAA;;AAAA,UACCC,QADD,GACa,KAAKC,KADlB,CACCD,OADD;;AAEP,UAAME,UAAU,EAAhB;AACA,UAAIC,UAAU,EAAd;AACA,WAAK,IAAIC,IAAI,CAAb,EAAgBA,IAAI,GAApB,EAAyBA,GAAzB,EAA8B;AAC5B,YAAID,QAAQE,MAAR,GAAiB,EAArB,EAAyB;AACvBF,kBAAQG,IAAR,CAAaC,gBAAMH,CAAN,CAAb;AACD,SAFD,MAEO;AACLF,kBAAQI,IAAR,CAAaH,OAAb;AACAA,oBAAU,EAAV;AACD;AACF;AACD,UAAIA,QAAQE,MAAR,GAAiB,CAArB,EAAwB;AACtBH,gBAAQI,IAAR,CAAaH,OAAb;AACD;AACD,aACE;AAAA;AAAA;AACE,eAAK,mBAAQ;AACX,mBAAKN,QAAL,GAAgBW,IAAhB;AACD;AAHH;AAKGN,gBAAQO,GAAR,CAAY,UAACC,IAAD,EAAOC,KAAP;AAAA,iBACX;AAAA;AAAA,cAAK,KAAKA,KAAV,EAAiB,WAAU,OAA3B;AACGD,iBAAKD,GAAL,CAAS,UAACG,IAAD,EAAOD,KAAP;AAAA,qBACR;AAAA;AAAA,kBAAK,WAAU,MAAf,EAAsB,KAAKC,KAAKC,KAAhC;AACE,wDAAM,WAAU,QAAhB,GADF;AAEE;AACE,4BAAQC,gBAAR,GAAoBF,KAAKC,KAAzB,SAAkCD,KAAKG,GADzC;AAEE,uBAAKH,KAAKI,KAFZ;AAGE,yBAAO,EAAEC,SAAS,cAAX,EAHT;AAIE,2BAAS;AAAA,2BAAMjB,SAAQY,KAAKI,KAAb,CAAN;AAAA;AAJX;AAFF,eADQ;AAAA,aAAT;AADH,WADW;AAAA,SAAZ;AALH,OADF;AAuBD;;;;EAnDiBE,gBAAMC,S;;kBAsDXvB,K","file":"Emoji.js","sourcesContent":["import React from \"react\";\nimport { Carousel } from \"antd\";\nimport emoji, { prefixUrl } from \"../../emoji\";\nimport \"./Emoji.css\";\n// 每页 20  5*4\n// 共 20 * 3 = 60 (实际是 54)\n\n// class Emoji\n\nclass Emoji extends React.Component {\n  next() {\n    if (this.carousel) {\n      this.carousel.next();\n    }\n  }\n\n  prev() {\n    if (this.carousel) {\n      this.carousel.prev();\n    }\n  }\n\n  render() {\n    const { onClick } = this.props;\n    const content = [];\n    let curPage = [];\n    for (let i = 0; i < 115; i++) {\n      if (curPage.length < 30) {\n        curPage.push(emoji[i]);\n      } else {\n        content.push(curPage);\n        curPage = [];\n      }\n    }\n    if (curPage.length > 0) {\n      content.push(curPage);\n    }\n    return (\n      <Carousel\n        ref={node => {\n          this.carousel = node;\n        }}\n      >\n        {content.map((page, index) => (\n          <div key={index} className=\"emoji\">\n            {page.map((item, index) => (\n              <div className=\"item\" key={item.value}>\n                <span className=\"helper\" />\n                <img\n                  src={`${prefixUrl}${item.value}.${item.ext}`}\n                  alt={item.title}\n                  style={{ display: \"inline-block\" }}\n                  onClick={() => onClick(item.title)}\n                />\n              </div>\n            ))}\n          </div>\n        ))}\n      </Carousel>\n    );\n  }\n}\n\nexport default Emoji;\n"]}
1
+{"version":3,"sources":["../../../src/components/Editor/Emoji.js"],"names":["Emoji","carousel","next","prev","onClick","props","content","curPage","i","length","push","emoji","node","map","page","index","item","value","prefixUrl","ext","title","display","React","Component"],"mappings":";;;;;;;;;;;;;;AAAA;;;;AAEA;;;;AACA;;;;;;;;;;AACA;AACA;;AAEA;;IAEMA,K;;;;;;;;;;;2BACG;AACL,UAAI,KAAKC,QAAT,EAAmB;AACjB,aAAKA,QAAL,CAAcC,IAAd;AACD;AACF;;;2BAEM;AACL,UAAI,KAAKD,QAAT,EAAmB;AACjB,aAAKA,QAAL,CAAcE,IAAd;AACD;AACF;;;6BAEQ;AAAA;;AAAA,UACCC,QADD,GACa,KAAKC,KADlB,CACCD,OADD;;AAEP,UAAME,UAAU,EAAhB;AACA,UAAIC,UAAU,EAAd;AACA,WAAK,IAAIC,IAAI,CAAb,EAAgBA,IAAI,GAApB,EAAyBA,GAAzB,EAA8B;AAC5B,YAAID,QAAQE,MAAR,GAAiB,EAArB,EAAyB;AACvBF,kBAAQG,IAAR,CAAaC,gBAAMH,CAAN,CAAb;AACD,SAFD,MAEO;AACLF,kBAAQI,IAAR,CAAaH,OAAb;AACAA,oBAAU,EAAV;AACD;AACF;AACD,UAAIA,QAAQE,MAAR,GAAiB,CAArB,EAAwB;AACtBH,gBAAQI,IAAR,CAAaH,OAAb;AACD;AACD,aACE;AAAA;AAAA;AACE,eAAK,mBAAQ;AACX,mBAAKN,QAAL,GAAgBW,IAAhB;AACD;AAHH;AAKGN,gBAAQO,GAAR,CAAY,UAACC,IAAD,EAAOC,KAAP;AAAA,iBACX;AAAA;AAAA,cAAK,KAAKA,KAAV,EAAiB,WAAU,OAA3B;AACGD,iBAAKD,GAAL,CAAS,UAACG,IAAD,EAAOD,KAAP;AAAA,qBACR;AAAA;AAAA,kBAAK,WAAU,MAAf,EAAsB,KAAKC,KAAKC,KAAhC;AACE,wDAAM,WAAU,QAAhB,GADF;AAEE;AACE,4BAAQC,gBAAR,GAAoBF,KAAKC,KAAzB,SAAkCD,KAAKG,GADzC;AAEE,uBAAKH,KAAKI,KAFZ;AAGE,yBAAO,EAAEC,SAAS,cAAX,EAHT;AAIE,2BAAS;AAAA,2BAAMjB,SAAQY,KAAKI,KAAb,CAAN;AAAA;AAJX;AAFF,eADQ;AAAA,aAAT;AADH,WADW;AAAA,SAAZ;AALH,OADF;AAuBD;;;;EAnDiBE,gBAAMC,S;;kBAsDXvB,K","file":"Emoji.js","sourcesContent":["import React from \"react\";\r\nimport { Carousel } from \"antd\";\r\nimport emoji, { prefixUrl } 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\nclass Emoji extends React.Component {\r\n  next() {\r\n    if (this.carousel) {\r\n      this.carousel.next();\r\n    }\r\n  }\r\n\r\n  prev() {\r\n    if (this.carousel) {\r\n      this.carousel.prev();\r\n    }\r\n  }\r\n\r\n  render() {\r\n    const { onClick } = this.props;\r\n    const content = [];\r\n    let curPage = [];\r\n    for (let i = 0; i < 115; i++) {\r\n      if (curPage.length < 30) {\r\n        curPage.push(emoji[i]);\r\n      } else {\r\n        content.push(curPage);\r\n        curPage = [];\r\n      }\r\n    }\r\n    if (curPage.length > 0) {\r\n      content.push(curPage);\r\n    }\r\n    return (\r\n      <Carousel\r\n        ref={node => {\r\n          this.carousel = node;\r\n        }}\r\n      >\r\n        {content.map((page, index) => (\r\n          <div key={index} className=\"emoji\">\r\n            {page.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}.${item.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        ))}\r\n      </Carousel>\r\n    );\r\n  }\r\n}\r\n\r\nexport default Emoji;\r\n"]}

+ 5
- 1
lib/components/Editor/Upload.js 查看文件

@@ -42,6 +42,10 @@ var _shortid = require("shortid");
42 42
 
43 43
 var _shortid2 = _interopRequireDefault(_shortid);
44 44
 
45
+var _reactIntlUniversal = require("react-intl-universal");
46
+
47
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
48
+
45 49
 var _constant = require("../../constant");
46 50
 
47 51
 var _Comment = require("../../Comment");
@@ -173,7 +177,7 @@ var App = function (_React$Component) {
173 177
         _react2.default.createElement(
174 178
           "div",
175 179
           { className: "ant-upload-text" },
176
-          "\u4E0A\u4F20"
180
+          _reactIntlUniversal2.default.get("editor.uploadBtn")
177 181
         )
178 182
       );
179 183
       return _react2.default.createElement(

+ 1
- 1
lib/components/Editor/Upload.js.map
文件差异内容过多而无法显示
查看文件


+ 15
- 11
lib/components/Editor/index.js 查看文件

@@ -48,6 +48,10 @@ var _classnames = require("classnames");
48 48
 
49 49
 var _classnames2 = _interopRequireDefault(_classnames);
50 50
 
51
+var _reactIntlUniversal = require("react-intl-universal");
52
+
53
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
54
+
51 55
 var _constant = require("../../constant");
52 56
 
53 57
 var _helper = require("../../helper");
@@ -218,7 +222,8 @@ var Editor = function (_React$Component) {
218 222
           fileList = _state.fileList;
219 223
 
220 224
       if (value.length > maxLength) {
221
-        _message3.default.error("\u5B57\u6570\u4E0D\u5F97\u8D85\u8FC7" + maxLength + "\u5B57");
225
+        // message.error(`字数不得超过${maxLength}字`);
226
+        _message3.default.error(_reactIntlUniversal2.default.get("editor.maxLength", { maxLength: maxLength }));
222 227
         return;
223 228
       }
224 229
       var files = [];
@@ -267,13 +272,11 @@ var Editor = function (_React$Component) {
267 272
 
268 273
       var _props = this.props,
269 274
           value = _props.value,
270
-          placeholder = _props.placeholder,
271 275
           rows = _props.rows,
272 276
           showEmoji = _props.showEmoji,
273 277
           showUpload = _props.showUpload,
274 278
           closeUploadWhenBlur = _props.closeUploadWhenBlur,
275 279
           maxUpload = _props.maxUpload,
276
-          btnSubmitText = _props.btnSubmitText,
277 280
           btnLoading = _props.btnLoading,
278 281
           btnDisabled = _props.btnDisabled,
279 282
           button = _props.button,
@@ -282,6 +285,8 @@ var Editor = function (_React$Component) {
282 285
           maxLength = _props.maxLength,
283 286
           autoFocus = _props.autoFocus;
284 287
 
288
+      var placeholder = this.props.placeholder || _reactIntlUniversal2.default.get("editor.placeholder");
289
+      var btnSubmitText = this.props.placeholder || _reactIntlUniversal2.default.get("editor.SubmitBtn");
285 290
       var handleSubmit = this.handleSubmit;
286 291
       var disabledSubmit = btnDisabled || !this.props.value && !this.state.value && !this.state.fileList.length;
287 292
       var inputValue = value || this.state.value;
@@ -296,11 +301,10 @@ var Editor = function (_React$Component) {
296 301
               "comment-editor-toolbar-error": inputValue.length > maxLength
297 302
             })
298 303
           },
299
-          "\u5DF2\u8F93\u5165 ",
300
-          inputValue.length,
301
-          " / ",
302
-          maxLength,
303
-          " \u5B57"
304
+          _reactIntlUniversal2.default.get("editor.alreadyEntered", {
305
+            count: inputValue.length,
306
+            maxLength: maxLength
307
+          })
304 308
         ),
305 309
         _react2.default.createElement(
306 310
           "div",
@@ -379,7 +383,7 @@ var Editor = function (_React$Component) {
379 383
                     _react2.default.createElement(
380 384
                       "span",
381 385
                       null,
382
-                      "\u4E0A\u4F20\u56FE\u7247",
386
+                      _reactIntlUniversal2.default.get("editor.uploadTip"),
383 387
                       maxUpload >= 2 ? _react2.default.createElement(
384 388
                         "span",
385 389
                         { style: { color: "#666", fontWeight: 400 } },
@@ -455,12 +459,12 @@ Editor.propTypes = {
455 459
 
456 460
 Editor.defaultProps = {
457 461
   rows: 5,
458
-  placeholder: "说点什么吧...",
462
+  // placeholder: "说点什么吧",
459 463
   showEmoji: true,
460 464
   showUpload: true,
461 465
   closeUploadWhenBlur: false,
462 466
   maxUpload: 1,
463
-  btnSubmitText: "发表",
467
+  // btnSubmitText: "发表",
464 468
   btnLoading: false,
465 469
   btnDisabled: false,
466 470
   showError: true,

+ 1
- 1
lib/components/Editor/index.js.map
文件差异内容过多而无法显示
查看文件


+ 7
- 2
lib/components/ImagePreviewer/ImagePreviewer.js 查看文件

@@ -26,6 +26,10 @@ var _classnames = require("classnames");
26 26
 
27 27
 var _classnames2 = _interopRequireDefault(_classnames);
28 28
 
29
+var _reactIntlUniversal = require("react-intl-universal");
30
+
31
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
32
+
29 33
 require("./ImagePreviewer.less");
30 34
 
31 35
 var _helper = require("../../helper");
@@ -161,13 +165,14 @@ var ImagePreviewer = function (_React$Component) {
161 165
             "span",
162 166
             { className: "button", onClick: onFold },
163 167
             _react2.default.createElement(_icon2.default, { type: "to-top" }),
164
-            "\u6536\u8D77"
168
+            _reactIntlUniversal2.default.get("picture.collapse")
165 169
           ),
166 170
           _react2.default.createElement(
167 171
             "span",
168 172
             { className: "button", onClick: this.onOrigin },
169 173
             _react2.default.createElement(_icon2.default, { type: "search" }),
170
-            " \u67E5\u770B\u539F\u56FE"
174
+            " ",
175
+            _reactIntlUniversal2.default.get("picture.viewOriginal")
171 176
           )
172 177
         ),
173 178
         _react2.default.createElement(

+ 1
- 1
lib/components/ImagePreviewer/ImagePreviewer.js.map
文件差异内容过多而无法显示
查看文件


+ 1
- 1
lib/components/RenderText/index.js.map 查看文件

@@ -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 查看文件

@@ -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","URL_REGEXP","REGEXP","AVATAR","IMAGE_SPLIT","IMAGE_PROCESS","IMAGE_PROCESS_SMALL","IMAGE_PROCESS_LARGE","COMMENT_TYPE","COMMENT","REPLY"],"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,6CAAjB;;AAEA,IAAMC,gDAAoB,CAA1B;;AAEA,IAAMC,kCAAa,oGAAnB;;AAEA,IAAMC,0BAAS,eAAf;;AAEA,IAAMC,0BAAS,EAAf;;AAEA,IAAMC,oCAAc,aAApB;;AAEA,IAAMC,wCAAgB,mCAAtB;AACA,IAAMC,oDAAsB,mCAA5B;AACA,IAAMC,oDAAsB,mCAA5B;;AAEA,IAAMC,sCAAe;AAC1BC,WAAS,SADiB;AAE1BC,SAAO;AAFmB,CAArB","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 = \"//links-comment.oss-cn-beijing.aliyuncs.com\";\n\nexport const MAX_UPLOAD_NUMBER = 4;\n\nexport const URL_REGEXP = /((http(s)?:)?\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/g;\n\nexport const REGEXP = /\\[[^[\\]]+?\\]/g;\n\nexport const AVATAR = \"\";\n\nexport const IMAGE_SPLIT = \"IMAGE_SPLIT\";\n\nexport const IMAGE_PROCESS = \"?x-oss-process=image/resize,h_350\";\nexport const IMAGE_PROCESS_SMALL = \"?x-oss-process=image/resize,h_100\";\nexport const IMAGE_PROCESS_LARGE = \"?x-oss-process=image/resize,h_500\";\n\nexport const COMMENT_TYPE = {\n  COMMENT: \"comment\",\n  REPLY: \"reply\"\n};\n"]}
1
+{"version":3,"sources":["../src/constant.js"],"names":["ERROR_DEFAULT","LIMIT","OSS_ENDPOINT","OSS_BUCKET","DRIVER_LICENSE_PATH","OSS_LINK","MAX_UPLOAD_NUMBER","URL_REGEXP","REGEXP","AVATAR","IMAGE_SPLIT","IMAGE_PROCESS","IMAGE_PROCESS_SMALL","IMAGE_PROCESS_LARGE","COMMENT_TYPE","COMMENT","REPLY"],"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,6CAAjB;;AAEA,IAAMC,gDAAoB,CAA1B;;AAEA,IAAMC,kCAAa,oGAAnB;;AAEA,IAAMC,0BAAS,eAAf;;AAEA,IAAMC,0BAAS,EAAf;;AAEA,IAAMC,oCAAc,aAApB;;AAEA,IAAMC,wCAAgB,mCAAtB;AACA,IAAMC,oDAAsB,mCAA5B;AACA,IAAMC,oDAAsB,mCAA5B;;AAEA,IAAMC,sCAAe;AAC1BC,WAAS,SADiB;AAE1BC,SAAO;AAFmB,CAArB","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 = \"//links-comment.oss-cn-beijing.aliyuncs.com\";\r\n\r\nexport const MAX_UPLOAD_NUMBER = 4;\r\n\r\nexport const URL_REGEXP = /((http(s)?:)?\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/g;\r\n\r\nexport const REGEXP = /\\[[^[\\]]+?\\]/g;\r\n\r\nexport const AVATAR = \"\";\r\n\r\nexport const IMAGE_SPLIT = \"IMAGE_SPLIT\";\r\n\r\nexport const IMAGE_PROCESS = \"?x-oss-process=image/resize,h_350\";\r\nexport const IMAGE_PROCESS_SMALL = \"?x-oss-process=image/resize,h_100\";\r\nexport const IMAGE_PROCESS_LARGE = \"?x-oss-process=image/resize,h_500\";\r\n\r\nexport const COMMENT_TYPE = {\r\n  COMMENT: \"comment\",\r\n  REPLY: \"reply\"\r\n};\r\n"]}

+ 1
- 1
lib/helper.js.map
文件差异内容过多而无法显示
查看文件


+ 1
- 1
lib/index.example.js.map
文件差异内容过多而无法显示
查看文件


+ 6
- 0
lib/index.js 查看文件

@@ -65,6 +65,12 @@ function renderComment(config) {
65 65
 
66 66
 window.renderComment = renderComment;
67 67
 
68
+renderComment({
69
+  id: "root-comment",
70
+  type: 1,
71
+  businessId: "test"
72
+});
73
+
68 74
 // renderComment({
69 75
 //   id: "root-comment",
70 76
 //   type: 1,

+ 1
- 1
lib/index.js.map 查看文件

@@ -1 +1 @@
1
-{"version":3,"sources":["../src/index.js"],"names":["Index","props","renderComment","config","id","Error","type","businessId","console","warn","API","userId","ReactDOM","render","document","getElementById","window"],"mappings":";;;;AAAA;;;;AACA;;;;AACA;;;;;;AACA;;AAEA,IAAMA,QAAQ,SAARA,KAAQ;AAAA,SACZ;AAAC,iBAAD;AAAA,eAAK,sBAAL,EAAsB,oBAAtB,EAAqC,oBAArC,EAAoD,eAApD,IAAkEC,KAAlE;AACE,kCAAC,WAAD,IAAQ,WAAW,CAAnB,EAAsB,eAAtB;AADF,GADY;AAAA,CAAd;;AAMA;;;;;;;;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;AACAC,YAAQC,IAAR,CAAa,+BAAb;AACD;AACD,MAAI,CAACN,OAAOO,GAAZ,EAAiB;AACf;AACAF,YAAQC,IAAR,CACE,sDADF;AAGD;AAhB4B,MAkB3BL,EAlB2B,GAuBzBD,MAvByB,CAkB3BC,EAlB2B;AAAA,qBAuBzBD,MAvByB,CAmB3BG,IAnB2B;AAAA,MAmB3BA,IAnB2B,gCAmBpB,CAnBoB;AAAA,2BAuBzBH,MAvByB,CAoB3BI,UApB2B;AAAA,MAoB3BA,UApB2B,sCAoBd,MApBc;AAAA,oBAuBzBJ,MAvByB,CAqB3BO,GArB2B;AAAA,MAqB3BA,GArB2B,+BAqBrB,oCArBqB;AAAA,MAsB3BC,MAtB2B,GAuBzBR,MAvByB,CAsB3BQ,MAtB2B;;;AAyB7BC,qBAASC,MAAT,CACE,8BAAC,KAAD,IAAO,MAAMP,IAAb,EAAmB,YAAYC,UAA/B,EAA2C,KAAKG,GAAhD,EAAqD,QAAQC,MAA7D,GADF,EAEEG,SAASC,cAAT,CAAwBX,EAAxB,CAFF;AAIA;AACD;;AAEDY,OAAOd,aAAP,GAAuBA,aAAvB;;AAEA;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\nconst Index = props => (\n  <App showAlertComment showAlertReply showAlertFavor showError {...props}>\n    <Editor maxUpload={9} autoFocus />\n  </App>\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    console.warn(\"没有传入 businessId 参数,默认使用: test\");\n  }\n  if (!config.API) {\n    // throw new Error(\"API is required\");\n    console.warn(\n      \"没有传入 API 参数,默认使用: http://api.links123.net/comment/v1\"\n    );\n  }\n  const {\n    id,\n    type = 1,\n    businessId = \"test\",\n    API = \"http://api.links123.net/comment/v1\",\n    userId\n  } = config;\n\n  ReactDOM.render(\n    <Index type={type} businessId={businessId} API={API} userId={userId} />,\n    document.getElementById(id)\n  );\n  // registerServiceWorker();\n}\n\nwindow.renderComment = renderComment;\n\n// renderComment({\n//   id: \"root-comment\",\n//   type: 1,\n//   businessId: \"test\",\n//   API: 'http://api.links123.net/comment/v1',\n// });\n"]}
1
+{"version":3,"sources":["../src/index.js"],"names":["Index","props","renderComment","config","id","Error","type","businessId","console","warn","API","userId","ReactDOM","render","document","getElementById","window"],"mappings":";;;;AAAA;;;;AACA;;;;AACA;;;;;;AACA;;AAEA,IAAMA,QAAQ,SAARA,KAAQ;AAAA,SACZ;AAAC,iBAAD;AAAA,eAAK,sBAAL,EAAsB,oBAAtB,EAAqC,oBAArC,EAAoD,eAApD,IAAkEC,KAAlE;AACE,kCAAC,WAAD,IAAQ,WAAW,CAAnB,EAAsB,eAAtB;AADF,GADY;AAAA,CAAd;;AAMA;;;;;;;;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;AACAC,YAAQC,IAAR,CAAa,+BAAb;AACD;AACD,MAAI,CAACN,OAAOO,GAAZ,EAAiB;AACf;AACAF,YAAQC,IAAR,CACE,sDADF;AAGD;AAhB4B,MAkB3BL,EAlB2B,GAuBzBD,MAvByB,CAkB3BC,EAlB2B;AAAA,qBAuBzBD,MAvByB,CAmB3BG,IAnB2B;AAAA,MAmB3BA,IAnB2B,gCAmBpB,CAnBoB;AAAA,2BAuBzBH,MAvByB,CAoB3BI,UApB2B;AAAA,MAoB3BA,UApB2B,sCAoBd,MApBc;AAAA,oBAuBzBJ,MAvByB,CAqB3BO,GArB2B;AAAA,MAqB3BA,GArB2B,+BAqBrB,oCArBqB;AAAA,MAsB3BC,MAtB2B,GAuBzBR,MAvByB,CAsB3BQ,MAtB2B;;;AAyB7BC,qBAASC,MAAT,CACE,8BAAC,KAAD,IAAO,MAAMP,IAAb,EAAmB,YAAYC,UAA/B,EAA2C,KAAKG,GAAhD,EAAqD,QAAQC,MAA7D,GADF,EAEEG,SAASC,cAAT,CAAwBX,EAAxB,CAFF;AAIA;AACD;;AAEDY,OAAOd,aAAP,GAAuBA,aAAvB;;AAEAA,cAAc;AACZE,MAAI,cADQ;AAEZE,QAAM,CAFM;AAGZC,cAAY;AAHA,CAAd;;AAMA;AACA;AACA;AACA;AACA;AACA","file":"index.js","sourcesContent":["import React from \"react\";\r\nimport ReactDOM from \"react-dom\";\r\nimport App, { Editor } from \"./App\";\r\n// import registerServiceWorker from \"./registerServiceWorker\";\r\n\r\nconst Index = props => (\r\n  <App showAlertComment showAlertReply showAlertFavor showError {...props}>\r\n    <Editor maxUpload={9} autoFocus />\r\n  </App>\r\n);\r\n\r\n/**\r\n * 渲染评论组件\r\n * @param {object} config 编辑器配置\r\n *  - {string} id 渲染评论的DOM的 ID\r\n *  - {number} type 评论的 type\r\n *  - {string} businessId 评论的 businessId\r\n *  - {string} API, API 前缀, 默认 http://api.links123.net/comment/v1\r\n */\r\nfunction renderComment(config) {\r\n  if (!config.id) {\r\n    throw new Error(\"id is required\");\r\n  }\r\n  if (!config.type) {\r\n    throw new Error(\"type is required\");\r\n  }\r\n  if (!config.businessId) {\r\n    // throw new Error(\"businessId is required\");\r\n    console.warn(\"没有传入 businessId 参数,默认使用: test\");\r\n  }\r\n  if (!config.API) {\r\n    // throw new Error(\"API is required\");\r\n    console.warn(\r\n      \"没有传入 API 参数,默认使用: http://api.links123.net/comment/v1\"\r\n    );\r\n  }\r\n  const {\r\n    id,\r\n    type = 1,\r\n    businessId = \"test\",\r\n    API = \"http://api.links123.net/comment/v1\",\r\n    userId\r\n  } = config;\r\n\r\n  ReactDOM.render(\r\n    <Index type={type} businessId={businessId} API={API} userId={userId} />,\r\n    document.getElementById(id)\r\n  );\r\n  // registerServiceWorker();\r\n}\r\n\r\nwindow.renderComment = renderComment;\r\n\r\nrenderComment({\r\n  id: \"root-comment\",\r\n  type: 1,\r\n  businessId: \"test\"\r\n});\r\n\r\n// renderComment({\r\n//   id: \"root-comment\",\r\n//   type: 1,\r\n//   businessId: \"test\",\r\n//   API: 'http://api.links123.net/comment/v1',\r\n// });\r\n"]}

+ 43
- 0
lib/lang/en-US.js 查看文件

@@ -0,0 +1,43 @@
1
+"use strict";
2
+
3
+Object.defineProperty(exports, "__esModule", {
4
+  value: true
5
+});
6
+var USdata = {
7
+  "editor.alreadyEntered": "{count} words entered",
8
+  "editor.placeholder": "Say something",
9
+  "editor.maxLength": "Maximum {maxLength} words",
10
+  "editor.SubmitBtn": "Send",
11
+  "editor.uploadTip": "Upload pictures",
12
+  "editor.uploadCount": "(You could upload {count} more)",
13
+  "editor.uploadBtn": "Upload",
14
+
15
+  "comment.tourist": "Visitor",
16
+  "comment.totalComment": "Total {total, plural, =1 {one comment} other {# comments}}",
17
+  "comment.reply": "Reply",
18
+  "comment.moreComment": "More comments",
19
+
20
+  "reply.totalReply": "Total {total, plural, =1 {one reply} other {# replies}}",
21
+  "reply.moreReply": "More replies",
22
+  "reply.collapse": "Fold replies",
23
+
24
+  "picture.collapse": "Fold",
25
+  "picture.viewOriginal": "See the original",
26
+
27
+  "popConfirm.title": "Delete?",
28
+  "popConfirm.ok": "Confirm",
29
+  "popConfirm.cancel": "Cancel",
30
+  "popConfirm.delete": "Delete",
31
+
32
+  "message.noMoreComment": "No more comments",
33
+  "message.noMoreData": "No more data",
34
+  "message.notNull": "It's still empty",
35
+  "message.success": "Comments sent",
36
+  "message.replyNoNull": "It's still empty",
37
+  "message.replySuccess": "Reply sent",
38
+  "message.cancelLickSuccess": "Unliked",
39
+  "message.likeSuccess": "Liked"
40
+};
41
+
42
+exports.default = USdata;
43
+//# sourceMappingURL=en-US.js.map

+ 1
- 0
lib/lang/en-US.js.map 查看文件

@@ -0,0 +1 @@
1
+{"version":3,"sources":["../../src/lang/en-US.js"],"names":["USdata"],"mappings":";;;;;AAAA,IAAMA,SAAS;AACb,2BAAyB,uBADZ;AAEb,wBAAsB,eAFT;AAGb,sBAAoB,2BAHP;AAIb,sBAAoB,MAJP;AAKb,sBAAoB,iBALP;AAMb,wBAAsB,iCANT;AAOb,sBAAoB,QAPP;;AASb,qBAAmB,SATN;AAUb,0BAAwB,4DAVX;AAWb,mBAAiB,OAXJ;AAYb,yBAAuB,eAZV;;AAcb,sBAAoB,yDAdP;AAeb,qBAAmB,cAfN;AAgBb,oBAAkB,cAhBL;;AAkBb,sBAAoB,MAlBP;AAmBb,0BAAwB,kBAnBX;;AAqBb,sBAAoB,SArBP;AAsBb,mBAAiB,SAtBJ;AAuBb,uBAAqB,QAvBR;AAwBb,uBAAqB,QAxBR;;AA0Bb,2BAAyB,kBA1BZ;AA2Bb,wBAAsB,cA3BT;AA4Bb,qBAAmB,kBA5BN;AA6Bb,qBAAmB,eA7BN;AA8Bb,yBAAuB,kBA9BV;AA+Bb,0BAAwB,YA/BX;AAgCb,+BAA6B,SAhChB;AAiCb,yBAAuB;AAjCV,CAAf;;kBAoCeA,M","file":"en-US.js","sourcesContent":["const USdata = {\r\n  \"editor.alreadyEntered\": \"{count} words entered\",\r\n  \"editor.placeholder\": \"Say something\",\r\n  \"editor.maxLength\": \"Maximum {maxLength} words\",\r\n  \"editor.SubmitBtn\": \"Send\",\r\n  \"editor.uploadTip\": \"Upload pictures\",\r\n  \"editor.uploadCount\": \"(You could upload {count} more)\",\r\n  \"editor.uploadBtn\": \"Upload\",\r\n\r\n  \"comment.tourist\": \"Visitor\",\r\n  \"comment.totalComment\": \"Total {total, plural, =1 {one comment} other {# comments}}\",\r\n  \"comment.reply\": \"Reply\",\r\n  \"comment.moreComment\": \"More comments\",\r\n\r\n  \"reply.totalReply\": \"Total {total, plural, =1 {one reply} other {# replies}}\",\r\n  \"reply.moreReply\": \"More replies\",\r\n  \"reply.collapse\": \"Fold replies\",\r\n\r\n  \"picture.collapse\": \"Fold\",\r\n  \"picture.viewOriginal\": \"See the original\",\r\n\r\n  \"popConfirm.title\": \"Delete?\",\r\n  \"popConfirm.ok\": \"Confirm\",\r\n  \"popConfirm.cancel\": \"Cancel\",\r\n  \"popConfirm.delete\": \"Delete\",\r\n\r\n  \"message.noMoreComment\": \"No more comments\",\r\n  \"message.noMoreData\": \"No more data\",\r\n  \"message.notNull\": \"It's still empty\",\r\n  \"message.success\": \"Comments sent\",\r\n  \"message.replyNoNull\": \"It's still empty\",\r\n  \"message.replySuccess\": \"Reply sent\",\r\n  \"message.cancelLickSuccess\": \"Unliked\",\r\n  \"message.likeSuccess\": \"Liked\"\r\n};\r\n\r\nexport default USdata;\r\n"]}

+ 37
- 15
lib/lang/index.js 查看文件

@@ -3,20 +3,42 @@
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
5 5
 });
6
-// 语言包
7
-// 英文短语和中文提示的对应
8
-var data = {
9
-  "not found": "没有数据",
10
-  "auth failed": "请先登录",
11
-  "create comment failed": "创建评论失败",
12
-  "comment favor failed": "评论点赞失败",
13
-  "delete comment favor failed": "评论取消点赞失败",
14
-  "get comments failed": "获取评论列表失败",
15
-  "create reply failed": "创建回复失败",
16
-  "reply favor failed": "回复点赞失败",
17
-  "delete reply favor failed": "删除回复点赞失败",
18
-  "get replies failed": "获取回复列表失败"
19
-};
6
+/**
7
+ * 当前支持的语言
8
+ */
9
+var SUPPORT_LOCALES = exports.SUPPORT_LOCALES = [{
10
+  name: "English",
11
+  value: "en-US"
12
+}, {
13
+  name: "简体中文",
14
+  value: "zh-CN"
15
+}];
20 16
 
21
-exports.default = data;
17
+// 服务端返回的英文短语和中文提示的对应
18
+var LOCALES_RESPONSE = exports.LOCALES_RESPONSE = {
19
+  "zh-CN": {
20
+    "not found": "没有数据",
21
+    "auth failed": "请先登录",
22
+    "create comment failed": "评论未发送",
23
+    "comment favor failed": "点赞失败",
24
+    "delete comment favor failed": "取消点赞失败",
25
+    "get comments failed": "评论加载失败",
26
+    "create reply failed": "回复失败",
27
+    "reply favor failed": "点赞失败",
28
+    "delete reply favor failed": "取消点赞失败",
29
+    "get replies failed": "回复加载失败"
30
+  },
31
+  "en-US": {
32
+    "not found": "No data",
33
+    "auth failed": "Please Login",
34
+    "create comment failed": "Comments not sent",
35
+    "comment favor failed": "Liking failed",
36
+    "delete comment favor failed": "Unliking failed",
37
+    "get comments failed": "Comments loading failed",
38
+    "create reply failed": "Replying failed",
39
+    "reply favor failed": "Liking failed",
40
+    "delete reply favor failed": "Unliking failed",
41
+    "get replies failed": "Loading of replies failed"
42
+  }
43
+};
22 44
 //# sourceMappingURL=index.js.map

+ 1
- 1
lib/lang/index.js.map 查看文件

@@ -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":["SUPPORT_LOCALES","name","value","LOCALES_RESPONSE"],"mappings":";;;;;AAAA;;;AAGO,IAAMA,4CAAkB,CAC7B;AACEC,QAAM,SADR;AAEEC,SAAO;AAFT,CAD6B,EAK7B;AACED,QAAM,MADR;AAEEC,SAAO;AAFT,CAL6B,CAAxB;;AAWP;AACO,IAAMC,8CAAmB;AAC9B,WAAS;AACP,iBAAa,MADN;AAEP,mBAAe,MAFR;AAGP,6BAAyB,OAHlB;AAIP,4BAAwB,MAJjB;AAKP,mCAA+B,QALxB;AAMP,2BAAuB,QANhB;AAOP,2BAAuB,MAPhB;AAQP,0BAAsB,MARf;AASP,iCAA6B,QATtB;AAUP,0BAAsB;AAVf,GADqB;AAa9B,WAAS;AACP,iBAAa,SADN;AAEP,mBAAe,cAFR;AAGP,6BAAyB,mBAHlB;AAIP,4BAAwB,eAJjB;AAKP,mCAA+B,iBALxB;AAMP,2BAAuB,yBANhB;AAOP,2BAAuB,iBAPhB;AAQP,0BAAsB,eARf;AASP,iCAA6B,iBATtB;AAUP,0BAAsB;AAVf;AAbqB,CAAzB","file":"index.js","sourcesContent":["/**\r\n * 当前支持的语言\r\n */\r\nexport const SUPPORT_LOCALES = [\r\n  {\r\n    name: \"English\",\r\n    value: \"en-US\"\r\n  },\r\n  {\r\n    name: \"简体中文\",\r\n    value: \"zh-CN\"\r\n  }\r\n];\r\n\r\n// 服务端返回的英文短语和中文提示的对应\r\nexport const LOCALES_RESPONSE = {\r\n  \"zh-CN\": {\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  \"en-US\": {\r\n    \"not found\": \"No data\",\r\n    \"auth failed\": \"Please Login\",\r\n    \"create comment failed\": \"Comments not sent\",\r\n    \"comment favor failed\": \"Liking failed\",\r\n    \"delete comment favor failed\": \"Unliking failed\",\r\n    \"get comments failed\": \"Comments loading failed\",\r\n    \"create reply failed\": \"Replying failed\",\r\n    \"reply favor failed\": \"Liking failed\",\r\n    \"delete reply favor failed\": \"Unliking failed\",\r\n    \"get replies failed\": \"Loading of replies failed\"\r\n  }\r\n};\r\n"]}

+ 43
- 0
lib/lang/zh-CN.js 查看文件

@@ -0,0 +1,43 @@
1
+"use strict";
2
+
3
+Object.defineProperty(exports, "__esModule", {
4
+  value: true
5
+});
6
+var CNdata = {
7
+  "editor.alreadyEntered": "已输入{count}/140字",
8
+  "editor.placeholder": "说点什么吧...",
9
+  "editor.maxLength": "字数上限{maxLength}",
10
+  "editor.SubmitBtn": "发送",
11
+  "editor.uploadTip": "上传图片",
12
+  "editor.uploadCount": "(您还能上传{count}张图片)",
13
+  "editor.uploadBtn": "上传",
14
+
15
+  "comment.tourist": "游客",
16
+  "comment.totalComment": "共{total}条评论",
17
+  "comment.reply": "回复",
18
+  "comment.moreComment": "更多评论",
19
+
20
+  "reply.totalReply": "共{total}条回复",
21
+  "reply.moreReply": "更多回复",
22
+  "reply.collapse": "收起回复",
23
+
24
+  "picture.collapse": "收起",
25
+  "picture.viewOriginal": "查看原图",
26
+
27
+  "popConfirm.title": "确定要删除吗",
28
+  "popConfirm.ok": "确定",
29
+  "popConfirm.cancel": "取消",
30
+  "popConfirm.delete": "删除",
31
+
32
+  "message.noMoreComment": "没有更多评论了",
33
+  "message.noMoreData": "没有更多数据了!",
34
+  "message.notNull": "没写内容呢",
35
+  "message.success": "评论已发送!",
36
+  "message.replyNoNull": "没写内容呢",
37
+  "message.replySuccess": "回复已发送!",
38
+  "message.cancelLickSuccess": "已取消点赞!",
39
+  "message.likeSuccess": "已赞!"
40
+};
41
+
42
+exports.default = CNdata;
43
+//# sourceMappingURL=zh-CN.js.map

+ 1
- 0
lib/lang/zh-CN.js.map 查看文件

@@ -0,0 +1 @@
1
+{"version":3,"sources":["../../src/lang/zh-CN.js"],"names":["CNdata"],"mappings":";;;;;AAAA,IAAMA,SAAS;AACb,2BAAyB,iBADZ;AAEb,wBAAsB,UAFT;AAGb,sBAAoB,iBAHP;AAIb,sBAAoB,IAJP;AAKb,sBAAoB,MALP;AAMb,wBAAsB,mBANT;AAOb,sBAAoB,IAPP;;AASb,qBAAmB,IATN;AAUb,0BAAwB,aAVX;AAWb,mBAAiB,IAXJ;AAYb,yBAAuB,MAZV;;AAcb,sBAAoB,aAdP;AAeb,qBAAmB,MAfN;AAgBb,oBAAkB,MAhBL;;AAkBb,sBAAoB,IAlBP;AAmBb,0BAAwB,MAnBX;;AAqBb,sBAAoB,QArBP;AAsBb,mBAAiB,IAtBJ;AAuBb,uBAAqB,IAvBR;AAwBb,uBAAqB,IAxBR;;AA0Bb,2BAAyB,SA1BZ;AA2Bb,wBAAsB,UA3BT;AA4Bb,qBAAmB,OA5BN;AA6Bb,qBAAmB,QA7BN;AA8Bb,yBAAuB,OA9BV;AA+Bb,0BAAwB,QA/BX;AAgCb,+BAA6B,QAhChB;AAiCb,yBAAuB;AAjCV,CAAf;;kBAoCeA,M","file":"zh-CN.js","sourcesContent":["const CNdata = {\r\n  \"editor.alreadyEntered\": \"已输入{count}/140字\",\r\n  \"editor.placeholder\": \"说点什么吧...\",\r\n  \"editor.maxLength\": \"字数上限{maxLength}\",\r\n  \"editor.SubmitBtn\": \"发送\",\r\n  \"editor.uploadTip\": \"上传图片\",\r\n  \"editor.uploadCount\": \"(您还能上传{count}张图片)\",\r\n  \"editor.uploadBtn\": \"上传\",\r\n\r\n  \"comment.tourist\": \"游客\",\r\n  \"comment.totalComment\": \"共{total}条评论\",\r\n  \"comment.reply\": \"回复\",\r\n  \"comment.moreComment\": \"更多评论\",\r\n\r\n  \"reply.totalReply\": \"共{total}条回复\",\r\n  \"reply.moreReply\": \"更多回复\",\r\n  \"reply.collapse\": \"收起回复\",\r\n\r\n  \"picture.collapse\": \"收起\",\r\n  \"picture.viewOriginal\": \"查看原图\",\r\n\r\n  \"popConfirm.title\": \"确定要删除吗\",\r\n  \"popConfirm.ok\": \"确定\",\r\n  \"popConfirm.cancel\": \"取消\",\r\n  \"popConfirm.delete\": \"删除\",\r\n\r\n  \"message.noMoreComment\": \"没有更多评论了\",\r\n  \"message.noMoreData\": \"没有更多数据了!\",\r\n  \"message.notNull\": \"没写内容呢\",\r\n  \"message.success\": \"评论已发送!\",\r\n  \"message.replyNoNull\": \"没写内容呢\",\r\n  \"message.replySuccess\": \"回复已发送!\",\r\n  \"message.cancelLickSuccess\": \"已取消点赞!\",\r\n  \"message.likeSuccess\": \"已赞!\"\r\n};\r\n\r\nexport default CNdata;\r\n"]}

+ 0
- 72
lib/mock.js 查看文件

@@ -1,72 +0,0 @@
1
-'use strict';
2
-
3
-Object.defineProperty(exports, "__esModule", {
4
-  value: true
5
-});
6
-var comments = exports.comments = {
7
-  list: [{
8
-    id: '5b3a4f0973df3e6a32b0a9d2',
9
-    user_id: 0,
10
-    user_name: '',
11
-    user_avatar: '',
12
-    content: 'test[微笑]',
13
-    replies: [{
14
-      id: '5b3c58c473df3e64d8d53afb',
15
-      user_id: 0,
16
-      user_name: '',
17
-      user_avatar: '',
18
-      reply: null,
19
-      content: 'test',
20
-      favor_count: 1,
21
-      favored: false,
22
-      created: 1530681540
23
-    }, {
24
-      id: '5b3c58c473df3e64d8d53afa',
25
-      user_id: 0,
26
-      user_name: '',
27
-      user_avatar: '',
28
-      reply: {
29
-        id: '5b3c58c473df3e64d8d53afb',
30
-        user_id: 0,
31
-        user_name: '',
32
-        user_avatar: '',
33
-        reply: null,
34
-        content: 'test',
35
-        favor_count: 1,
36
-        favored: false,
37
-        created: 1530681540
38
-      },
39
-      content: 'test',
40
-      favor_count: 2,
41
-      favored: false,
42
-      created: 1530681540
43
-    }, {
44
-      id: '5b3c6e4873df3e53f870d912',
45
-      user_id: 0,
46
-      user_name: '',
47
-      user_avatar: '',
48
-      reply: {
49
-        id: '5b3c58c473df3e64d8d53afb',
50
-        user_id: 0,
51
-        user_name: '',
52
-        user_avatar: '',
53
-        reply: null,
54
-        content: 'test',
55
-        favor_count: 1,
56
-        favored: false,
57
-        created: 1530681540
58
-      },
59
-      content: 'test',
60
-      favor_count: 0,
61
-      favored: false,
62
-      created: 1530687048
63
-    }],
64
-    reply_count: 4,
65
-    favor_count: 0,
66
-    favored: false,
67
-    created: 1530547977
68
-  }],
69
-  total: 1,
70
-  page: 1
71
-};
72
-//# sourceMappingURL=mock.js.map

+ 0
- 1
lib/mock.js.map 查看文件

@@ -1 +0,0 @@
1
-{"version":3,"sources":["../src/mock.js"],"names":["comments","list","id","user_id","user_name","user_avatar","content","replies","reply","favor_count","favored","created","reply_count","total","page"],"mappings":";;;;;AAAO,IAAMA,8BAAW;AACtBC,QAAM,CACJ;AACEC,QAAI,0BADN;AAEEC,aAAS,CAFX;AAGEC,eAAW,EAHb;AAIEC,iBAAa,EAJf;AAKEC,aAAS,UALX;AAMEC,aAAS,CACP;AACEL,UAAI,0BADN;AAEEC,eAAS,CAFX;AAGEC,iBAAW,EAHb;AAIEC,mBAAa,EAJf;AAKEG,aAAO,IALT;AAMEF,eAAS,MANX;AAOEG,mBAAa,CAPf;AAQEC,eAAS,KARX;AASEC,eAAS;AATX,KADO,EAYP;AACET,UAAI,0BADN;AAEEC,eAAS,CAFX;AAGEC,iBAAW,EAHb;AAIEC,mBAAa,EAJf;AAKEG,aAAO;AACLN,YAAI,0BADC;AAELC,iBAAS,CAFJ;AAGLC,mBAAW,EAHN;AAILC,qBAAa,EAJR;AAKLG,eAAO,IALF;AAMLF,iBAAS,MANJ;AAOLG,qBAAa,CAPR;AAQLC,iBAAS,KARJ;AASLC,iBAAS;AATJ,OALT;AAgBEL,eAAS,MAhBX;AAiBEG,mBAAa,CAjBf;AAkBEC,eAAS,KAlBX;AAmBEC,eAAS;AAnBX,KAZO,EAiCP;AACET,UAAI,0BADN;AAEEC,eAAS,CAFX;AAGEC,iBAAW,EAHb;AAIEC,mBAAa,EAJf;AAKEG,aAAO;AACLN,YAAI,0BADC;AAELC,iBAAS,CAFJ;AAGLC,mBAAW,EAHN;AAILC,qBAAa,EAJR;AAKLG,eAAO,IALF;AAMLF,iBAAS,MANJ;AAOLG,qBAAa,CAPR;AAQLC,iBAAS,KARJ;AASLC,iBAAS;AATJ,OALT;AAgBEL,eAAS,MAhBX;AAiBEG,mBAAa,CAjBf;AAkBEC,eAAS,KAlBX;AAmBEC,eAAS;AAnBX,KAjCO,CANX;AA6DEC,iBAAa,CA7Df;AA8DEH,iBAAa,CA9Df;AA+DEC,aAAS,KA/DX;AAgEEC,aAAS;AAhEX,GADI,CADgB;AAqEtBE,SAAO,CArEe;AAsEtBC,QAAM;AAtEgB,CAAjB","file":"mock.js","sourcesContent":["export const comments = {\n  list: [\n    {\n      id: '5b3a4f0973df3e6a32b0a9d2',\n      user_id: 0,\n      user_name: '',\n      user_avatar: '',\n      content: 'test[微笑]',\n      replies: [\n        {\n          id: '5b3c58c473df3e64d8d53afb',\n          user_id: 0,\n          user_name: '',\n          user_avatar: '',\n          reply: null,\n          content: 'test',\n          favor_count: 1,\n          favored: false,\n          created: 1530681540,\n        },\n        {\n          id: '5b3c58c473df3e64d8d53afa',\n          user_id: 0,\n          user_name: '',\n          user_avatar: '',\n          reply: {\n            id: '5b3c58c473df3e64d8d53afb',\n            user_id: 0,\n            user_name: '',\n            user_avatar: '',\n            reply: null,\n            content: 'test',\n            favor_count: 1,\n            favored: false,\n            created: 1530681540,\n          },\n          content: 'test',\n          favor_count: 2,\n          favored: false,\n          created: 1530681540,\n        },\n        {\n          id: '5b3c6e4873df3e53f870d912',\n          user_id: 0,\n          user_name: '',\n          user_avatar: '',\n          reply: {\n            id: '5b3c58c473df3e64d8d53afb',\n            user_id: 0,\n            user_name: '',\n            user_avatar: '',\n            reply: null,\n            content: 'test',\n            favor_count: 1,\n            favored: false,\n            created: 1530681540,\n          },\n          content: 'test',\n          favor_count: 0,\n          favored: false,\n          created: 1530687048,\n        },\n      ],\n      reply_count: 4,\n      favor_count: 0,\n      favored: false,\n      created: 1530547977,\n    },\n  ],\n  total: 1,\n  page: 1,\n};\n"]}

+ 1
- 1
lib/registerServiceWorker.js.map
文件差异内容过多而无法显示
查看文件


+ 2
- 1
package.json 查看文件

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "comment",
3
-  "version": "0.5.14",
3
+  "version": "1.0.0",
4 4
   "main": "lib/App.js",
5 5
   "description": "通用评论",
6 6
   "keywords": [
@@ -20,6 +20,7 @@
20 20
     "prop-types": "^15.6.2",
21 21
     "react": "^16.4.1",
22 22
     "react-dom": "^16.4.1",
23
+    "react-intl-universal": "^1.15.2",
23 24
     "react-scripts": "1.1.4",
24 25
     "shortid": "^2.2.11"
25 26
   },

+ 21
- 0
public/locales/en-US.json 查看文件

@@ -0,0 +1,21 @@
1
+{
2
+  "editor.alreadyEntered": "已输入{count}/140字",
3
+  "editor.placeholder": "say...",
4
+  "editor.SubmitBtn": "Submit",
5
+  "editor.uploadTip": "上传图片",
6
+  "editor.uploadCount": "(您还能上传{count}张图片)",
7
+  "editor.uploadBtn": "upload",
8
+
9
+  "comment.totalComment": "共{total}条评论",
10
+  "comment.reply": "reply",
11
+  "comment.moreComment": "More",
12
+
13
+  "reply.totalReply": "{total}条回复",
14
+  "reply.moreReply": "More",
15
+  "reply.collapse": "收起回复",
16
+
17
+  "popConfirm.title": "Sure?",
18
+  "popConfirm.ok": "Ok",
19
+  "popConfirm.cancel": "Cancel",
20
+  "popConfirm.delete": "Delete"
21
+}

+ 21
- 0
public/locales/zh-CN.json 查看文件

@@ -0,0 +1,21 @@
1
+{
2
+  "editor.alreadyEntered": "已输入{count}/140字",
3
+  "editor.placeholder": "说点什么吧...",
4
+  "editor.SubmitBtn": "发表",
5
+  "editor.uploadTip": "上传图片",
6
+  "editor.uploadCount": "(您还能上传{count}张图片)",
7
+  "editor.uploadBtn": "上传",
8
+
9
+  "comment.totalComment": "共{total}条评论",
10
+  "comment.reply": "回复",
11
+  "comment.moreComment": "查看更多评论",
12
+
13
+  "reply.totalReply": "{total}条回复",
14
+  "reply.moreReply": "查看更多回复",
15
+  "reply.collapse": "收起回复",
16
+
17
+  "popConfirm.title": "确定要删除吗",
18
+  "popConfirm.ok": "确定",
19
+  "popConfirm.cancel": "取消",
20
+  "popConfirm.delete": "删除"
21
+}

+ 78
- 27
src/App.js 查看文件

@@ -2,6 +2,7 @@ import React, { Component } from "react";
2 2
 import PropTypes from "prop-types";
3 3
 import { message } from "antd";
4 4
 import axios from "axios";
5
+import intl from "react-intl-universal";
5 6
 import { ERROR_DEFAULT, LIMIT, COMMENT_TYPE } from "./constant";
6 7
 import { CommentContext } from "./Comment";
7 8
 import { isFunction } from "./helper";
@@ -9,9 +10,15 @@ import CommentInput from "./components/CommentInput";
9 10
 import CommentList from "./components/CommentList";
10 11
 import Editor from "./components/Editor";
11 12
 import RenderText from "./components/RenderText";
12
-import lang from "./lang";
13
+import { SUPPORT_LOCALES, LOCALES_RESPONSE } from "./lang";
14
+import USdata from "./lang/en-US.js";
15
+import CNdata from "./lang/zh-CN.js";
13 16
 import "./App.css";
14
-// import styles from "./App.module.css";
17
+
18
+const LOCALES = {
19
+  "zh-CN": CNdata,
20
+  "en-US": USdata
21
+};
15 22
 
16 23
 class App extends Component {
17 24
   constructor(props) {
@@ -27,7 +34,9 @@ class App extends Component {
27 34
       page: 1,
28 35
       total: 0,
29 36
       // 是否没有更多评论了
30
-      isNoMoreComment: false
37
+      isNoMoreComment: false,
38
+      initDone: false,
39
+      locale: "zh-CN"
31 40
     };
32 41
     this.handleChangeLoading = this.handleChangeLoading.bind(this);
33 42
     this.sCreateComment = this.sCreateComment.bind(this);
@@ -52,7 +61,36 @@ class App extends Component {
52 61
     }
53 62
   }
54 63
 
55
-  componentDidMount() {}
64
+  componentDidMount() {
65
+    this.loadLocales();
66
+  }
67
+
68
+  /**
69
+   * 加载语言包
70
+   * 只能根据url或者传入的props来确定加载哪个语言包
71
+   * 优先级:传入的props > url
72
+   */
73
+  loadLocales() {
74
+    let { locales: currentLocale } = this.props;
75
+    if (!currentLocale) {
76
+      currentLocale = intl.determineLocale({
77
+        urlLocaleKey: "lang"
78
+      });
79
+    }
80
+    currentLocale = SUPPORT_LOCALES.find(item => item.value === currentLocale)
81
+      ? currentLocale
82
+      : "zh-CN";
83
+    intl
84
+      .init({
85
+        currentLocale,
86
+        locales: {
87
+          [currentLocale]: LOCALES[currentLocale]
88
+        }
89
+      })
90
+      .then(() => {
91
+        this.setState({ initDone: true, locale: currentLocale });
92
+      });
93
+  }
56 94
 
57 95
   error(msg, info = {}) {
58 96
     if (this.props.showError) {
@@ -64,13 +102,15 @@ class App extends Component {
64 102
   }
65 103
 
66 104
   errorHandler(error) {
105
+    const { locale } = this.state;
106
+    const localResponse = LOCALES_RESPONSE[locale];
67 107
     if (error.response && error.response.data && error.response.data.msg) {
68
-      this.error(lang[error.response.data.msg] || ERROR_DEFAULT, {
108
+      this.error(localResponse[error.response.data.msg] || ERROR_DEFAULT, {
69 109
         response: error.response
70 110
       });
71 111
       return;
72 112
     }
73
-    this.error(lang[error.message] || ERROR_DEFAULT, {
113
+    this.error(localResponse[error.response.data.msg] || ERROR_DEFAULT, {
74 114
       response: error.response
75 115
     });
76 116
   }
@@ -119,7 +159,7 @@ class App extends Component {
119 159
             total
120 160
           });
121 161
         } else {
122
-          message.info("没有更多评论了");
162
+          message.info(intl.get("message.noMoreComment"));
123 163
           this.setState({
124 164
             isNoMoreComment: true
125 165
           });
@@ -141,7 +181,7 @@ class App extends Component {
141 181
       .get(`${API}/replies?comment_id=${commentId}&page=${page}&limit=${limit}`)
142 182
       .then(response => {
143 183
         if (!response.data.list) {
144
-          message.info("没有更多数据了!");
184
+          message.info(intl.get("message.noMoreData"));
145 185
         }
146 186
         const list = this.state.list.map(item => {
147 187
           if (item.id === commentId) {
@@ -178,7 +218,7 @@ class App extends Component {
178 218
    * @param {object} {content} comment content
179 219
    */
180 220
   sCreateComment({ content } = {}, cb) {
181
-    if (!content) return this.error("评论内容不能为空 ");
221
+    if (!content) return this.error(intl.get("message.notNull"));
182 222
     this.handleChangeLoading("sCreateComment", true);
183 223
     const { API, type, businessId } = this.props;
184 224
     this.axios(`${API}/comments`, {
@@ -192,7 +232,7 @@ class App extends Component {
192 232
     })
193 233
       .then(response => {
194 234
         if (this.props.showAlertComment) {
195
-          message.success("评论成功!");
235
+          message.success(intl.get("message.success"));
196 236
         }
197 237
         if (isFunction(cb)) cb();
198 238
         // 将数据写入到 list 中
@@ -239,7 +279,7 @@ class App extends Component {
239 279
    * @param {object} data { comment_id, content, [reply_id] }
240 280
    */
241 281
   sCreateReply(data, cb) {
242
-    if (!data.content) return this.error("回复内容不能为空 ");
282
+    if (!data.content) return this.error(intl.get("message.replyNoNull"));
243 283
     this.handleChangeLoading("sCreateReply", true);
244 284
     const { API } = this.props;
245 285
     this.axios(`${API}/replies`, {
@@ -249,7 +289,7 @@ class App extends Component {
249 289
     })
250 290
       .then(response => {
251 291
         if (this.props.showAlertReply) {
252
-          message.success("回复成功!");
292
+          message.success(intl.get("message.replySuccess"));
253 293
         }
254 294
         if (isFunction(cb)) cb();
255 295
         // 将数据写入到 list 中
@@ -318,7 +358,11 @@ class App extends Component {
318 358
     })
319 359
       .then(response => {
320 360
         if (this.props.showAlertFavor) {
321
-          message.success(favored ? "取消点赞成功!" : "点赞成功!");
361
+          message.success(
362
+            favored
363
+              ? intl.get("message.cancelLickSuccess")
364
+              : intl.get("message.likeSuccess")
365
+          );
322 366
         }
323 367
         // 更新 list 中的该项数据的 favored
324 368
         const list = this.state.list.map(item => {
@@ -353,7 +397,11 @@ class App extends Component {
353 397
       withCredentials: true
354 398
     })
355 399
       .then(response => {
356
-        message.success(favored ? "取消点赞成功!" : "点赞成功!");
400
+        message.success(
401
+          favored
402
+            ? intl.get("message.cancelLickSuccess")
403
+            : intl.get("message.likeSuccess")
404
+        );
357 405
         // 更新 list 中的该项数据的 favored
358 406
         const list = this.state.list.map(item => {
359 407
           if (item.id === commentId) {
@@ -412,18 +460,20 @@ class App extends Component {
412 460
     };
413 461
 
414 462
     return (
415
-      <CommentContext.Provider value={value}>
416
-        <div className="comment">
417
-          {this.props.showEditor && (
418
-            <CommentInput content={this.props.children} />
419
-          )}
420
-          {this.props.showList && (
421
-            <div style={{ marginTop: 20 }}>
422
-              <CommentList />
423
-            </div>
424
-          )}
425
-        </div>
426
-      </CommentContext.Provider>
463
+      this.state.initDone && (
464
+        <CommentContext.Provider value={value}>
465
+          <div className="comment">
466
+            {this.props.showEditor && (
467
+              <CommentInput content={this.props.children} />
468
+            )}
469
+            {this.props.showList && (
470
+              <div style={{ marginTop: 20 }}>
471
+                <CommentList />
472
+              </div>
473
+            )}
474
+          </div>
475
+        </CommentContext.Provider>
476
+      )
427 477
     );
428 478
   }
429 479
 }
@@ -445,7 +495,8 @@ App.propTypes = {
445 495
   limit: PropTypes.number, // 一次加载评论数量
446 496
   onPageChange: PropTypes.func, // 页码变化回调
447 497
   onGetMoreBtnClick: PropTypes.func, // 点击查看更多按钮回调
448
-  onDelete: PropTypes.func
498
+  onDelete: PropTypes.func,
499
+  locales: PropTypes.string //  传入的语言环境, en-US/zh-CN
449 500
 };
450 501
 
451 502
 App.defaultProps = {

+ 10
- 10
src/components/CommentBox/index.js 查看文件

@@ -1,6 +1,7 @@
1 1
 import React, { Component } from "react";
2 2
 import PropTypes from "prop-types";
3 3
 import { Icon } from "antd";
4
+import intl from "react-intl-universal";
4 5
 import Comment from "../../Comment";
5 6
 import ContentItem from "./../ContentItem";
6 7
 import "./index.css";
@@ -60,21 +61,20 @@ class CommentBox extends Component {
60 61
                   action="replyToReply" // 回复的回复
61 62
                 />,
62 63
                 <div className="comment-more-box" key="show_more_button">
63
-                  {!isNoMoreReply &&
64
-                    replyCount !== len && (
65
-                      <span
66
-                        className="comment-show-more"
67
-                        onClick={() => this.handleGetMoreReply(commentId)}
68
-                      >
69
-                        查看更多回复
70
-                      </span>
71
-                    )}
64
+                  {!isNoMoreReply && replyCount !== len && (
65
+                    <span
66
+                      className="comment-show-more"
67
+                      onClick={() => this.handleGetMoreReply(commentId)}
68
+                    >
69
+                      {intl.get("reply.moreReply")}
70
+                    </span>
71
+                  )}
72 72
 
73 73
                   <a
74 74
                     style={{ float: "right" }}
75 75
                     onClick={this.handleToggleReply}
76 76
                   >
77
-                    <Icon type="up" /> 收起回复
77
+                    <Icon type="up" /> {intl.get("reply.collapse")}
78 78
                   </a>
79 79
                 </div>
80 80
               ];

+ 4
- 2
src/components/CommentList/index.js 查看文件

@@ -1,5 +1,6 @@
1 1
 import React, { Component } from "react";
2 2
 import { Spin, Pagination } from "antd";
3
+import intl from "react-intl-universal";
3 4
 import Comment from "../../Comment";
4 5
 import CommentBox from "../CommentBox";
5 6
 import "./index.css";
@@ -43,7 +44,7 @@ class CommentList extends Component {
43 44
               onPageChange(page + 1);
44 45
             }}
45 46
           >
46
-            <span>查看更多评论</span>
47
+            <span>{intl.get("comment.moreComment")}</span>
47 48
           </div>
48 49
         );
49 50
       } else {
@@ -75,7 +76,8 @@ class CommentList extends Component {
75 76
     return (
76 77
       <div>
77 78
         <Spin spinning={spinning}>
78
-          <div>共 {total} 条评论</div>
79
+          {/* <div>共 {total} 条评论</div> */}
80
+          <div>{intl.get("comment.totalComment", { total })}</div>
79 81
           {list.map(item => (
80 82
             <CommentBox content={item} key={item.id} commentId={item.id} />
81 83
           ))}

+ 67
- 53
src/components/ContentItem/index.js 查看文件

@@ -3,7 +3,9 @@ import PropTypes from "prop-types";
3 3
 import { Avatar, Icon, Tooltip, Popconfirm } from "antd";
4 4
 import dayjs from "dayjs";
5 5
 import "dayjs/locale/zh-cn";
6
+// import 'dayjs/locale/es';
6 7
 import relativeTime from "dayjs/plugin/relativeTime";
8
+import intl from "react-intl-universal";
7 9
 import Comment from "../../Comment";
8 10
 import CommentInput from "../CommentInput";
9 11
 import avatar from "../../avatar";
@@ -12,9 +14,13 @@ import { IMAGE_SPLIT } from "../../constant";
12 14
 import "./index.css";
13 15
 import ImagePreviewer from "../ImagePreviewer/ImagePreviewer";
14 16
 
15
-dayjs.locale("zh-cn");
17
+// dayjs.locale("zh-cn");
16 18
 dayjs.extend(relativeTime);
17 19
 
20
+const LOCALES = {
21
+  "zh-CN": "zh-cn"
22
+};
23
+
18 24
 class CommentItem extends Component {
19 25
   constructor(props) {
20 26
     super(props);
@@ -78,6 +84,7 @@ class CommentItem extends Component {
78 84
       app
79 85
     } = this.props;
80 86
 
87
+    const { locale } = this.props.app;
81 88
     const { showInput } = this.state;
82 89
 
83 90
     let newContent = content.content;
@@ -115,7 +122,7 @@ class CommentItem extends Component {
115 122
             {/* <a href={`/${content.user_id}`}>
116 123
               {content.user_name || "暂无昵称"}
117 124
             </a> */}
118
-            <strong>{content.user_name || "游客"}</strong>
125
+            <strong>{content.user_name || intl.get("comment.tourist")}</strong>
119 126
             <span style={{ marginLeft: 10 }}>
120 127
               <Tooltip
121 128
                 placement="top"
@@ -123,7 +130,11 @@ class CommentItem extends Component {
123 130
                   "YYYY-MM-DD HH:mm:ss"
124 131
                 )}
125 132
               >
126
-                {dayjs(content.created * 1000).fromNow()}
133
+                {LOCALES[locale]
134
+                  ? dayjs(content.created * 1000)
135
+                      .locale(LOCALES[locale])
136
+                      .fromNow()
137
+                  : dayjs(content.created * 1000).fromNow()}
127 138
               </Tooltip>
128 139
             </span>
129 140
           </div>
@@ -136,66 +147,67 @@ class CommentItem extends Component {
136 147
             }}
137 148
           />
138 149
           {// image为空时不渲染comment-item-image
139
-          imageList.length > 0 &&
140
-            imageList[0] !== "" && (
141
-              <div className="comment-item-image">
142
-                {!this.state.showPreviewer &&
143
-                  imgs.map((item, index) => {
144
-                    if (item.type === "divider") {
145
-                      return (
146
-                        <div className="comment-item-image-wrapper" key={index}>
147
-                          <div className="comment-img-divider" />
148
-                          {/* <img src={item} alt={item} className="comment-img" /> */}
149
-                        </div>
150
-                      );
151
-                    }
150
+          imageList.length > 0 && imageList[0] !== "" && (
151
+            <div className="comment-item-image">
152
+              {!this.state.showPreviewer &&
153
+                imgs.map((item, index) => {
154
+                  if (item.type === "divider") {
152 155
                     return (
153
-                      <div
154
-                        className="comment-item-image-wrapper"
155
-                        key={index}
156
-                        onClick={() => {
157
-                          let i = index;
158
-                          if (needClear) {
159
-                            if (index > 3) {
160
-                              i -= 1;
161
-                            }
162
-                            if (index > 7) {
163
-                              i -= 1;
164
-                            }
165
-                          }
166
-                          this.showPreviewer(i);
167
-                        }}
168
-                      >
169
-                        <div
170
-                          style={{ backgroundImage: `url(${item})` }}
171
-                          className="comment-img-thumbnail"
172
-                        />
156
+                      <div className="comment-item-image-wrapper" key={index}>
157
+                        <div className="comment-img-divider" />
173 158
                         {/* <img src={item} alt={item} className="comment-img" /> */}
174 159
                       </div>
175 160
                     );
176
-                  })}
177
-                {this.state.showPreviewer && (
178
-                  <ImagePreviewer
179
-                    list={imageList}
180
-                    index={this.state.previewerIndex}
181
-                    onFold={this.hidePreviewer}
182
-                  />
183
-                )}
184
-                <div className="clearfix" />
185
-              </div>
186
-            )}
161
+                  }
162
+                  return (
163
+                    <div
164
+                      className="comment-item-image-wrapper"
165
+                      key={index}
166
+                      onClick={() => {
167
+                        let i = index;
168
+                        if (needClear) {
169
+                          if (index > 3) {
170
+                            i -= 1;
171
+                          }
172
+                          if (index > 7) {
173
+                            i -= 1;
174
+                          }
175
+                        }
176
+                        this.showPreviewer(i);
177
+                      }}
178
+                    >
179
+                      <div
180
+                        style={{ backgroundImage: `url(${item})` }}
181
+                        className="comment-img-thumbnail"
182
+                      />
183
+                      {/* <img src={item} alt={item} className="comment-img" /> */}
184
+                    </div>
185
+                  );
186
+                })}
187
+              {this.state.showPreviewer && (
188
+                <ImagePreviewer
189
+                  list={imageList}
190
+                  index={this.state.previewerIndex}
191
+                  onFold={this.hidePreviewer}
192
+                />
193
+              )}
194
+              <div className="clearfix" />
195
+            </div>
196
+          )}
187 197
           <div className="comment-item-bottom">
188 198
             {content.reply_count ? (
189 199
               <div>
190 200
                 <a className="comment-item-bottom-left" onClick={onShowReply}>
191
-                  {content.reply_count} 条回复
201
+                  {/* {content.reply_count} 条回复 */}
202
+                  {intl.get("reply.totalReply", { total: content.reply_count })}
192 203
                   {showReply ? <Icon type="up" /> : <Icon type="down" />}
193 204
                 </a>
194 205
               </div>
195 206
             ) : null}
196 207
             {app.userId === content.user_id && (
197 208
               <Popconfirm
198
-                title="确定要删除吗?"
209
+                // title="确定要删除吗?"
210
+                title={intl.get("popConfirm.title")}
199 211
                 onConfirm={() => {
200 212
                   if (replyId) {
201 213
                     app.sDeleteReply(content.id, commentId);
@@ -203,17 +215,19 @@ class CommentItem extends Component {
203 215
                   }
204 216
                   app.sDeleteComment(content.id);
205 217
                 }}
206
-                okText="确定"
207
-                cancelText="取消"
218
+                okText={intl.get("popConfirm.ok")}
219
+                cancelText={intl.get("popConfirm.cancel")}
208 220
               >
209
-                <a className="comment-item-bottom-right">&nbsp; 删除</a>
221
+                <a className="comment-item-bottom-right">
222
+                  &nbsp; {intl.get("popConfirm.delete")}
223
+                </a>
210 224
               </Popconfirm>
211 225
             )}
212 226
             <a
213 227
               onClick={this.handleToggleInput}
214 228
               className="comment-item-bottom-right"
215 229
             >
216
-              &nbsp; 回复
230
+              &nbsp; {intl.get("comment.reply")}
217 231
             </a>
218 232
             <div
219 233
               className="comment-item-bottom-right"

+ 2
- 1
src/components/Editor/Upload.js 查看文件

@@ -2,6 +2,7 @@ import React from "react";
2 2
 import { Upload, Icon, Modal, message } from "antd";
3 3
 import dayjs from "dayjs";
4 4
 import shortid from "shortid";
5
+import intl from "react-intl-universal";
5 6
 import {
6 7
   OSS_ENDPOINT,
7 8
   OSS_BUCKET,
@@ -106,7 +107,7 @@ class App extends React.Component {
106 107
     const uploadButton = (
107 108
       <div>
108 109
         <Icon type="plus" />
109
-        <div className="ant-upload-text">上传</div>
110
+        <div className="ant-upload-text">{intl.get("editor.uploadBtn")}</div>
110 111
       </div>
111 112
     );
112 113
     return (

+ 15
- 7
src/components/Editor/index.js 查看文件

@@ -2,6 +2,7 @@ import React from "react";
2 2
 import PropTypes from "prop-types";
3 3
 import { Icon, Button, Popover, Input, message } from "antd";
4 4
 import classnames from "classnames";
5
+import intl from "react-intl-universal";
5 6
 import { OSS_LINK } from "../../constant";
6 7
 import { isFunction } from "../../helper";
7 8
 import Upload from "./Upload";
@@ -119,7 +120,8 @@ class Editor extends React.Component {
119 120
     const { maxLength } = this.props;
120 121
     let { value, fileMap, fileList } = this.state;
121 122
     if (value.length > maxLength) {
122
-      message.error(`字数不得超过${maxLength}字`);
123
+      // message.error(`字数不得超过${maxLength}字`);
124
+      message.error(intl.get("editor.maxLength", { maxLength }));
123 125
       return;
124 126
     }
125 127
     const files = [];
@@ -166,13 +168,13 @@ class Editor extends React.Component {
166 168
   render() {
167 169
     const {
168 170
       value,
169
-      placeholder,
171
+      // placeholder,
170 172
       rows,
171 173
       showEmoji,
172 174
       showUpload,
173 175
       closeUploadWhenBlur,
174 176
       maxUpload,
175
-      btnSubmitText,
177
+      // btnSubmitText,
176 178
       btnLoading,
177 179
       btnDisabled,
178 180
       button,
@@ -181,6 +183,8 @@ class Editor extends React.Component {
181 183
       maxLength,
182 184
       autoFocus
183 185
     } = this.props;
186
+    let placeholder = this.props.placeholder || intl.get("editor.placeholder");
187
+    let btnSubmitText = this.props.placeholder || intl.get("editor.SubmitBtn");
184 188
     const handleSubmit = this.handleSubmit;
185 189
     const disabledSubmit =
186 190
       btnDisabled ||
@@ -194,7 +198,11 @@ class Editor extends React.Component {
194 198
             "comment-editor-toolbar-error": inputValue.length > maxLength
195 199
           })}
196 200
         >
197
-          已输入 {inputValue.length} / {maxLength} 字
201
+          {intl.get("editor.alreadyEntered", {
202
+            count: inputValue.length,
203
+            maxLength
204
+          })}
205
+          {/* 已输入 {inputValue.length} / {maxLength} 字 */}
198 206
         </div>
199 207
         <div className="comment-editor">
200 208
           <TextArea
@@ -269,7 +277,7 @@ class Editor extends React.Component {
269 277
                   title={
270 278
                     <div style={{ margin: "5px auto" }}>
271 279
                       <span>
272
-                        上传图片
280
+                        {intl.get("editor.uploadTip")}
273 281
                         {maxUpload >= 2 ? (
274 282
                           <span style={{ color: "#666", fontWeight: 400 }}>
275 283
                             (您还能上传
@@ -354,12 +362,12 @@ Editor.propTypes = {
354 362
 
355 363
 Editor.defaultProps = {
356 364
   rows: 5,
357
-  placeholder: "说点什么吧...",
365
+  // placeholder: "说点什么吧",
358 366
   showEmoji: true,
359 367
   showUpload: true,
360 368
   closeUploadWhenBlur: false,
361 369
   maxUpload: 1,
362
-  btnSubmitText: "发表",
370
+  // btnSubmitText: "发表",
363 371
   btnLoading: false,
364 372
   btnDisabled: false,
365 373
   showError: true,

+ 3
- 2
src/components/ImagePreviewer/ImagePreviewer.jsx 查看文件

@@ -1,6 +1,7 @@
1 1
 import React from "react";
2 2
 import classnames from "classnames";
3 3
 import { Icon, Spin } from "antd";
4
+import intl from "react-intl-universal";
4 5
 
5 6
 import "./ImagePreviewer.less";
6 7
 // import "./ImagePreviewer.css";
@@ -104,10 +105,10 @@ export default class ImagePreviewer extends React.Component {
104 105
         <div className="toolbar">
105 106
           <span className="button" onClick={onFold}>
106 107
             <Icon type="to-top" />
107
-            收起
108
+            {intl.get("picture.collapse")}
108 109
           </span>
109 110
           <span className="button" onClick={this.onOrigin}>
110
-            <Icon type="search" /> 查看原图
111
+            <Icon type="search" /> {intl.get("picture.viewOriginal")}
111 112
           </span>
112 113
           {/* <span className="button" onClick={this.rotateRight}>
113 114
                         <Icon type="reload" /> 向右旋转

+ 6
- 0
src/index.js 查看文件

@@ -43,6 +43,12 @@ function renderComment(config) {
43 43
 
44 44
 window.renderComment = renderComment;
45 45
 
46
+renderComment({
47
+  id: "root-comment",
48
+  type: 1,
49
+  businessId: "test"
50
+});
51
+
46 52
 // renderComment({
47 53
 //   id: "root-comment",
48 54
 //   type: 1,

+ 38
- 0
src/lang/en-US.js 查看文件

@@ -0,0 +1,38 @@
1
+const USdata = {
2
+  "editor.alreadyEntered": "{count} words entered",
3
+  "editor.placeholder": "Say something",
4
+  "editor.maxLength": "Maximum {maxLength} words",
5
+  "editor.SubmitBtn": "Send",
6
+  "editor.uploadTip": "Upload pictures",
7
+  "editor.uploadCount": "(You could upload {count} more)",
8
+  "editor.uploadBtn": "Upload",
9
+
10
+  "comment.tourist": "Visitor",
11
+  "comment.totalComment":
12
+    "Total {total, plural, =1 {one comment} other {# comments}}",
13
+  "comment.reply": "Reply",
14
+  "comment.moreComment": "More comments",
15
+
16
+  "reply.totalReply": "Total {total, plural, =1 {one reply} other {# replies}}",
17
+  "reply.moreReply": "More replies",
18
+  "reply.collapse": "Fold replies",
19
+
20
+  "picture.collapse": "Fold",
21
+  "picture.viewOriginal": "See the original",
22
+
23
+  "popConfirm.title": "Delete?",
24
+  "popConfirm.ok": "Confirm",
25
+  "popConfirm.cancel": "Cancel",
26
+  "popConfirm.delete": "Delete",
27
+
28
+  "message.noMoreComment": "No more comments",
29
+  "message.noMoreData": "No more data",
30
+  "message.notNull": "It's still empty",
31
+  "message.success": "Comments sent",
32
+  "message.replyNoNull": "It's still empty",
33
+  "message.replySuccess": "Reply sent",
34
+  "message.cancelLickSuccess": "Unliked",
35
+  "message.likeSuccess": "Liked"
36
+};
37
+
38
+export default USdata;

+ 40
- 15
src/lang/index.js 查看文件

@@ -1,16 +1,41 @@
1
-// 语言包
2
-// 英文短语和中文提示的对应
3
-const data = {
4
-  "not found": "没有数据",
5
-  "auth failed": "请先登录",
6
-  "create comment failed": "创建评论失败",
7
-  "comment favor failed": "评论点赞失败",
8
-  "delete comment favor failed": "评论取消点赞失败",
9
-  "get comments failed": "获取评论列表失败",
10
-  "create reply failed": "创建回复失败",
11
-  "reply favor failed": "回复点赞失败",
12
-  "delete reply favor failed": "删除回复点赞失败",
13
-  "get replies failed": "获取回复列表失败"
14
-};
1
+/**
2
+ * 当前支持的语言
3
+ */
4
+export const SUPPORT_LOCALES = [
5
+  {
6
+    name: "English",
7
+    value: "en-US"
8
+  },
9
+  {
10
+    name: "简体中文",
11
+    value: "zh-CN"
12
+  }
13
+];
15 14
 
16
-export default data;
15
+// 服务端返回的英文短语和中文提示的对应
16
+export const LOCALES_RESPONSE = {
17
+  "zh-CN": {
18
+    "not found": "没有数据",
19
+    "auth failed": "请先登录",
20
+    "create comment failed": "评论未发送",
21
+    "comment favor failed": "点赞失败",
22
+    "delete comment favor failed": "取消点赞失败",
23
+    "get comments failed": "评论加载失败",
24
+    "create reply failed": "回复失败",
25
+    "reply favor failed": "点赞失败",
26
+    "delete reply favor failed": "取消点赞失败",
27
+    "get replies failed": "回复加载失败"
28
+  },
29
+  "en-US": {
30
+    "not found": "No data",
31
+    "auth failed": "Please Login",
32
+    "create comment failed": "Comments not sent",
33
+    "comment favor failed": "Liking failed",
34
+    "delete comment favor failed": "Unliking failed",
35
+    "get comments failed": "Comments loading failed",
36
+    "create reply failed": "Replying failed",
37
+    "reply favor failed": "Liking failed",
38
+    "delete reply favor failed": "Unliking failed",
39
+    "get replies failed": "Loading of replies failed"
40
+  }
41
+};

+ 37
- 0
src/lang/zh-CN.js 查看文件

@@ -0,0 +1,37 @@
1
+const CNdata = {
2
+  "editor.alreadyEntered": "已输入{count}/140字",
3
+  "editor.placeholder": "说点什么吧...",
4
+  "editor.maxLength": "字数上限{maxLength}",
5
+  "editor.SubmitBtn": "发送",
6
+  "editor.uploadTip": "上传图片",
7
+  "editor.uploadCount": "(您还能上传{count}张图片)",
8
+  "editor.uploadBtn": "上传",
9
+
10
+  "comment.tourist": "游客",
11
+  "comment.totalComment": "共{total}条评论",
12
+  "comment.reply": "回复",
13
+  "comment.moreComment": "更多评论",
14
+
15
+  "reply.totalReply": "共{total}条回复",
16
+  "reply.moreReply": "更多回复",
17
+  "reply.collapse": "收起回复",
18
+
19
+  "picture.collapse": "收起",
20
+  "picture.viewOriginal": "查看原图",
21
+
22
+  "popConfirm.title": "确定要删除吗",
23
+  "popConfirm.ok": "确定",
24
+  "popConfirm.cancel": "取消",
25
+  "popConfirm.delete": "删除",
26
+
27
+  "message.noMoreComment": "没有更多评论了",
28
+  "message.noMoreData": "没有更多数据了!",
29
+  "message.notNull": "没写内容呢",
30
+  "message.success": "评论已发送!",
31
+  "message.replyNoNull": "没写内容呢",
32
+  "message.replySuccess": "回复已发送!",
33
+  "message.cancelLickSuccess": "已取消点赞!",
34
+  "message.likeSuccess": "已赞!"
35
+};
36
+
37
+export default CNdata;