Browse Source

feat:add token

nodejh 5 years ago
parent
commit
ce3c61cdec
43 changed files with 605 additions and 544 deletions
  1. 104
    88
      lib/App.js
  2. 1
    1
      lib/App.js.map
  3. 2
    2
      lib/Comment.js
  4. 1
    1
      lib/Comment.js.map
  5. 2
    2
      lib/avatar.js
  6. 1
    1
      lib/avatar.js.map
  7. 3
    2
      lib/axios.js
  8. 1
    1
      lib/axios.js.map
  9. 26
    26
      lib/components/CommentBox/index.js
  10. 1
    1
      lib/components/CommentBox/index.js.map
  11. 22
    15
      lib/components/CommentInput/index.js
  12. 1
    1
      lib/components/CommentInput/index.js.map
  13. 17
    17
      lib/components/CommentList/index.js
  14. 1
    1
      lib/components/CommentList/index.js.map
  15. 3
    0
      lib/components/ContentItem/index.css
  16. 55
    55
      lib/components/ContentItem/index.js
  17. 1
    1
      lib/components/ContentItem/index.js.map
  18. 27
    27
      lib/components/Editor/Emoji.js
  19. 1
    1
      lib/components/Editor/Emoji.js.map
  20. 32
    32
      lib/components/Editor/Upload.js
  21. 1
    1
      lib/components/Editor/Upload.js.map
  22. 1
    1
      lib/components/Editor/index.css
  23. 78
    69
      lib/components/Editor/index.js
  24. 1
    1
      lib/components/Editor/index.js.map
  25. 7
    7
      lib/constant.js
  26. 1
    1
      lib/constant.js.map
  27. 111
    111
      lib/emoji.js
  28. 1
    1
      lib/emoji.js.map
  29. 7
    7
      lib/helper.js
  30. 1
    1
      lib/helper.js.map
  31. 13
    13
      lib/index.js
  32. 1
    1
      lib/index.js.map
  33. 11
    11
      lib/lang/index.js
  34. 1
    1
      lib/lang/index.js.map
  35. 14
    14
      lib/registerServiceWorker.js
  36. 1
    1
      lib/registerServiceWorker.js.map
  37. 1
    1
      package.json
  38. 20
    17
      src/App.js
  39. 12
    4
      src/components/CommentInput/index.js
  40. 3
    0
      src/components/ContentItem/index.css
  41. 5
    1
      src/components/ContentItem/index.js
  42. 11
    4
      src/components/Editor/index.js
  43. 1
    1
      src/index.js

+ 104
- 88
lib/App.js View File

@@ -1,15 +1,15 @@
1
-"use strict";
1
+'use strict';
2 2
 
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
5 5
 });
6 6
 exports.Editor = undefined;
7 7
 
8
-var _tag = require("antd/es/tag");
8
+var _tag = require('antd/es/tag');
9 9
 
10 10
 var _tag2 = _interopRequireDefault(_tag);
11 11
 
12
-var _message2 = require("antd/es/message");
12
+var _message2 = require('antd/es/message');
13 13
 
14 14
 var _message3 = _interopRequireDefault(_message2);
15 15
 
@@ -17,45 +17,45 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
17 17
 
18 18
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
19 19
 
20
-require("antd/es/tag/style/css");
20
+require('antd/es/tag/style/css');
21 21
 
22
-require("antd/es/message/style/css");
22
+require('antd/es/message/style/css');
23 23
 
24
-var _react = require("react");
24
+var _react = require('react');
25 25
 
26 26
 var _react2 = _interopRequireDefault(_react);
27 27
 
28
-var _propTypes = require("prop-types");
28
+var _propTypes = require('prop-types');
29 29
 
30 30
 var _propTypes2 = _interopRequireDefault(_propTypes);
31 31
 
32
-var _axios = require("./axios");
32
+var _axios = require('axios');
33 33
 
34 34
 var _axios2 = _interopRequireDefault(_axios);
35 35
 
36
-var _constant = require("./constant");
36
+var _constant = require('./constant');
37 37
 
38
-var _Comment = require("./Comment");
38
+var _Comment = require('./Comment');
39 39
 
40
-var _helper = require("./helper");
40
+var _helper = require('./helper');
41 41
 
42
-var _CommentInput = require("./components/CommentInput");
42
+var _CommentInput = require('./components/CommentInput');
43 43
 
44 44
 var _CommentInput2 = _interopRequireDefault(_CommentInput);
45 45
 
46
-var _CommentList = require("./components/CommentList");
46
+var _CommentList = require('./components/CommentList');
47 47
 
48 48
 var _CommentList2 = _interopRequireDefault(_CommentList);
49 49
 
50
-var _Editor = require("./components/Editor");
50
+var _Editor = require('./components/Editor');
51 51
 
52 52
 var _Editor2 = _interopRequireDefault(_Editor);
53 53
 
54
-var _lang = require("./lang");
54
+var _lang = require('./lang');
55 55
 
56 56
 var _lang2 = _interopRequireDefault(_lang);
57 57
 
58
-require("./App.css");
58
+require('./App.css');
59 59
 
60 60
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
61 61
 
@@ -98,7 +98,16 @@ var App = function (_Component) {
98 98
   }
99 99
 
100 100
   _createClass(App, [{
101
-    key: "componentDidMount",
101
+    key: 'componentWillMount',
102
+    value: function componentWillMount() {
103
+      this.axios = _axios2.default;
104
+      this.axios.defaults.withCredentials = true;
105
+      if (this.props.token) {
106
+        this.axios.defaults.headers.common['Authorization'] = 'Bearer ' + this.props.token;
107
+      }
108
+    }
109
+  }, {
110
+    key: 'componentDidMount',
102 111
     value: function componentDidMount() {}
103 112
 
104 113
     /**
@@ -108,7 +117,7 @@ var App = function (_Component) {
108 117
      */
109 118
 
110 119
   }, {
111
-    key: "handleChangeLoading",
120
+    key: 'handleChangeLoading',
112 121
     value: function handleChangeLoading(key, value) {
113 122
       var loading = this.state.loading;
114 123
 
@@ -121,7 +130,7 @@ var App = function (_Component) {
121 130
      */
122 131
 
123 132
   }, {
124
-    key: "sGetComment",
133
+    key: 'sGetComment',
125 134
     value: function sGetComment() {
126 135
       var _this2 = this;
127 136
 
@@ -129,13 +138,13 @@ var App = function (_Component) {
129 138
           _ref$page = _ref.page,
130 139
           page = _ref$page === undefined ? 1 : _ref$page;
131 140
 
132
-      this.handleChangeLoading("sGetComment", true);
141
+      this.handleChangeLoading('sGetComment', true);
133 142
       var _props = this.props,
134 143
           API = _props.API,
135 144
           type = _props.type,
136 145
           businessId = _props.businessId;
137 146
 
138
-      _axios2.default.get(API + "/comments?type=" + type + "&business_id=" + businessId + "&page=" + page + "&limit=" + _constant.LIMIT).then(function (response) {
147
+      this.axios.get(API + '/comments?type=' + type + '&business_id=' + businessId + '&page=' + page + '&limit=' + _constant.LIMIT).then(function (response) {
139 148
         var _response$data = response.data,
140 149
             list = _response$data.list,
141 150
             page = _response$data.page,
@@ -158,7 +167,7 @@ var App = function (_Component) {
158 167
             total: total
159 168
           });
160 169
         } else {
161
-          _message3.default.info("没有更多评论了");
170
+          _message3.default.info('没有更多评论了');
162 171
           _this2.setState({
163 172
             isNoMoreComment: true
164 173
           });
@@ -170,7 +179,7 @@ var App = function (_Component) {
170 179
         }
171 180
         _message3.default.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
172 181
       }).finally(function () {
173
-        _this2.handleChangeLoading("sGetComment", false);
182
+        _this2.handleChangeLoading('sGetComment', false);
174 183
       });
175 184
     }
176 185
 
@@ -179,7 +188,7 @@ var App = function (_Component) {
179 188
      */
180 189
 
181 190
   }, {
182
-    key: "sGetReply",
191
+    key: 'sGetReply',
183 192
     value: function sGetReply() {
184 193
       var _this3 = this;
185 194
 
@@ -188,12 +197,12 @@ var App = function (_Component) {
188 197
           _ref2$page = _ref2.page,
189 198
           page = _ref2$page === undefined ? 1 : _ref2$page;
190 199
 
191
-      this.handleChangeLoading("sGetReply", true);
200
+      this.handleChangeLoading('sGetReply', true);
192 201
       var API = this.props.API;
193 202
 
194
-      _axios2.default.get(API + "/replies?comment_id=" + commentId + "&page=" + page + "&limit=" + _constant.LIMIT).then(function (response) {
203
+      this.axios.get(API + '/replies?comment_id=' + commentId + '&page=' + page + '&limit=' + _constant.LIMIT).then(function (response) {
195 204
         if (!response.data.list) {
196
-          _message3.default.info("没有更多数据了!");
205
+          _message3.default.info('没有更多数据了!');
197 206
         }
198 207
         var list = _this3.state.list.map(function (item) {
199 208
           if (item.id === commentId) {
@@ -225,7 +234,7 @@ var App = function (_Component) {
225 234
         }
226 235
         _message3.default.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
227 236
       }).finally(function () {
228
-        _this3.handleChangeLoading("sGetReply", false);
237
+        _this3.handleChangeLoading('sGetReply', false);
229 238
       });
230 239
     }
231 240
 
@@ -235,22 +244,24 @@ var App = function (_Component) {
235 244
      */
236 245
 
237 246
   }, {
238
-    key: "sCreateComment",
247
+    key: 'sCreateComment',
239 248
     value: function sCreateComment() {
240 249
       var _this4 = this;
241 250
 
242 251
       var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
243 252
           content = _ref3.content;
244 253
 
245
-      if (!content) return _message3.default.error("评论内容不能为空 ");
246
-      this.handleChangeLoading("sCreateComment", true);
254
+      var cb = arguments[1];
255
+
256
+      if (!content) return _message3.default.error('评论内容不能为空 ');
257
+      this.handleChangeLoading('sCreateComment', true);
247 258
       var _props2 = this.props,
248 259
           API = _props2.API,
249 260
           type = _props2.type,
250 261
           businessId = _props2.businessId;
251 262
 
252
-      (0, _axios2.default)(API + "/comments", {
253
-        method: "post",
263
+      this.axios(API + '/comments', {
264
+        method: 'post',
254 265
         data: {
255 266
           type: type,
256 267
           business_id: businessId,
@@ -258,7 +269,8 @@ var App = function (_Component) {
258 269
         },
259 270
         withCredentials: true
260 271
       }).then(function (response) {
261
-        _message3.default.success("评论成功!");
272
+        _message3.default.success('评论成功!');
273
+        if ((0, _helper.isFunction)(cb)) cb();
262 274
         // 将数据写入到 list 中
263 275
         // 临时插入
264 276
         // 等到获取数据之后,删除临时数据
@@ -277,7 +289,7 @@ var App = function (_Component) {
277 289
         }
278 290
         _message3.default.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
279 291
       }).finally(function () {
280
-        _this4.handleChangeLoading("sCreateComment", false);
292
+        _this4.handleChangeLoading('sCreateComment', false);
281 293
       });
282 294
     }
283 295
 
@@ -288,22 +300,20 @@ var App = function (_Component) {
288 300
      */
289 301
 
290 302
   }, {
291
-    key: "sCreateReply",
303
+    key: 'sCreateReply',
292 304
     value: function sCreateReply(data, cb) {
293 305
       var _this5 = this;
294 306
 
295
-      console.log("list: ", this.state.list);
296
-
297
-      if (!data.content) return _message3.default.error("回复内容不能为空 ");
298
-      this.handleChangeLoading("sCreateReply", true);
307
+      if (!data.content) return _message3.default.error('回复内容不能为空 ');
308
+      this.handleChangeLoading('sCreateReply', true);
299 309
       var API = this.props.API;
300 310
 
301
-      (0, _axios2.default)(API + "/replies", {
302
-        method: "post",
311
+      this.axios(API + '/replies', {
312
+        method: 'post',
303 313
         data: data,
304 314
         withCredentials: true
305 315
       }).then(function (response) {
306
-        _message3.default.success("回复成功!");
316
+        _message3.default.success('回复成功!');
307 317
         if ((0, _helper.isFunction)(cb)) cb();
308 318
         // 将数据写入到 list 中
309 319
         // 临时插入
@@ -326,7 +336,7 @@ var App = function (_Component) {
326 336
         }
327 337
         _message3.default.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
328 338
       }).finally(function () {
329
-        _this5.handleChangeLoading("sCreateReply", false);
339
+        _this5.handleChangeLoading('sCreateReply', false);
330 340
       });
331 341
     }
332 342
 
@@ -337,18 +347,18 @@ var App = function (_Component) {
337 347
      */
338 348
 
339 349
   }, {
340
-    key: "sCommentFavor",
350
+    key: 'sCommentFavor',
341 351
     value: function sCommentFavor(commentId, favored) {
342 352
       var _this6 = this;
343 353
 
344
-      this.handleChangeLoading("sCommentFavor", true);
354
+      this.handleChangeLoading('sCommentFavor', true);
345 355
       var API = this.props.API;
346 356
 
347
-      (0, _axios2.default)(API + "/comments/" + commentId + "/favor", {
348
-        method: favored ? "delete" : "put",
357
+      this.axios(API + '/comments/' + commentId + '/favor', {
358
+        method: favored ? 'delete' : 'put',
349 359
         withCredentials: true
350 360
       }).then(function (response) {
351
-        _message3.default.success(favored ? "取消点赞成功!" : "点赞成功!");
361
+        _message3.default.success(favored ? '取消点赞成功!' : '点赞成功!');
352 362
         // 更新 list 中的该项数据的 favored
353 363
         var list = _this6.state.list.map(function (item) {
354 364
           if (item.id === commentId) {
@@ -365,7 +375,7 @@ var App = function (_Component) {
365 375
         }
366 376
         _message3.default.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
367 377
       }).finally(function () {
368
-        _this6.handleChangeLoading("sCommentFavor", false);
378
+        _this6.handleChangeLoading('sCommentFavor', false);
369 379
       });
370 380
     }
371 381
 
@@ -377,32 +387,38 @@ var App = function (_Component) {
377 387
      */
378 388
 
379 389
   }, {
380
-    key: "sReplyFavor",
390
+    key: 'sReplyFavor',
381 391
     value: function sReplyFavor(replyId, commentId, favored) {
382 392
       var _this7 = this;
383 393
 
384
-      this.handleChangeLoading("sReplyFavor", true);
385
-      console.log("replyId, commentId ", replyId, commentId);
386
-
394
+      this.handleChangeLoading('sReplyFavor', true);
387 395
       var API = this.props.API;
388 396
 
389
-      (0, _axios2.default)(API + "/replies/" + replyId + "/favor", {
390
-        method: favored ? "delete" : "put",
397
+      this.axios(API + '/replies/' + replyId + '/favor', {
398
+        method: favored ? 'delete' : 'put',
399
+        data: {
400
+          comment_id: commentId
401
+        },
391 402
         withCredentials: true
392 403
       }).then(function (response) {
393
-        console.log("response: ", response);
394
-
395
-        _message3.default.success(favored ? "取消点赞成功!" : "点赞成功!");
396
-        // TODO: (2018.07.20 node) 对评论的回复点赞,报错
397
-        // // 更新 list 中的该项数据的 favored
398
-        // const list = this.state.list.map(item => {
399
-        //   if (item.id === replyId) {
400
-        //     item.favored = !favored;
401
-        //     item.favor_count += favored ? -1 : 1;
402
-        //   }
403
-        //   return item;
404
-        // });
405
-        // this.setState({ list });
404
+        _message3.default.success(favored ? '取消点赞成功!' : '点赞成功!');
405
+        // 更新 list 中的该项数据的 favored
406
+        var list = _this7.state.list.map(function (item) {
407
+          if (item.id === commentId) {
408
+            item.replies = item.replies.map(function (r) {
409
+              if (r.id === replyId) {
410
+                r.favored = !favored;
411
+                // r.favor_count =  response.data.favor_count;
412
+                // 点赞数 +1,而不是使用后端返回的点赞数
413
+                // 不然如果返回的不是增加 1,用户可能以为程序错误
414
+                r.favor_count += favored ? -1 : 1;
415
+              }
416
+              return r;
417
+            });
418
+          }
419
+          return item;
420
+        });
421
+        _this7.setState({ list: list });
406 422
       }).catch(function (error) {
407 423
         if (error.response && error.response.data && error.response.data.msg) {
408 424
           _message3.default.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT);
@@ -410,7 +426,7 @@ var App = function (_Component) {
410 426
         }
411 427
         _message3.default.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
412 428
       }).finally(function () {
413
-        _this7.handleChangeLoading("sReplyFavor", false);
429
+        _this7.handleChangeLoading('sReplyFavor', false);
414 430
       });
415 431
     }
416 432
 
@@ -419,14 +435,14 @@ var App = function (_Component) {
419 435
      */
420 436
 
421 437
   }, {
422
-    key: "sOssSts",
438
+    key: 'sOssSts',
423 439
     value: function sOssSts() {
424 440
       var _this8 = this;
425 441
 
426
-      this.handleChangeLoading("sOssSts", true);
442
+      this.handleChangeLoading('sOssSts', true);
427 443
       var API = this.props.API;
428 444
 
429
-      _axios2.default.get(API + "/oss/sts").then(function (response) {
445
+      this.axios.get(API + '/oss/sts').then(function (response) {
430 446
         _this8.setState({ oss: _extends({}, response.data) });
431 447
       }).catch(function (error) {
432 448
         if (error.response && error.response.data && error.response.data.msg) {
@@ -435,11 +451,11 @@ var App = function (_Component) {
435 451
         }
436 452
         _message3.default.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT);
437 453
       }).finally(function () {
438
-        _this8.handleChangeLoading("sOssSts", false);
454
+        _this8.handleChangeLoading('sOssSts', false);
439 455
       });
440 456
     }
441 457
   }, {
442
-    key: "render",
458
+    key: 'render',
443 459
     value: function render() {
444 460
       // 添加到 Context 的数据
445 461
       var value = _extends({}, this.state, this.props, {
@@ -456,30 +472,30 @@ var App = function (_Component) {
456 472
         _Comment.CommentContext.Provider,
457 473
         { value: value },
458 474
         _react2.default.createElement(
459
-          "div",
460
-          { className: "comment" },
475
+          'div',
476
+          { className: 'comment' },
461 477
           this.props.showHeader && _react2.default.createElement(
462
-            "div",
478
+            'div',
463 479
             { style: { marginBottom: 15 } },
464 480
             _react2.default.createElement(
465 481
               _tag2.default,
466
-              { className: "comment-header-tag" },
467
-              "\u7559\u8A00"
482
+              { className: 'comment-header-tag' },
483
+              '\u7559\u8A00'
468 484
             ),
469 485
             _react2.default.createElement(
470
-              "span",
471
-              { className: "comment-header-tip" },
472
-              "\u53E3\u7891"
486
+              'span',
487
+              { className: 'comment-header-tip' },
488
+              '\u53E3\u7891'
473 489
             ),
474 490
             _react2.default.createElement(
475
-              "span",
476
-              { className: "comment-header-text" },
477
-              "(\u5168\u7AD9\u6311\u51FA\u6BDB\u75C5\u6216\u63D0\u51FA\u5408\u7406\u5EFA\u8BAE\uFF0C\u5956\u52B110\u5230100\u5143\u7EA2\u5305)"
491
+              'span',
492
+              { className: 'comment-header-text' },
493
+              '(\u5168\u7AD9\u6311\u51FA\u6BDB\u75C5\u6216\u63D0\u51FA\u5408\u7406\u5EFA\u8BAE\uFF0C\u5956\u52B110\u5230100\u5143\u7EA2\u5305)'
478 494
             )
479 495
           ),
480 496
           this.props.showEditor && _react2.default.createElement(_CommentInput2.default, { content: this.props.children }),
481 497
           this.props.showList && _react2.default.createElement(
482
-            "div",
498
+            'div',
483 499
             { style: { marginTop: 20 } },
484 500
             _react2.default.createElement(_CommentList2.default, null)
485 501
           )
@@ -501,7 +517,7 @@ App.propTypes = {
501 517
 };
502 518
 
503 519
 App.defaultProps = {
504
-  API: "http://api.links123.net/comment/v1",
520
+  API: 'http://api.links123.net/comment/v1',
505 521
   showList: true,
506 522
   showEditor: true,
507 523
   showHeader: true

+ 1
- 1
lib/App.js.map
File diff suppressed because it is too large
View File


+ 2
- 2
lib/Comment.js View File

@@ -1,4 +1,4 @@
1
-"use strict";
1
+'use strict';
2 2
 
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
@@ -9,7 +9,7 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
9 9
 
10 10
 exports.Comment = Comment;
11 11
 
12
-var _react = require("react");
12
+var _react = require('react');
13 13
 
14 14
 var _react2 = _interopRequireDefault(_react);
15 15
 

+ 1
- 1
lib/Comment.js.map View File

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

+ 2
- 2
lib/avatar.js
File diff suppressed because it is too large
View File


+ 1
- 1
lib/avatar.js.map
File diff suppressed because it is too large
View File


+ 3
- 2
lib/axios.js View File

@@ -1,16 +1,17 @@
1
-"use strict";
1
+'use strict';
2 2
 
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
5 5
 });
6 6
 
7
-var _axios = require("axios");
7
+var _axios = require('axios');
8 8
 
9 9
 var _axios2 = _interopRequireDefault(_axios);
10 10
 
11 11
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12 12
 
13 13
 _axios2.default.defaults.withCredentials = true;
14
+_axios2.default.defaults.headers.common['Authorization'] = 'Bearer ';
14 15
 
15 16
 exports.default = _axios2.default;
16 17
 //# sourceMappingURL=axios.js.map

+ 1
- 1
lib/axios.js.map View File

@@ -1 +1 @@
1
-{"version":3,"sources":["../src/axios.js"],"names":["axios","defaults","withCredentials"],"mappings":";;;;;;AAAA;;;;;;AAEAA,gBAAMC,QAAN,CAAeC,eAAf,GAAiC,IAAjC;;kBAEeF,e","file":"axios.js","sourcesContent":["import axios from \"axios\";\n\naxios.defaults.withCredentials = true;\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';\n\naxios.defaults.withCredentials = true;\naxios.defaults.headers.common['Authorization'] = 'Bearer ';\n\nexport default axios;\n"]}

+ 26
- 26
lib/components/CommentBox/index.js View File

@@ -1,34 +1,34 @@
1
-"use strict";
1
+'use strict';
2 2
 
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
5 5
 });
6 6
 
7
-var _icon = require("antd/es/icon");
7
+var _icon = require('antd/es/icon');
8 8
 
9 9
 var _icon2 = _interopRequireDefault(_icon);
10 10
 
11 11
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
12 12
 
13
-require("antd/es/icon/style/css");
13
+require('antd/es/icon/style/css');
14 14
 
15
-var _react = require("react");
15
+var _react = require('react');
16 16
 
17 17
 var _react2 = _interopRequireDefault(_react);
18 18
 
19
-var _propTypes = require("prop-types");
19
+var _propTypes = require('prop-types');
20 20
 
21 21
 var _propTypes2 = _interopRequireDefault(_propTypes);
22 22
 
23
-var _Comment = require("../../Comment");
23
+var _Comment = require('../../Comment');
24 24
 
25 25
 var _Comment2 = _interopRequireDefault(_Comment);
26 26
 
27
-var _ContentItem = require("./../ContentItem");
27
+var _ContentItem = require('./../ContentItem');
28 28
 
29 29
 var _ContentItem2 = _interopRequireDefault(_ContentItem);
30 30
 
31
-require("./index.css");
31
+require('./index.css');
32 32
 
33 33
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34 34
 
@@ -63,7 +63,7 @@ var CommentBox = function (_Component) {
63 63
 
64 64
 
65 65
   _createClass(CommentBox, [{
66
-    key: "handleToggleReply",
66
+    key: 'handleToggleReply',
67 67
     value: function handleToggleReply() {
68 68
       this.setState({ showReply: !this.state.showReply });
69 69
     }
@@ -74,7 +74,7 @@ var CommentBox = function (_Component) {
74 74
      */
75 75
 
76 76
   }, {
77
-    key: "handleGetMoreReply",
77
+    key: 'handleGetMoreReply',
78 78
     value: function handleGetMoreReply(commentId) {
79 79
       // 从第一页开始获取评论
80 80
       var page = this.state.page;
@@ -91,7 +91,7 @@ var CommentBox = function (_Component) {
91 91
      */
92 92
 
93 93
   }, {
94
-    key: "renderReplies",
94
+    key: 'renderReplies',
95 95
     value: function renderReplies(replies, replyCount, isNoMoreReply) {
96 96
       var _this2 = this;
97 97
 
@@ -101,7 +101,7 @@ var CommentBox = function (_Component) {
101 101
       if (showReply && replies && replies.length) {
102 102
         var len = replies.length;
103 103
         return _react2.default.createElement(
104
-          "div",
104
+          'div',
105 105
           { style: { marginLeft: 50 } },
106 106
           replies.map(function (item, index) {
107 107
             if (index === len - 1) {
@@ -110,28 +110,28 @@ var CommentBox = function (_Component) {
110 110
                 replyId: item.id,
111 111
                 key: item.id,
112 112
                 content: item,
113
-                action: "replyToReply" // 回复的回复
113
+                action: 'replyToReply' // 回复的回复
114 114
               }), _react2.default.createElement(
115
-                "div",
116
-                { className: "comment-more-box", key: "show_more_button" },
115
+                'div',
116
+                { className: 'comment-more-box', key: 'show_more_button' },
117 117
                 !isNoMoreReply && replyCount !== len && _react2.default.createElement(
118
-                  "span",
118
+                  'span',
119 119
                   {
120
-                    className: "comment-show-more",
120
+                    className: 'comment-show-more',
121 121
                     onClick: function onClick() {
122 122
                       return _this2.handleGetMoreReply(commentId);
123 123
                     }
124 124
                   },
125
-                  "\u67E5\u770B\u66F4\u591A\u56DE\u590D"
125
+                  '\u67E5\u770B\u66F4\u591A\u56DE\u590D'
126 126
                 ),
127 127
                 _react2.default.createElement(
128
-                  "a",
128
+                  'a',
129 129
                   {
130
-                    style: { float: "right" },
130
+                    style: { float: 'right' },
131 131
                     onClick: _this2.handleToggleReply
132 132
                   },
133
-                  _react2.default.createElement(_icon2.default, { type: "up" }),
134
-                  " \u6536\u8D77\u56DE\u590D"
133
+                  _react2.default.createElement(_icon2.default, { type: 'up' }),
134
+                  ' \u6536\u8D77\u56DE\u590D'
135 135
                 )
136 136
               )];
137 137
             }
@@ -140,7 +140,7 @@ var CommentBox = function (_Component) {
140 140
               replyId: item.id,
141 141
               key: item.id,
142 142
               content: item,
143
-              action: "replyToReply" // 评论的回复
143
+              action: 'replyToReply' // 评论的回复
144 144
             });
145 145
           })
146 146
         );
@@ -148,20 +148,20 @@ var CommentBox = function (_Component) {
148 148
       return null;
149 149
     }
150 150
   }, {
151
-    key: "render",
151
+    key: 'render',
152 152
     value: function render() {
153 153
       var content = this.props.content;
154 154
       var showReply = this.state.showReply;
155 155
 
156 156
       return _react2.default.createElement(
157
-        "div",
157
+        'div',
158 158
         null,
159 159
         _react2.default.createElement(_ContentItem2.default, {
160 160
           content: content,
161 161
           onShowReply: this.handleToggleReply,
162 162
           showReply: showReply,
163 163
           commentId: content.id,
164
-          action: "reply" // 评论的回复
164
+          action: 'reply' // 评论的回复
165 165
         }),
166 166
         this.renderReplies(content.replies, content.reply_count, content.isNoMoreReply)
167 167
       );

+ 1
- 1
lib/components/CommentBox/index.js.map
File diff suppressed because it is too large
View File


+ 22
- 15
lib/components/CommentInput/index.js View File

@@ -1,4 +1,4 @@
1
-"use strict";
1
+'use strict';
2 2
 
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
@@ -8,15 +8,15 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
8 8
 
9 9
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
10 10
 
11
-var _react = require("react");
11
+var _react = require('react');
12 12
 
13 13
 var _react2 = _interopRequireDefault(_react);
14 14
 
15
-var _propTypes = require("prop-types");
15
+var _propTypes = require('prop-types');
16 16
 
17 17
 var _propTypes2 = _interopRequireDefault(_propTypes);
18 18
 
19
-var _Comment = require("../../Comment");
19
+var _Comment = require('../../Comment');
20 20
 
21 21
 var _Comment2 = _interopRequireDefault(_Comment);
22 22
 
@@ -41,27 +41,34 @@ var CommentInput = function (_Component) {
41 41
     return _this;
42 42
   }
43 43
 
44
+  /**
45
+   * 提交评论
46
+   * @param {string} value 需要提交的评论的值
47
+   * @param {function} cb 提交成功后的回掉
48
+   */
49
+
50
+
44 51
   _createClass(CommentInput, [{
45
-    key: "handleSubmit",
46
-    value: function handleSubmit(value) {
52
+    key: 'handleSubmit',
53
+    value: function handleSubmit(value, cb) {
47 54
       var _props = this.props,
48 55
           action = _props.action,
49 56
           commentId = _props.commentId,
50 57
           replyId = _props.replyId,
51 58
           callback = _props.callback;
52 59
 
53
-      if (action === "comment") {
60
+      if (action === 'comment') {
54 61
         this.props.app.sCreateComment({
55 62
           content: value
56
-        });
57
-      } else if (action === "reply") {
63
+        }, cb);
64
+      } else if (action === 'reply') {
58 65
         this.props.app.sCreateReply({
59 66
           comment_id: commentId,
60 67
           content: value
61 68
         }, function () {
62 69
           return callback && callback();
63 70
         });
64
-      } else if (action === "replyToReply") {
71
+      } else if (action === 'replyToReply') {
65 72
         this.props.app.sCreateReply({
66 73
           comment_id: commentId,
67 74
           content: value,
@@ -72,7 +79,7 @@ var CommentInput = function (_Component) {
72 79
       }
73 80
     }
74 81
   }, {
75
-    key: "render",
82
+    key: 'render',
76 83
     value: function render() {
77 84
       var _this2 = this;
78 85
 
@@ -85,12 +92,12 @@ var CommentInput = function (_Component) {
85 92
           onSubmit: _this2.handleSubmit
86 93
         }, child.props, {
87 94
           // 如果当前的编辑器不是“评论”,则编辑器高度减小一些
88
-          rows: _this2.props.action === "comment" ? child.props.rows : child.props.rows - 1
95
+          rows: _this2.props.action === 'comment' ? child.props.rows : child.props.rows - 1
89 96
         }));
90 97
       });
91 98
 
92 99
       return _react2.default.createElement(
93
-        "div",
100
+        'div',
94 101
         null,
95 102
         childrenWithProps
96 103
       );
@@ -104,11 +111,11 @@ CommentInput.propTypes = {
104 111
   // comment 评论
105 112
   // reply 评论的回复
106 113
   // replyToReply 回复的回复
107
-  action: _propTypes2.default.oneOf(["comment", "reply", "replyToReply"])
114
+  action: _propTypes2.default.oneOf(['comment', 'reply', 'replyToReply'])
108 115
 };
109 116
 
110 117
 CommentInput.defaultProps = {
111
-  action: "comment"
118
+  action: 'comment'
112 119
 };
113 120
 
114 121
 exports.default = (0, _Comment2.default)(CommentInput);

+ 1
- 1
lib/components/CommentInput/index.js.map View File

@@ -1 +1 @@
1
-{"version":3,"sources":["../../../src/components/CommentInput/index.js"],"names":["CommentInput","props","state","handleSubmit","bind","value","action","commentId","replyId","callback","app","sCreateComment","content","sCreateReply","comment_id","reply_id","childrenWithProps","React","Children","map","cloneElement","child","onSubmit","rows","Component","propTypes","PropTypes","oneOf","defaultProps"],"mappings":";;;;;;;;;;AAAA;;;;AACA;;;;AACA;;;;;;;;;;;;IAEMA,Y;;;AACJ,wBAAYC,KAAZ,EAAmB;AAAA;;AAAA,4HACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa,EAAb;AACA,UAAKC,YAAL,GAAoB,MAAKA,YAAL,CAAkBC,IAAlB,OAApB;AAHiB;AAIlB;;;;iCAEYC,K,EAAO;AAAA,mBAC+B,KAAKJ,KADpC;AAAA,UACVK,MADU,UACVA,MADU;AAAA,UACFC,SADE,UACFA,SADE;AAAA,UACSC,OADT,UACSA,OADT;AAAA,UACkBC,QADlB,UACkBA,QADlB;;AAElB,UAAIH,WAAW,SAAf,EAA0B;AACxB,aAAKL,KAAL,CAAWS,GAAX,CAAeC,cAAf,CAA8B;AAC5BC,mBAASP;AADmB,SAA9B;AAGD,OAJD,MAIO,IAAIC,WAAW,OAAf,EAAwB;AAC7B,aAAKL,KAAL,CAAWS,GAAX,CAAeG,YAAf,CACE;AACEC,sBAAYP,SADd;AAEEK,mBAASP;AAFX,SADF,EAKE;AAAA,iBAAMI,YAAYA,UAAlB;AAAA,SALF;AAOD,OARM,MAQA,IAAIH,WAAW,cAAf,EAA+B;AACpC,aAAKL,KAAL,CAAWS,GAAX,CAAeG,YAAf,CACE;AACEC,sBAAYP,SADd;AAEEK,mBAASP,KAFX;AAGEU,oBAAUP;AAHZ,SADF,EAME;AAAA,iBAAMC,YAAYA,UAAlB;AAAA,SANF;AAQD;AACF;;;6BAEQ;AAAA;;AACP,UAAMO,oBAAoBC,gBAAMC,QAAN,CAAeC,GAAf,CAAmB,KAAKlB,KAAL,CAAWW,OAA9B,EAAuC,iBAAS;AACxE,eAAOK,gBAAMG,YAAN,CAAmBC,KAAnB;AACL;AACA;AACA;AACA;AACAC,oBAAU,OAAKnB;AALV,WAMFkB,MAAMpB,KANJ;AAOL;AACAsB,gBACE,OAAKtB,KAAL,CAAWK,MAAX,KAAsB,SAAtB,GACIe,MAAMpB,KAAN,CAAYsB,IADhB,GAEIF,MAAMpB,KAAN,CAAYsB,IAAZ,GAAmB;AAXpB,WAAP;AAaD,OAdyB,CAA1B;;AAgBA,aAAO;AAAA;AAAA;AAAMP;AAAN,OAAP;AACD;;;;EAnDwBQ,gB;;AAsD3BxB,aAAayB,SAAb,GAAyB;AACvB;AACA;AACA;AACAnB,UAAQoB,oBAAUC,KAAV,CAAgB,CAAC,SAAD,EAAY,OAAZ,EAAqB,cAArB,CAAhB;AAJe,CAAzB;;AAOA3B,aAAa4B,YAAb,GAA4B;AAC1BtB,UAAQ;AADkB,CAA5B;;kBAIe,uBAAQN,YAAR,C","file":"index.js","sourcesContent":["import React, { Component } from \"react\";\nimport PropTypes from \"prop-types\";\nimport Comment from \"../../Comment\";\n\nclass CommentInput extends Component {\n  constructor(props) {\n    super(props);\n    this.state = {};\n    this.handleSubmit = this.handleSubmit.bind(this);\n  }\n\n  handleSubmit(value) {\n    const { action, commentId, replyId, callback } = this.props;\n    if (action === \"comment\") {\n      this.props.app.sCreateComment({\n        content: value\n      });\n    } else if (action === \"reply\") {\n      this.props.app.sCreateReply(\n        {\n          comment_id: commentId,\n          content: value\n        },\n        () => callback && callback()\n      );\n    } else if (action === \"replyToReply\") {\n      this.props.app.sCreateReply(\n        {\n          comment_id: commentId,\n          content: value,\n          reply_id: replyId\n        },\n        () => callback && callback()\n      );\n    }\n  }\n\n  render() {\n    const childrenWithProps = React.Children.map(this.props.content, child => {\n      return React.cloneElement(child, {\n        // 编辑器本身不提交值,但 CommentInput 会提交\n        // CommentInput 主要是负责评论的业务逻辑,提交评论和回复\n        // 默认使用 CommentInput 的 onSubmit 来提交评论\n        // 但也可以使用 Editor 的 props 来覆盖 onSubmit\n        onSubmit: this.handleSubmit,\n        ...child.props,\n        // 如果当前的编辑器不是“评论”,则编辑器高度减小一些\n        rows:\n          this.props.action === \"comment\"\n            ? child.props.rows\n            : child.props.rows - 1\n      });\n    });\n\n    return <div>{childrenWithProps}</div>;\n  }\n}\n\nCommentInput.propTypes = {\n  // comment 评论\n  // reply 评论的回复\n  // replyToReply 回复的回复\n  action: PropTypes.oneOf([\"comment\", \"reply\", \"replyToReply\"])\n};\n\nCommentInput.defaultProps = {\n  action: \"comment\"\n};\n\nexport default Comment(CommentInput);\n"]}
1
+{"version":3,"sources":["../../../src/components/CommentInput/index.js"],"names":["CommentInput","props","state","handleSubmit","bind","value","cb","action","commentId","replyId","callback","app","sCreateComment","content","sCreateReply","comment_id","reply_id","childrenWithProps","React","Children","map","cloneElement","child","onSubmit","rows","Component","propTypes","PropTypes","oneOf","defaultProps"],"mappings":";;;;;;;;;;AAAA;;;;AACA;;;;AACA;;;;;;;;;;;;IAEMA,Y;;;AACJ,wBAAYC,KAAZ,EAAmB;AAAA;;AAAA,4HACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa,EAAb;AACA,UAAKC,YAAL,GAAoB,MAAKA,YAAL,CAAkBC,IAAlB,OAApB;AAHiB;AAIlB;;AAED;;;;;;;;;iCAKaC,K,EAAOC,E,EAAI;AAAA,mBAC2B,KAAKL,KADhC;AAAA,UACdM,MADc,UACdA,MADc;AAAA,UACNC,SADM,UACNA,SADM;AAAA,UACKC,OADL,UACKA,OADL;AAAA,UACcC,QADd,UACcA,QADd;;AAEtB,UAAIH,WAAW,SAAf,EAA0B;AACxB,aAAKN,KAAL,CAAWU,GAAX,CAAeC,cAAf,CACE;AACEC,mBAASR;AADX,SADF,EAIEC,EAJF;AAMD,OAPD,MAOO,IAAIC,WAAW,OAAf,EAAwB;AAC7B,aAAKN,KAAL,CAAWU,GAAX,CAAeG,YAAf,CACE;AACEC,sBAAYP,SADd;AAEEK,mBAASR;AAFX,SADF,EAKE;AAAA,iBAAMK,YAAYA,UAAlB;AAAA,SALF;AAOD,OARM,MAQA,IAAIH,WAAW,cAAf,EAA+B;AACpC,aAAKN,KAAL,CAAWU,GAAX,CAAeG,YAAf,CACE;AACEC,sBAAYP,SADd;AAEEK,mBAASR,KAFX;AAGEW,oBAAUP;AAHZ,SADF,EAME;AAAA,iBAAMC,YAAYA,UAAlB;AAAA,SANF;AAQD;AACF;;;6BAEQ;AAAA;;AACP,UAAMO,oBAAoBC,gBAAMC,QAAN,CAAeC,GAAf,CAAmB,KAAKnB,KAAL,CAAWY,OAA9B,EAAuC,iBAAS;AACxE,eAAOK,gBAAMG,YAAN,CAAmBC,KAAnB;AACL;AACA;AACA;AACA;AACAC,oBAAU,OAAKpB;AALV,WAMFmB,MAAMrB,KANJ;AAOL;AACAuB,gBACE,OAAKvB,KAAL,CAAWM,MAAX,KAAsB,SAAtB,GACIe,MAAMrB,KAAN,CAAYuB,IADhB,GAEIF,MAAMrB,KAAN,CAAYuB,IAAZ,GAAmB;AAXpB,WAAP;AAaD,OAdyB,CAA1B;;AAgBA,aAAO;AAAA;AAAA;AAAMP;AAAN,OAAP;AACD;;;;EA3DwBQ,gB;;AA8D3BzB,aAAa0B,SAAb,GAAyB;AACvB;AACA;AACA;AACAnB,UAAQoB,oBAAUC,KAAV,CAAgB,CAAC,SAAD,EAAY,OAAZ,EAAqB,cAArB,CAAhB;AAJe,CAAzB;;AAOA5B,aAAa6B,YAAb,GAA4B;AAC1BtB,UAAQ;AADkB,CAA5B;;kBAIe,uBAAQP,YAAR,C","file":"index.js","sourcesContent":["import React, { Component } from 'react';\nimport PropTypes from 'prop-types';\nimport Comment from '../../Comment';\n\nclass CommentInput extends Component {\n  constructor(props) {\n    super(props);\n    this.state = {};\n    this.handleSubmit = this.handleSubmit.bind(this);\n  }\n\n  /**\n   * 提交评论\n   * @param {string} value 需要提交的评论的值\n   * @param {function} cb 提交成功后的回掉\n   */\n  handleSubmit(value, cb) {\n    const { action, commentId, replyId, callback } = this.props;\n    if (action === 'comment') {\n      this.props.app.sCreateComment(\n        {\n          content: value,\n        },\n        cb\n      );\n    } else if (action === 'reply') {\n      this.props.app.sCreateReply(\n        {\n          comment_id: commentId,\n          content: value,\n        },\n        () => callback && callback()\n      );\n    } else if (action === 'replyToReply') {\n      this.props.app.sCreateReply(\n        {\n          comment_id: commentId,\n          content: value,\n          reply_id: replyId,\n        },\n        () => callback && callback()\n      );\n    }\n  }\n\n  render() {\n    const childrenWithProps = React.Children.map(this.props.content, child => {\n      return React.cloneElement(child, {\n        // 编辑器本身不提交值,但 CommentInput 会提交\n        // CommentInput 主要是负责评论的业务逻辑,提交评论和回复\n        // 默认使用 CommentInput 的 onSubmit 来提交评论\n        // 但也可以使用 Editor 的 props 来覆盖 onSubmit\n        onSubmit: this.handleSubmit,\n        ...child.props,\n        // 如果当前的编辑器不是“评论”,则编辑器高度减小一些\n        rows:\n          this.props.action === 'comment'\n            ? child.props.rows\n            : child.props.rows - 1,\n      });\n    });\n\n    return <div>{childrenWithProps}</div>;\n  }\n}\n\nCommentInput.propTypes = {\n  // comment 评论\n  // reply 评论的回复\n  // replyToReply 回复的回复\n  action: PropTypes.oneOf(['comment', 'reply', 'replyToReply']),\n};\n\nCommentInput.defaultProps = {\n  action: 'comment',\n};\n\nexport default Comment(CommentInput);\n"]}

+ 17
- 17
lib/components/CommentList/index.js View File

@@ -1,30 +1,30 @@
1
-"use strict";
1
+'use strict';
2 2
 
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
5 5
 });
6 6
 
7
-var _spin = require("antd/es/spin");
7
+var _spin = require('antd/es/spin');
8 8
 
9 9
 var _spin2 = _interopRequireDefault(_spin);
10 10
 
11 11
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
12 12
 
13
-require("antd/es/spin/style/css");
13
+require('antd/es/spin/style/css');
14 14
 
15
-var _react = require("react");
15
+var _react = require('react');
16 16
 
17 17
 var _react2 = _interopRequireDefault(_react);
18 18
 
19
-var _Comment = require("../../Comment");
19
+var _Comment = require('../../Comment');
20 20
 
21 21
 var _Comment2 = _interopRequireDefault(_Comment);
22 22
 
23
-var _CommentBox = require("../CommentBox");
23
+var _CommentBox = require('../CommentBox');
24 24
 
25 25
 var _CommentBox2 = _interopRequireDefault(_CommentBox);
26 26
 
27
-require("./index.css");
27
+require('./index.css');
28 28
 
29 29
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30 30
 
@@ -47,12 +47,12 @@ var CommentList = function (_Component) {
47 47
   }
48 48
 
49 49
   _createClass(CommentList, [{
50
-    key: "componentWillMount",
50
+    key: 'componentWillMount',
51 51
     value: function componentWillMount() {
52 52
       this.props.app.sGetComment();
53 53
     }
54 54
   }, {
55
-    key: "render",
55
+    key: 'render',
56 56
     value: function render() {
57 57
       var _props$app = this.props.app,
58 58
           list = _props$app.list,
@@ -65,33 +65,33 @@ var CommentList = function (_Component) {
65 65
 
66 66
       var spinning = Boolean(loading.sGetComment || loading.sCommentFavor || loading.sReplyFavor);
67 67
       return _react2.default.createElement(
68
-        "div",
68
+        'div',
69 69
         null,
70 70
         _react2.default.createElement(
71 71
           _spin2.default,
72 72
           { spinning: spinning },
73 73
           _react2.default.createElement(
74
-            "div",
74
+            'div',
75 75
             null,
76
-            "\u5171 ",
76
+            '\u5171 ',
77 77
             total,
78
-            " \u6761\u8BC4\u8BBA"
78
+            ' \u6761\u8BC4\u8BBA'
79 79
           ),
80 80
           list.map(function (item) {
81 81
             return _react2.default.createElement(_CommentBox2.default, { content: item, key: item.id, commentId: item.id });
82 82
           }),
83 83
           !isNoMoreComment && list.length !== total && _react2.default.createElement(
84
-            "div",
84
+            'div',
85 85
             {
86
-              className: "comment-list-show-more",
86
+              className: 'comment-list-show-more',
87 87
               onClick: function onClick() {
88 88
                 return sGetComment({ page: page + 1 });
89 89
               }
90 90
             },
91 91
             _react2.default.createElement(
92
-              "span",
92
+              'span',
93 93
               null,
94
-              "\u67E5\u770B\u66F4\u591A\u8BC4\u8BBA"
94
+              '\u67E5\u770B\u66F4\u591A\u8BC4\u8BBA'
95 95
             )
96 96
           )
97 97
         )

+ 1
- 1
lib/components/CommentList/index.js.map View File

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

+ 3
- 0
lib/components/ContentItem/index.css View File

@@ -29,6 +29,9 @@
29 29
   margin-left: 5px;
30 30
   cursor: pointer;
31 31
 }
32
+.comment-favor {
33
+  font-size: 20px;
34
+}
32 35
 .comment-favored {
33 36
   color: #4a90e2;
34 37
 }

+ 55
- 55
lib/components/ContentItem/index.js View File

@@ -1,62 +1,62 @@
1
-"use strict";
1
+'use strict';
2 2
 
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
5 5
 });
6 6
 
7
-var _icon = require("antd/es/icon");
7
+var _icon = require('antd/es/icon');
8 8
 
9 9
 var _icon2 = _interopRequireDefault(_icon);
10 10
 
11
-var _tooltip = require("antd/es/tooltip");
11
+var _tooltip = require('antd/es/tooltip');
12 12
 
13 13
 var _tooltip2 = _interopRequireDefault(_tooltip);
14 14
 
15
-var _avatar = require("antd/es/avatar");
15
+var _avatar = require('antd/es/avatar');
16 16
 
17 17
 var _avatar2 = _interopRequireDefault(_avatar);
18 18
 
19 19
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
20 20
 
21
-require("antd/es/icon/style/css");
21
+require('antd/es/icon/style/css');
22 22
 
23
-require("antd/es/tooltip/style/css");
23
+require('antd/es/tooltip/style/css');
24 24
 
25
-require("antd/es/avatar/style/css");
25
+require('antd/es/avatar/style/css');
26 26
 
27
-var _react = require("react");
27
+var _react = require('react');
28 28
 
29 29
 var _react2 = _interopRequireDefault(_react);
30 30
 
31
-var _propTypes = require("prop-types");
31
+var _propTypes = require('prop-types');
32 32
 
33 33
 var _propTypes2 = _interopRequireDefault(_propTypes);
34 34
 
35
-var _dayjs = require("dayjs");
35
+var _dayjs = require('dayjs');
36 36
 
37 37
 var _dayjs2 = _interopRequireDefault(_dayjs);
38 38
 
39
-require("dayjs/locale/zh-cn");
39
+require('dayjs/locale/zh-cn');
40 40
 
41
-var _relativeTime = require("dayjs/plugin/relativeTime");
41
+var _relativeTime = require('dayjs/plugin/relativeTime');
42 42
 
43 43
 var _relativeTime2 = _interopRequireDefault(_relativeTime);
44 44
 
45
-var _Comment = require("../../Comment");
45
+var _Comment = require('../../Comment');
46 46
 
47 47
 var _Comment2 = _interopRequireDefault(_Comment);
48 48
 
49
-var _CommentInput = require("../CommentInput");
49
+var _CommentInput = require('../CommentInput');
50 50
 
51 51
 var _CommentInput2 = _interopRequireDefault(_CommentInput);
52 52
 
53
-var _avatar3 = require("../../avatar");
53
+var _avatar3 = require('../../avatar');
54 54
 
55 55
 var _avatar4 = _interopRequireDefault(_avatar3);
56 56
 
57
-var _helper = require("../../helper");
57
+var _helper = require('../../helper');
58 58
 
59
-require("./index.css");
59
+require('./index.css');
60 60
 
61 61
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
62 62
 
@@ -66,7 +66,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
66 66
 
67 67
 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; }
68 68
 
69
-_dayjs2.default.locale("zh-cn");
69
+_dayjs2.default.locale('zh-cn');
70 70
 _dayjs2.default.extend(_relativeTime2.default);
71 71
 
72 72
 var CommentItem = function (_Component) {
@@ -86,18 +86,18 @@ var CommentItem = function (_Component) {
86 86
   }
87 87
 
88 88
   _createClass(CommentItem, [{
89
-    key: "handleToggleInput",
89
+    key: 'handleToggleInput',
90 90
     value: function handleToggleInput() {
91 91
       this.setState({ showInput: !this.state.showInput });
92 92
     }
93 93
   }, {
94
-    key: "renderTextWithReply",
94
+    key: 'renderTextWithReply',
95 95
     value: function renderTextWithReply(text, content) {
96 96
       var newText = text;
97 97
       var reply = content.reply;
98 98
 
99 99
       if (reply) {
100
-        newText = newText + " //@<a href=\"/" + reply.user_id + "\">" + reply.user_name + "</a> " + reply.content;
100
+        newText = newText + ' //@<a href="/' + reply.user_id + '">' + reply.user_name + '</a> ' + reply.content;
101 101
         if (reply.reply) {
102 102
           return this.renderTextWithReply(newText, reply);
103 103
         }
@@ -105,7 +105,7 @@ var CommentItem = function (_Component) {
105 105
       return newText;
106 106
     }
107 107
   }, {
108
-    key: "render",
108
+    key: 'render',
109 109
     value: function render() {
110 110
       var _props = this.props,
111 111
           commentId = _props.commentId,
@@ -119,69 +119,69 @@ var CommentItem = function (_Component) {
119 119
 
120 120
 
121 121
       return _react2.default.createElement(
122
-        "div",
123
-        { className: "comment-item-box" },
122
+        'div',
123
+        { className: 'comment-item-box' },
124 124
         _react2.default.createElement(
125
-          "div",
126
-          { className: "comment-item-left" },
127
-          _react2.default.createElement(_avatar2.default, { src: content.user_avatar || _avatar4.default, size: "large" })
125
+          'div',
126
+          { className: 'comment-item-left' },
127
+          _react2.default.createElement(_avatar2.default, { src: content.user_avatar || _avatar4.default, size: 'large' })
128 128
         ),
129 129
         _react2.default.createElement(
130
-          "div",
131
-          { className: "comment-item-right" },
130
+          'div',
131
+          { className: 'comment-item-right' },
132 132
           _react2.default.createElement(
133
-            "div",
133
+            'div',
134 134
             null,
135 135
             _react2.default.createElement(
136
-              "a",
137
-              { href: "/" + content.user_id },
138
-              content.user_name || "暂无昵称"
136
+              'a',
137
+              { href: '/' + content.user_id },
138
+              content.user_name || '暂无昵称'
139 139
             ),
140 140
             _react2.default.createElement(
141
-              "span",
141
+              'span',
142 142
               { style: { marginLeft: 10 } },
143 143
               _react2.default.createElement(
144 144
                 _tooltip2.default,
145 145
                 {
146
-                  placement: "top",
147
-                  title: (0, _dayjs2.default)(content.created * 1000).format("YYYY-MM-DD HH:mm:ss")
146
+                  placement: 'top',
147
+                  title: (0, _dayjs2.default)(content.created * 1000).format('YYYY-MM-DD HH:mm:ss')
148 148
                 },
149 149
                 (0, _dayjs2.default)(content.created * 1000).fromNow()
150 150
               )
151 151
             )
152 152
           ),
153
-          _react2.default.createElement("div", {
154
-            className: "comment-item-content",
153
+          _react2.default.createElement('div', {
154
+            className: 'comment-item-content',
155 155
             dangerouslySetInnerHTML: {
156 156
               __html: (0, _helper.renderContent)(this.renderTextWithReply(content.content, content))
157 157
             }
158 158
           }),
159 159
           _react2.default.createElement(
160
-            "div",
161
-            { className: "comment-item-bottom" },
160
+            'div',
161
+            { className: 'comment-item-bottom' },
162 162
             content.reply_count ? _react2.default.createElement(
163
-              "div",
163
+              'div',
164 164
               null,
165 165
               _react2.default.createElement(
166
-                "a",
167
-                { className: "comment-item-bottom-left", onClick: onShowReply },
166
+                'a',
167
+                { className: 'comment-item-bottom-left', onClick: onShowReply },
168 168
                 content.reply_count,
169
-                " \u6761\u56DE\u590D",
170
-                showReply ? _react2.default.createElement(_icon2.default, { type: "up" }) : _react2.default.createElement(_icon2.default, { type: "down" })
169
+                ' \u6761\u56DE\u590D',
170
+                showReply ? _react2.default.createElement(_icon2.default, { type: 'up' }) : _react2.default.createElement(_icon2.default, { type: 'down' })
171 171
               )
172 172
             ) : null,
173 173
             _react2.default.createElement(
174
-              "a",
174
+              'a',
175 175
               {
176 176
                 onClick: this.handleToggleInput,
177
-                className: "comment-item-bottom-right"
177
+                className: 'comment-item-bottom-right'
178 178
               },
179
-              "\xA0 \u56DE\u590D"
179
+              '\xA0 \u56DE\u590D'
180 180
             ),
181 181
             _react2.default.createElement(
182
-              "div",
182
+              'div',
183 183
               {
184
-                className: "comment-item-bottom-right",
184
+                className: 'comment-item-bottom-right',
185 185
                 onClick: function onClick() {
186 186
                   if (replyId) {
187 187
                     // 如果有 replyId,则说明是评论的回复
@@ -192,10 +192,10 @@ var CommentItem = function (_Component) {
192 192
                 }
193 193
               },
194 194
               _react2.default.createElement(_icon2.default, {
195
-                type: "like-o",
196
-                className: content.favored ? "comment-favored" : ""
195
+                type: 'like-o',
196
+                className: content.favored ? 'comment-favor comment-favored' : 'comment-favor'
197 197
               }),
198
-              "\xA0",
198
+              '\xA0',
199 199
               content.favor_count
200 200
             )
201 201
           )
@@ -219,12 +219,12 @@ CommentItem.propTypes = {
219 219
   // comment 评论
220 220
   // reply 评论的回复
221 221
   // replyToReply 回复的回复
222
-  action: _propTypes2.default.oneOf(["comment", "reply", "replyToReply"]),
222
+  action: _propTypes2.default.oneOf(['comment', 'reply', 'replyToReply']),
223 223
   onShowReply: _propTypes2.default.func
224 224
 };
225 225
 
226 226
 CommentItem.defaultProps = {
227
-  action: "comment",
227
+  action: 'comment',
228 228
   onShowReply: function onShowReply() {}
229 229
 };
230 230
 

+ 1
- 1
lib/components/ContentItem/index.js.map
File diff suppressed because it is too large
View File


+ 27
- 27
lib/components/Editor/Emoji.js View File

@@ -1,24 +1,24 @@
1
-"use strict";
1
+'use strict';
2 2
 
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
5 5
 });
6 6
 
7
-var _carousel = require("antd/es/carousel");
7
+var _carousel = require('antd/es/carousel');
8 8
 
9 9
 var _carousel2 = _interopRequireDefault(_carousel);
10 10
 
11
-require("antd/es/carousel/style/css");
11
+require('antd/es/carousel/style/css');
12 12
 
13
-var _react = require("react");
13
+var _react = require('react');
14 14
 
15 15
 var _react2 = _interopRequireDefault(_react);
16 16
 
17
-var _emoji = require("../../emoji");
17
+var _emoji = require('../../emoji');
18 18
 
19 19
 var _emoji2 = _interopRequireDefault(_emoji);
20 20
 
21
-require("./Emoji.css");
21
+require('./Emoji.css');
22 22
 
23 23
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 24
 
@@ -45,17 +45,17 @@ var Emoji = function Emoji(_ref) {
45 45
     _carousel2.default,
46 46
     null,
47 47
     _react2.default.createElement(
48
-      "div",
48
+      'div',
49 49
       null,
50 50
       content[0].map(function (item, index) {
51 51
         return _react2.default.createElement(
52
-          "div",
53
-          { className: "item", key: item.value },
54
-          _react2.default.createElement("span", { className: "helper" }),
55
-          _react2.default.createElement("img", {
56
-            src: "" + _emoji.prefixUrl + item.value + "." + _emoji.ext,
52
+          'div',
53
+          { className: 'item', key: item.value },
54
+          _react2.default.createElement('span', { className: 'helper' }),
55
+          _react2.default.createElement('img', {
56
+            src: '' + _emoji.prefixUrl + item.value + '.' + _emoji.ext,
57 57
             alt: item.title,
58
-            style: { display: "inline-block" },
58
+            style: { display: 'inline-block' },
59 59
             onClick: function onClick() {
60 60
               return _onClick(item.title);
61 61
             }
@@ -64,17 +64,17 @@ var Emoji = function Emoji(_ref) {
64 64
       })
65 65
     ),
66 66
     _react2.default.createElement(
67
-      "div",
67
+      'div',
68 68
       null,
69 69
       content[1].map(function (item, index) {
70 70
         return _react2.default.createElement(
71
-          "div",
72
-          { className: "item", key: item.value },
73
-          _react2.default.createElement("span", { className: "helper" }),
74
-          _react2.default.createElement("img", {
75
-            src: "" + _emoji.prefixUrl + item.value + "." + _emoji.ext,
71
+          'div',
72
+          { className: 'item', key: item.value },
73
+          _react2.default.createElement('span', { className: 'helper' }),
74
+          _react2.default.createElement('img', {
75
+            src: '' + _emoji.prefixUrl + item.value + '.' + _emoji.ext,
76 76
             alt: item.title,
77
-            style: { display: "inline-block" },
77
+            style: { display: 'inline-block' },
78 78
             onClick: function onClick() {
79 79
               return _onClick(item.title);
80 80
             }
@@ -83,17 +83,17 @@ var Emoji = function Emoji(_ref) {
83 83
       })
84 84
     ),
85 85
     _react2.default.createElement(
86
-      "div",
86
+      'div',
87 87
       null,
88 88
       content[2].map(function (item) {
89 89
         return _react2.default.createElement(
90
-          "div",
91
-          { className: "item", key: item.value },
92
-          _react2.default.createElement("span", { className: "helper" }),
93
-          _react2.default.createElement("img", {
94
-            src: "" + _emoji.prefixUrl + item.value + "." + _emoji.ext,
90
+          'div',
91
+          { className: 'item', key: item.value },
92
+          _react2.default.createElement('span', { className: 'helper' }),
93
+          _react2.default.createElement('img', {
94
+            src: '' + _emoji.prefixUrl + item.value + '.' + _emoji.ext,
95 95
             alt: item.title,
96
-            style: { display: "inline-block" },
96
+            style: { display: 'inline-block' },
97 97
             onClick: function onClick() {
98 98
               return _onClick(item.title);
99 99
             }

+ 1
- 1
lib/components/Editor/Emoji.js.map View File

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

+ 32
- 32
lib/components/Editor/Upload.js View File

@@ -1,54 +1,54 @@
1
-"use strict";
1
+'use strict';
2 2
 
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
5 5
 });
6 6
 
7
-var _modal = require("antd/es/modal");
7
+var _modal = require('antd/es/modal');
8 8
 
9 9
 var _modal2 = _interopRequireDefault(_modal);
10 10
 
11
-var _upload = require("antd/es/upload");
11
+var _upload = require('antd/es/upload');
12 12
 
13 13
 var _upload2 = _interopRequireDefault(_upload);
14 14
 
15
-var _icon = require("antd/es/icon");
15
+var _icon = require('antd/es/icon');
16 16
 
17 17
 var _icon2 = _interopRequireDefault(_icon);
18 18
 
19
-var _message2 = require("antd/es/message");
19
+var _message2 = require('antd/es/message');
20 20
 
21 21
 var _message3 = _interopRequireDefault(_message2);
22 22
 
23 23
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
24 24
 
25
-require("antd/es/modal/style/css");
25
+require('antd/es/modal/style/css');
26 26
 
27
-require("antd/es/upload/style/css");
27
+require('antd/es/upload/style/css');
28 28
 
29
-require("antd/es/icon/style/css");
29
+require('antd/es/icon/style/css');
30 30
 
31
-require("antd/es/message/style/css");
31
+require('antd/es/message/style/css');
32 32
 
33
-var _react = require("react");
33
+var _react = require('react');
34 34
 
35 35
 var _react2 = _interopRequireDefault(_react);
36 36
 
37
-var _dayjs = require("dayjs");
37
+var _dayjs = require('dayjs');
38 38
 
39 39
 var _dayjs2 = _interopRequireDefault(_dayjs);
40 40
 
41
-var _shortid = require("shortid");
41
+var _shortid = require('shortid');
42 42
 
43 43
 var _shortid2 = _interopRequireDefault(_shortid);
44 44
 
45
-var _constant = require("../../constant");
45
+var _constant = require('../../constant');
46 46
 
47
-var _Comment = require("../../Comment");
47
+var _Comment = require('../../Comment');
48 48
 
49 49
 var _Comment2 = _interopRequireDefault(_Comment);
50 50
 
51
-require("./Upload.css");
51
+require('./Upload.css');
52 52
 
53 53
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
54 54
 
@@ -69,7 +69,7 @@ var client = function client(oss) {
69 69
 };
70 70
 
71 71
 var uploadPath = function uploadPath(path, file) {
72
-  return path + "/" + (0, _dayjs2.default)().format("YYYYMMDD") + "/" + _shortid2.default.generate() + "." + file.type.split("/")[1];
72
+  return path + '/' + (0, _dayjs2.default)().format('YYYYMMDD') + '/' + _shortid2.default.generate() + '.' + file.type.split('/')[1];
73 73
 };
74 74
 
75 75
 var UploadToOss = function UploadToOss(oss, path, file) {
@@ -93,7 +93,7 @@ var App = function (_React$Component) {
93 93
 
94 94
     _this.state = {
95 95
       previewVisible: false,
96
-      previewImage: ""
96
+      previewImage: ''
97 97
     };
98 98
     _this.handleCancel = _this.handleCancel.bind(_this);
99 99
     _this.handlePreview = _this.handlePreview.bind(_this);
@@ -103,17 +103,17 @@ var App = function (_React$Component) {
103 103
   }
104 104
 
105 105
   _createClass(App, [{
106
-    key: "componentDidMount",
106
+    key: 'componentDidMount',
107 107
     value: function componentDidMount() {
108 108
       this.props.app.sOssSts();
109 109
     }
110 110
   }, {
111
-    key: "handleCancel",
111
+    key: 'handleCancel',
112 112
     value: function handleCancel() {
113 113
       this.setState({ previewVisible: false });
114 114
     }
115 115
   }, {
116
-    key: "handlePreview",
116
+    key: 'handlePreview',
117 117
     value: function handlePreview(file) {
118 118
       this.setState({
119 119
         previewImage: file.url || file.thumbUrl,
@@ -121,14 +121,14 @@ var App = function (_React$Component) {
121 121
       });
122 122
     }
123 123
   }, {
124
-    key: "handleChange",
124
+    key: 'handleChange',
125 125
     value: function handleChange(_ref) {
126 126
       var fileList = _ref.fileList;
127 127
 
128 128
       this.props.onChangeFileList(fileList);
129 129
     }
130 130
   }, {
131
-    key: "customRequest",
131
+    key: 'customRequest',
132 132
     value: function customRequest(info) {
133 133
       var _this2 = this;
134 134
 
@@ -151,7 +151,7 @@ var App = function (_React$Component) {
151 151
       };
152 152
     }
153 153
   }, {
154
-    key: "render",
154
+    key: 'render',
155 155
     value: function render() {
156 156
       var _state = this.state,
157 157
           previewVisible = _state.previewVisible,
@@ -159,23 +159,23 @@ var App = function (_React$Component) {
159 159
       var fileList = this.props.fileList;
160 160
 
161 161
       var uploadButton = _react2.default.createElement(
162
-        "div",
162
+        'div',
163 163
         null,
164
-        _react2.default.createElement(_icon2.default, { type: "plus" }),
164
+        _react2.default.createElement(_icon2.default, { type: 'plus' }),
165 165
         _react2.default.createElement(
166
-          "div",
167
-          { className: "ant-upload-text" },
168
-          "\u4E0A\u4F20"
166
+          'div',
167
+          { className: 'ant-upload-text' },
168
+          '\u4E0A\u4F20'
169 169
         )
170 170
       );
171 171
       return _react2.default.createElement(
172
-        "div",
172
+        'div',
173 173
         null,
174 174
         _react2.default.createElement(
175 175
           _upload2.default,
176 176
           {
177
-            accept: "image/jpg,image/jpeg,image/png,image/bmp",
178
-            listType: "picture-card",
177
+            accept: 'image/jpg,image/jpeg,image/png,image/bmp',
178
+            listType: 'picture-card',
179 179
             fileList: fileList,
180 180
             customRequest: this.customRequest,
181 181
             onPreview: this.handlePreview,
@@ -190,7 +190,7 @@ var App = function (_React$Component) {
190 190
             footer: null,
191 191
             onCancel: this.handleCancel
192 192
           },
193
-          _react2.default.createElement("img", { alt: "upload", style: { width: "100%" }, src: previewImage })
193
+          _react2.default.createElement('img', { alt: 'upload', style: { width: '100%' }, src: previewImage })
194 194
         )
195 195
       );
196 196
     }

+ 1
- 1
lib/components/Editor/Upload.js.map
File diff suppressed because it is too large
View File


+ 1
- 1
lib/components/Editor/index.css View File

@@ -30,7 +30,7 @@
30 30
   box-shadow: none;
31 31
   border-bottom: 1px solid #eee;
32 32
 }
33
-.comment-editor [contentEditable="true"]:empty:not(:focus):before {
33
+.comment-editor [contentEditable='true']:empty:not(:focus):before {
34 34
   content: attr(data-text);
35 35
   color: #bfbfbf;
36 36
 }

+ 78
- 69
lib/components/Editor/index.js View File

@@ -1,54 +1,54 @@
1
-"use strict";
1
+'use strict';
2 2
 
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
5 5
 });
6 6
 
7
-var _button = require("antd/es/button");
7
+var _button = require('antd/es/button');
8 8
 
9 9
 var _button2 = _interopRequireDefault(_button);
10 10
 
11
-var _popover = require("antd/es/popover");
11
+var _popover = require('antd/es/popover');
12 12
 
13 13
 var _popover2 = _interopRequireDefault(_popover);
14 14
 
15
-var _icon = require("antd/es/icon");
15
+var _icon = require('antd/es/icon');
16 16
 
17 17
 var _icon2 = _interopRequireDefault(_icon);
18 18
 
19
-var _input = require("antd/es/input");
19
+var _input = require('antd/es/input');
20 20
 
21 21
 var _input2 = _interopRequireDefault(_input);
22 22
 
23 23
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
24 24
 
25
-require("antd/es/button/style/css");
25
+require('antd/es/button/style/css');
26 26
 
27
-require("antd/es/popover/style/css");
27
+require('antd/es/popover/style/css');
28 28
 
29
-require("antd/es/icon/style/css");
29
+require('antd/es/icon/style/css');
30 30
 
31
-require("antd/es/input/style/css");
31
+require('antd/es/input/style/css');
32 32
 
33
-var _react = require("react");
33
+var _react = require('react');
34 34
 
35 35
 var _react2 = _interopRequireDefault(_react);
36 36
 
37
-var _propTypes = require("prop-types");
37
+var _propTypes = require('prop-types');
38 38
 
39 39
 var _propTypes2 = _interopRequireDefault(_propTypes);
40 40
 
41
-var _constant = require("../../constant");
41
+var _constant = require('../../constant');
42 42
 
43
-var _Upload = require("./Upload");
43
+var _Upload = require('./Upload');
44 44
 
45 45
 var _Upload2 = _interopRequireDefault(_Upload);
46 46
 
47
-var _Emoji = require("./Emoji");
47
+var _Emoji = require('./Emoji');
48 48
 
49 49
 var _Emoji2 = _interopRequireDefault(_Emoji);
50 50
 
51
-require("./index.css");
51
+require('./index.css');
52 52
 
53 53
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
54 54
 
@@ -70,7 +70,7 @@ var Editor = function (_React$Component) {
70 70
 
71 71
     _this.state = {
72 72
       showUpload: false,
73
-      value: "", // 编辑器里面的值
73
+      value: '', // 编辑器里面的值
74 74
 
75 75
       fileList: [], // 图片列表
76 76
       fileMap: {} // 已经上传的图片路径和 uid 的映射 { uid: path }
@@ -85,7 +85,7 @@ var Editor = function (_React$Component) {
85 85
   }
86 86
 
87 87
   _createClass(Editor, [{
88
-    key: "componentDidMount",
88
+    key: 'componentDidMount',
89 89
     value: function componentDidMount() {}
90 90
 
91 91
     /**
@@ -95,7 +95,7 @@ var Editor = function (_React$Component) {
95 95
      */
96 96
 
97 97
   }, {
98
-    key: "handleChange",
98
+    key: 'handleChange',
99 99
     value: function handleChange(value) {
100 100
       this.setState({ value: value });
101 101
       if (this.props.onChange) {
@@ -112,11 +112,11 @@ var Editor = function (_React$Component) {
112 112
      */
113 113
 
114 114
   }, {
115
-    key: "handleClickEmoji",
115
+    key: 'handleClickEmoji',
116 116
     value: function handleClickEmoji(emoji) {
117 117
       var value = this.state.value;
118 118
 
119
-      value += "[" + emoji + "]";
119
+      value += '[' + emoji + ']';
120 120
       this.handleChange(value);
121 121
     }
122 122
 
@@ -126,7 +126,7 @@ var Editor = function (_React$Component) {
126 126
      */
127 127
 
128 128
   }, {
129
-    key: "handleChangeFileList",
129
+    key: 'handleChangeFileList',
130 130
     value: function handleChangeFileList(fileList) {
131 131
       this.setState({ fileList: fileList });
132 132
     }
@@ -137,9 +137,9 @@ var Editor = function (_React$Component) {
137 137
      */
138 138
 
139 139
   }, {
140
-    key: "handleShowUpload",
140
+    key: 'handleShowUpload',
141 141
     value: function handleShowUpload(showUpload) {
142
-      if (typeof showUpload === "boolean") {
142
+      if (typeof showUpload === 'boolean') {
143 143
         this.setState({ showUpload: showUpload });
144 144
       } else {
145 145
         this.setState({ showUpload: !this.state.showUpload });
@@ -147,12 +147,12 @@ var Editor = function (_React$Component) {
147 147
     }
148 148
 
149 149
     /**
150
-     * 上传文件 TODO:
150
+     * 上传文件
151 151
      * @param {object} param 文件对象
152 152
      */
153 153
 
154 154
   }, {
155
-    key: "handleUpload",
155
+    key: 'handleUpload',
156 156
     value: function handleUpload(_ref) {
157 157
       var uid = _ref.uid,
158 158
           path = _ref.path;
@@ -169,25 +169,34 @@ var Editor = function (_React$Component) {
169 169
      */
170 170
 
171 171
   }, {
172
-    key: "handleSubmit",
172
+    key: 'handleSubmit',
173 173
     value: function handleSubmit() {
174
+      var _this2 = this;
175
+
174 176
       var _state = this.state,
175 177
           value = _state.value,
176 178
           fileMap = _state.fileMap,
177 179
           fileList = _state.fileList;
178 180
 
179 181
       if (fileList.length) {
180
-        value += "<br/>";
182
+        value += '<br/>';
181 183
         fileList.forEach(function (item) {
182
-          value += "[" + _constant.OSS_LINK + fileMap[item.uid] + "]";
184
+          value += '[' + _constant.OSS_LINK + fileMap[item.uid] + ']';
183 185
         });
184 186
       }
185
-      this.props.onSubmit(value);
187
+      this.props.onSubmit(value, function () {
188
+        _this2.setState({
189
+          showUpload: false,
190
+          value: '',
191
+          fileList: [],
192
+          fileMap: {}
193
+        });
194
+      });
186 195
     }
187 196
   }, {
188
-    key: "render",
197
+    key: 'render',
189 198
     value: function render() {
190
-      var _this2 = this;
199
+      var _this3 = this;
191 200
 
192 201
       var _props = this.props,
193 202
           value = _props.value,
@@ -202,39 +211,39 @@ var Editor = function (_React$Component) {
202 211
           emojiToolIcon = _props.emojiToolIcon,
203 212
           imageToolIcon = _props.imageToolIcon;
204 213
 
205
-
206 214
       var handleSubmit = this.handleSubmit;
215
+      var disabledSubmit = btnDisabled || !this.props.value && !this.state.value && !this.state.fileList.length;
207 216
       return _react2.default.createElement(
208
-        "div",
209
-        { className: "comment-editor" },
217
+        'div',
218
+        { className: 'comment-editor' },
210 219
         _react2.default.createElement(TextArea, {
211 220
           value: value || this.state.value,
212 221
           onChange: function onChange(e) {
213
-            return _this2.handleChange(e.target.value);
222
+            return _this3.handleChange(e.target.value);
214 223
           },
215 224
           rows: rows,
216 225
           placeholder: placeholder
217 226
         }),
218 227
         _react2.default.createElement(
219
-          "div",
220
-          { className: "comment-toolbar" },
228
+          'div',
229
+          { className: 'comment-toolbar' },
221 230
           _react2.default.createElement(
222
-            "div",
223
-            { className: "comment-toolbar-left" },
231
+            'div',
232
+            { className: 'comment-toolbar-left' },
224 233
             showEmoji && _react2.default.createElement(
225 234
               _popover2.default,
226 235
               {
227
-                trigger: "click",
228
-                placement: "bottomLeft",
236
+                trigger: 'click',
237
+                placement: 'bottomLeft',
229 238
                 autoAdjustOverflow: false,
230 239
                 content: _react2.default.createElement(
231
-                  "div",
240
+                  'div',
232 241
                   { style: { width: 200 } },
233 242
                   _react2.default.createElement(_Emoji2.default, { onClick: this.handleClickEmoji })
234 243
                 ),
235
-                overlayClassName: "comment-emoji-popover"
244
+                overlayClassName: 'comment-emoji-popover'
236 245
               },
237
-              emojiToolIcon || _react2.default.createElement(_icon2.default, { type: "smile-o", className: "comment-toolbar-icon" })
246
+              emojiToolIcon || _react2.default.createElement(_icon2.default, { type: 'smile-o', className: 'comment-toolbar-icon' })
238 247
             ),
239 248
             showUpload && _react2.default.createElement(
240 249
               _popover2.default,
@@ -242,7 +251,7 @@ var Editor = function (_React$Component) {
242 251
                 visible: this.state.showUpload,
243 252
                 overlayStyle: { zIndex: 999 },
244 253
                 content: _react2.default.createElement(
245
-                  "div",
254
+                  'div',
246 255
                   {
247 256
                     style: { width: 112 * _constant.MAX_UPLOAD_NUMBER, minHeight: 100 }
248 257
                   },
@@ -252,30 +261,30 @@ var Editor = function (_React$Component) {
252 261
                     fileList: this.state.fileList
253 262
                   })
254 263
                 ),
255
-                placement: "bottomLeft",
264
+                placement: 'bottomLeft',
256 265
                 title: _react2.default.createElement(
257
-                  "div",
258
-                  { style: { margin: "5px auto" } },
266
+                  'div',
267
+                  { style: { margin: '5px auto' } },
259 268
                   _react2.default.createElement(
260
-                    "span",
269
+                    'span',
261 270
                     null,
262
-                    "\u4E0A\u4F20\u56FE\u7247",
271
+                    '\u4E0A\u4F20\u56FE\u7247',
263 272
                     _react2.default.createElement(
264
-                      "span",
265
-                      { style: { color: "#666", fontWeight: 400 } },
266
-                      "(\u60A8\u8FD8\u80FD\u4E0A\u4F20",
273
+                      'span',
274
+                      { style: { color: '#666', fontWeight: 400 } },
275
+                      '(\u60A8\u8FD8\u80FD\u4E0A\u4F20',
267 276
                       _constant.MAX_UPLOAD_NUMBER - this.state.fileList.length,
268
-                      "\u5F20\u56FE\u7247)"
277
+                      '\u5F20\u56FE\u7247)'
269 278
                     )
270 279
                   ),
271 280
                   _react2.default.createElement(_icon2.default, {
272
-                    type: "close",
281
+                    type: 'close',
273 282
                     onClick: function onClick() {
274
-                      return _this2.handleShowUpload(false);
283
+                      return _this3.handleShowUpload(false);
275 284
                     },
276 285
                     style: {
277
-                      float: "right",
278
-                      cursor: "pointer",
286
+                      float: 'right',
287
+                      cursor: 'pointer',
279 288
                       marginTop: 4
280 289
                     }
281 290
                   })
@@ -283,32 +292,32 @@ var Editor = function (_React$Component) {
283 292
               },
284 293
               imageToolIcon ? _react2.default.cloneElement(imageToolIcon, {
285 294
                 onClick: function onClick() {
286
-                  return _this2.handleShowUpload(true);
295
+                  return _this3.handleShowUpload(true);
287 296
                 }
288 297
               }) : _react2.default.createElement(_icon2.default, {
289
-                type: "picture",
290
-                className: "comment-toolbar-icon",
298
+                type: 'picture',
299
+                className: 'comment-toolbar-icon',
291 300
                 style: { marginLeft: 10 },
292 301
                 onClick: function onClick() {
293
-                  return _this2.handleShowUpload(true);
302
+                  return _this3.handleShowUpload(true);
294 303
                 }
295 304
               })
296 305
             )
297 306
           ),
298 307
           _react2.default.createElement(
299
-            "div",
300
-            { className: "comment-toolbar-right" },
308
+            'div',
309
+            { className: 'comment-toolbar-right' },
301 310
             button ? _react2.default.cloneElement(button, {
302 311
               onClick: button.props.onClick || handleSubmit
303 312
             }) : _react2.default.createElement(
304 313
               _button2.default,
305 314
               {
306 315
                 onClick: function onClick() {
307
-                  return _this2.handleSubmit();
316
+                  return _this3.handleSubmit();
308 317
                 },
309
-                type: "primary",
318
+                type: 'primary',
310 319
                 loading: btnLoading,
311
-                disabled: btnDisabled
320
+                disabled: disabledSubmit
312 321
               },
313 322
               btnSubmitText
314 323
             )
@@ -339,10 +348,10 @@ Editor.propTypes = {
339 348
 
340 349
 Editor.defaultProps = {
341 350
   rows: 5,
342
-  placeholder: "说点什么吧...",
351
+  placeholder: '说点什么吧...',
343 352
   showEmoji: true,
344 353
   showUpload: true,
345
-  btnSubmitText: "发表",
354
+  btnSubmitText: '发表',
346 355
   btnLoading: false,
347 356
   btnDisabled: false
348 357
 };

+ 1
- 1
lib/components/Editor/index.js.map
File diff suppressed because it is too large
View File


+ 7
- 7
lib/constant.js View File

@@ -1,21 +1,21 @@
1
-"use strict";
1
+'use strict';
2 2
 
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
5 5
 });
6
-var ERROR_DEFAULT = exports.ERROR_DEFAULT = "出错了!";
6
+var ERROR_DEFAULT = exports.ERROR_DEFAULT = '出错了!';
7 7
 
8 8
 var LIMIT = exports.LIMIT = 10; // 默认 limit
9 9
 
10
-var OSS_ENDPOINT = exports.OSS_ENDPOINT = "oss-cn-beijing.aliyuncs.com";
11
-var OSS_BUCKET = exports.OSS_BUCKET = "links-comment";
12
-var DRIVER_LICENSE_PATH = exports.DRIVER_LICENSE_PATH = "/comment";
10
+var OSS_ENDPOINT = exports.OSS_ENDPOINT = 'oss-cn-beijing.aliyuncs.com';
11
+var OSS_BUCKET = exports.OSS_BUCKET = 'links-comment';
12
+var DRIVER_LICENSE_PATH = exports.DRIVER_LICENSE_PATH = '/comment';
13 13
 
14
-var OSS_LINK = exports.OSS_LINK = "http://links-comment.oss-cn-beijing.aliyuncs.com";
14
+var OSS_LINK = exports.OSS_LINK = 'http://links-comment.oss-cn-beijing.aliyuncs.com';
15 15
 
16 16
 var MAX_UPLOAD_NUMBER = exports.MAX_UPLOAD_NUMBER = 4;
17 17
 
18 18
 var REGEXP = exports.REGEXP = /\[.+?\]/g;
19 19
 
20
-var AVATAR = exports.AVATAR = "";
20
+var AVATAR = exports.AVATAR = '';
21 21
 //# sourceMappingURL=constant.js.map

+ 1
- 1
lib/constant.js.map View File

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

+ 111
- 111
lib/emoji.js View File

@@ -1,175 +1,175 @@
1
-"use strict";
1
+'use strict';
2 2
 
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
5 5
 });
6 6
 var emoji = [{
7
-  value: "0",
8
-  title: "捶地"
7
+  value: '0',
8
+  title: '捶地'
9 9
 }, {
10
-  value: "1",
11
-  title: "怀疑"
10
+  value: '1',
11
+  title: '怀疑'
12 12
 }, {
13
-  value: "2",
14
-  title: "撇嘴"
13
+  value: '2',
14
+  title: '撇嘴'
15 15
 }, {
16
-  value: "3",
17
-  title: "色"
16
+  value: '3',
17
+  title: '色'
18 18
 }, {
19
-  value: "4",
20
-  title: "发呆"
19
+  value: '4',
20
+  title: '发呆'
21 21
 }, {
22
-  value: "5",
23
-  title: "酷"
22
+  value: '5',
23
+  title: '酷'
24 24
 }, {
25
-  value: "6",
26
-  title: "害羞"
25
+  value: '6',
26
+  title: '害羞'
27 27
 }, {
28
-  value: "7",
29
-  title: "闭嘴"
28
+  value: '7',
29
+  title: '闭嘴'
30 30
 }, {
31
-  value: "8",
32
-  title: "睡觉"
31
+  value: '8',
32
+  title: '睡觉'
33 33
 }, {
34
-  value: "9",
35
-  title: "大哭"
34
+  value: '9',
35
+  title: '大哭'
36 36
 }, {
37
-  value: "10",
38
-  title: "尴尬"
37
+  value: '10',
38
+  title: '尴尬'
39 39
 }, {
40
-  value: "11",
41
-  title: "发怒"
40
+  value: '11',
41
+  title: '发怒'
42 42
 }, {
43
-  value: "12",
44
-  title: "调皮"
43
+  value: '12',
44
+  title: '调皮'
45 45
 }, {
46
-  value: "13",
47
-  title: "呲牙"
46
+  value: '13',
47
+  title: '呲牙'
48 48
 }, {
49
-  value: "14",
50
-  title: "微笑"
49
+  value: '14',
50
+  title: '微笑'
51 51
 }, {
52
-  value: "15",
53
-  title: "难过"
52
+  value: '15',
53
+  title: '难过'
54 54
 }, {
55
-  value: "16",
56
-  title: "帅呆"
55
+  value: '16',
56
+  title: '帅呆'
57 57
 }, {
58
-  value: "17",
59
-  title: "折磨"
58
+  value: '17',
59
+  title: '折磨'
60 60
 }, {
61
-  value: "18",
62
-  title: "吐"
61
+  value: '18',
62
+  title: '吐'
63 63
 }, {
64
-  value: "19",
65
-  title: "偷笑"
64
+  value: '19',
65
+  title: '偷笑'
66 66
 }, {
67
-  value: "20",
68
-  title: "可爱"
67
+  value: '20',
68
+  title: '可爱'
69 69
 }, {
70
-  value: "21",
71
-  title: "白眼"
70
+  value: '21',
71
+  title: '白眼'
72 72
 }, {
73
-  value: "22",
74
-  title: "傲慢"
73
+  value: '22',
74
+  title: '傲慢'
75 75
 }, {
76
-  value: "23",
77
-  title: "嘴馋"
76
+  value: '23',
77
+  title: '嘴馋'
78 78
 }, {
79
-  value: "24",
80
-  title: "困"
79
+  value: '24',
80
+  title: '困'
81 81
 }, {
82
-  value: "25",
83
-  title: "恐慌"
82
+  value: '25',
83
+  title: '恐慌'
84 84
 }, {
85
-  value: "26",
86
-  title: "流汗"
85
+  value: '26',
86
+  title: '流汗'
87 87
 }, {
88
-  value: "27",
89
-  title: "憨笑"
88
+  value: '27',
89
+  title: '憨笑'
90 90
 }, {
91
-  value: "28",
92
-  title: "大兵"
91
+  value: '28',
92
+  title: '大兵'
93 93
 }, {
94
-  value: "29",
95
-  title: "奋斗"
94
+  value: '29',
95
+  title: '奋斗'
96 96
 }, {
97
-  value: "30",
98
-  title: "疑问"
97
+  value: '30',
98
+  title: '疑问'
99 99
 }, {
100
-  value: "31",
101
-  title: "嘘"
100
+  value: '31',
101
+  title: '嘘'
102 102
 }, {
103
-  value: "32",
104
-  title: "晕"
103
+  value: '32',
104
+  title: '晕'
105 105
 }, {
106
-  value: "33",
107
-  title: "被炸了"
106
+  value: '33',
107
+  title: '被炸了'
108 108
 }, {
109
-  value: "34",
110
-  title: "骷髅"
109
+  value: '34',
110
+  title: '骷髅'
111 111
 }, {
112
-  value: "35",
113
-  title: "敲打"
112
+  value: '35',
113
+  title: '敲打'
114 114
 }, {
115
-  value: "36",
116
-  title: "拜拜"
115
+  value: '36',
116
+  title: '拜拜'
117 117
 }, {
118
-  value: "37",
119
-  title: "发抖"
118
+  value: '37',
119
+  title: '发抖'
120 120
 }, {
121
-  value: "38",
122
-  title: "亲密"
121
+  value: '38',
122
+  title: '亲密'
123 123
 }, {
124
-  value: "39",
125
-  title: "跳"
124
+  value: '39',
125
+  title: '跳'
126 126
 }, {
127
-  value: "40",
128
-  title: "猪头"
127
+  value: '40',
128
+  title: '猪头'
129 129
 }, {
130
-  value: "41",
131
-  title: "拥抱"
130
+  value: '41',
131
+  title: '拥抱'
132 132
 }, {
133
-  value: "42",
134
-  title: "生日蛋糕"
133
+  value: '42',
134
+  title: '生日蛋糕'
135 135
 }, {
136
-  value: "43",
137
-  title: "闪电"
136
+  value: '43',
137
+  title: '闪电'
138 138
 }, {
139
-  value: "44",
140
-  title: "地雷"
139
+  value: '44',
140
+  title: '地雷'
141 141
 }, {
142
-  value: "45",
143
-  title: "刀"
142
+  value: '45',
143
+  title: '刀'
144 144
 }, {
145
-  value: "46",
146
-  title: "足球"
145
+  value: '46',
146
+  title: '足球'
147 147
 }, {
148
-  value: "47",
149
-  title: "便便"
148
+  value: '47',
149
+  title: '便便'
150 150
 }, {
151
-  value: "48",
152
-  title: "咖啡"
151
+  value: '48',
152
+  title: '咖啡'
153 153
 }, {
154
-  value: "49",
155
-  title: "米饭"
154
+  value: '49',
155
+  title: '米饭'
156 156
 }, {
157
-  value: "50",
158
-  title: "玫瑰"
157
+  value: '50',
158
+  title: '玫瑰'
159 159
 }, {
160
-  value: "51",
161
-  title: "枯萎玫瑰"
160
+  value: '51',
161
+  title: '枯萎玫瑰'
162 162
 }, {
163
-  value: "52",
164
-  title: "爱心"
163
+  value: '52',
164
+  title: '爱心'
165 165
 }, {
166
-  value: "53",
167
-  title: "心碎"
166
+  value: '53',
167
+  title: '心碎'
168 168
 }];
169 169
 
170
-var prefixUrl = exports.prefixUrl = "https://a.links123.cn/site/src/feed/imgs/qq/";
170
+var prefixUrl = exports.prefixUrl = 'https://a.links123.cn/site/src/feed/imgs/qq/';
171 171
 
172
-var ext = exports.ext = "gif";
172
+var ext = exports.ext = 'gif';
173 173
 
174 174
 exports.default = emoji;
175 175
 //# sourceMappingURL=emoji.js.map

+ 1
- 1
lib/emoji.js.map
File diff suppressed because it is too large
View File


+ 7
- 7
lib/helper.js View File

@@ -1,4 +1,4 @@
1
-"use strict";
1
+'use strict';
2 2
 
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
@@ -8,16 +8,16 @@ exports.isUrl = isUrl;
8 8
 exports.arrayToObject = arrayToObject;
9 9
 exports.renderContent = renderContent;
10 10
 
11
-var _constant = require("./constant");
11
+var _constant = require('./constant');
12 12
 
13
-var _emoji = require("./emoji");
13
+var _emoji = require('./emoji');
14 14
 
15 15
 var _emoji2 = _interopRequireDefault(_emoji);
16 16
 
17 17
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18 18
 
19 19
 function isFunction(functionToCheck) {
20
-  return functionToCheck && {}.toString.call(functionToCheck) === "[object Function]";
20
+  return functionToCheck && {}.toString.call(functionToCheck) === '[object Function]';
21 21
 }
22 22
 
23 23
 function isUrl(userInput) {
@@ -47,11 +47,11 @@ function renderContent(content, onClick) {
47 47
   return content.replace(_constant.REGEXP, function (a, b) {
48 48
     var src = a.slice(1, -1);
49 49
     if (isUrl(src)) {
50
-      return "<img src=\"" + src + "\" alt=\"" + src + "\" style=\"max-width: 300px\" />";
50
+      return '<img src="' + src + '" alt="' + src + '" style="max-width: 300px" />';
51 51
     }
52
-    var emojiObejct = arrayToObject(_emoji2.default, "title");
52
+    var emojiObejct = arrayToObject(_emoji2.default, 'title');
53 53
     var value = emojiObejct[src].value;
54
-    return "<img src=\"" + _emoji.prefixUrl + value + "." + _emoji.ext + "\" alt=\"" + value + "\" />";
54
+    return '<img src="' + _emoji.prefixUrl + value + '.' + _emoji.ext + '" alt="' + value + '" />';
55 55
   });
56 56
 }
57 57
 //# sourceMappingURL=helper.js.map

+ 1
- 1
lib/helper.js.map View File

@@ -1 +1 @@
1
-{"version":3,"sources":["../src/helper.js"],"names":["isFunction","isUrl","arrayToObject","renderContent","functionToCheck","toString","call","userInput","regexp","res","match","array","keyField","reduce","obj","item","content","onClick","replace","REGEXP","a","b","src","slice","emojiObejct","emoji","value","prefixUrl","ext"],"mappings":";;;;;QAGgBA,U,GAAAA,U;QAMAC,K,GAAAA,K;QAYAC,a,GAAAA,a;QAYAC,a,GAAAA,a;;AAjChB;;AACA;;;;;;AAEO,SAASH,UAAT,CAAoBI,eAApB,EAAqC;AAC1C,SACEA,mBAAmB,GAAGC,QAAH,CAAYC,IAAZ,CAAiBF,eAAjB,MAAsC,mBAD3D;AAGD;;AAEM,SAASH,KAAT,CAAeM,SAAf,EAA0B;AAC/B,MAAMC,SAAS,kGAAf;AACA,MAAIC,MAAMF,UAAUG,KAAV,CAAgBF,MAAhB,CAAV;AACA,MAAIC,QAAQ,IAAZ,EAAkB,OAAO,KAAP,CAAlB,KACK,OAAO,IAAP;AACN;;AAED;;;;;AAKO,SAASP,aAAT,CAAuBS,KAAvB,EAA8BC,QAA9B,EAAwC;AAC7C,SAAOD,MAAME,MAAN,CAAa,UAACC,GAAD,EAAMC,IAAN,EAAe;AACjCD,QAAIC,KAAKH,QAAL,CAAJ,IAAsBG,IAAtB;AACA,WAAOD,GAAP;AACD,GAHM,EAGJ,EAHI,CAAP;AAID;;AAED;;;;;AAKO,SAASX,aAAT,CAAuBa,OAAvB,EAAgCC,OAAhC,EAAyC;AAC9C,SAAOD,QAAQE,OAAR,CAAgBC,gBAAhB,EAAwB,UAASC,CAAT,EAAYC,CAAZ,EAAe;AAC5C,QAAMC,MAAMF,EAAEG,KAAF,CAAQ,CAAR,EAAW,CAAC,CAAZ,CAAZ;AACA,QAAItB,MAAMqB,GAAN,CAAJ,EAAgB;AACd,6BAAoBA,GAApB,iBAAiCA,GAAjC;AACD;AACD,QAAME,cAActB,cAAcuB,eAAd,EAAqB,OAArB,CAApB;AACA,QAAMC,QAAQF,YAAYF,GAAZ,EAAiBI,KAA/B;AACA,2BAAoBC,gBAApB,GAAgCD,KAAhC,SAAyCE,UAAzC,iBAAsDF,KAAtD;AACD,GARM,CAAP;AASD","file":"helper.js","sourcesContent":["import { REGEXP } from \"./constant\";\nimport emoji, { prefixUrl, ext } from \"./emoji\";\n\nexport function isFunction(functionToCheck) {\n  return (\n    functionToCheck && {}.toString.call(functionToCheck) === \"[object Function]\"\n  );\n}\n\nexport function isUrl(userInput) {\n  const regexp = /(http(s)?:\\/\\/.)?(www\\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/g;\n  var res = userInput.match(regexp);\n  if (res === null) return false;\n  else return true;\n}\n\n/**\n * 将对象数组转换为对象\n * @param {array} array Array of Objects\n * @param {string} keyField string\n */\nexport function arrayToObject(array, keyField) {\n  return array.reduce((obj, item) => {\n    obj[item[keyField]] = item;\n    return obj;\n  }, {});\n}\n\n/**\n * 渲染编辑器\n * [x] => <img src=\"x\" />\n * @param {strig} content\n */\nexport function renderContent(content, onClick) {\n  return content.replace(REGEXP, function(a, b) {\n    const src = a.slice(1, -1);\n    if (isUrl(src)) {\n      return `<img src=\"${src}\" alt=\"${src}\" style=\"max-width: 300px\" />`;\n    }\n    const emojiObejct = arrayToObject(emoji, \"title\");\n    const value = emojiObejct[src].value;\n    return `<img src=\"${prefixUrl}${value}.${ext}\" alt=\"${value}\" />`;\n  });\n}\n"]}
1
+{"version":3,"sources":["../src/helper.js"],"names":["isFunction","isUrl","arrayToObject","renderContent","functionToCheck","toString","call","userInput","regexp","res","match","array","keyField","reduce","obj","item","content","onClick","replace","REGEXP","a","b","src","slice","emojiObejct","emoji","value","prefixUrl","ext"],"mappings":";;;;;QAGgBA,U,GAAAA,U;QAMAC,K,GAAAA,K;QAYAC,a,GAAAA,a;QAYAC,a,GAAAA,a;;AAjChB;;AACA;;;;;;AAEO,SAASH,UAAT,CAAoBI,eAApB,EAAqC;AAC1C,SACEA,mBAAmB,GAAGC,QAAH,CAAYC,IAAZ,CAAiBF,eAAjB,MAAsC,mBAD3D;AAGD;;AAEM,SAASH,KAAT,CAAeM,SAAf,EAA0B;AAC/B,MAAMC,SAAS,kGAAf;AACA,MAAIC,MAAMF,UAAUG,KAAV,CAAgBF,MAAhB,CAAV;AACA,MAAIC,QAAQ,IAAZ,EAAkB,OAAO,KAAP,CAAlB,KACK,OAAO,IAAP;AACN;;AAED;;;;;AAKO,SAASP,aAAT,CAAuBS,KAAvB,EAA8BC,QAA9B,EAAwC;AAC7C,SAAOD,MAAME,MAAN,CAAa,UAACC,GAAD,EAAMC,IAAN,EAAe;AACjCD,QAAIC,KAAKH,QAAL,CAAJ,IAAsBG,IAAtB;AACA,WAAOD,GAAP;AACD,GAHM,EAGJ,EAHI,CAAP;AAID;;AAED;;;;;AAKO,SAASX,aAAT,CAAuBa,OAAvB,EAAgCC,OAAhC,EAAyC;AAC9C,SAAOD,QAAQE,OAAR,CAAgBC,gBAAhB,EAAwB,UAASC,CAAT,EAAYC,CAAZ,EAAe;AAC5C,QAAMC,MAAMF,EAAEG,KAAF,CAAQ,CAAR,EAAW,CAAC,CAAZ,CAAZ;AACA,QAAItB,MAAMqB,GAAN,CAAJ,EAAgB;AACd,4BAAoBA,GAApB,eAAiCA,GAAjC;AACD;AACD,QAAME,cAActB,cAAcuB,eAAd,EAAqB,OAArB,CAApB;AACA,QAAMC,QAAQF,YAAYF,GAAZ,EAAiBI,KAA/B;AACA,0BAAoBC,gBAApB,GAAgCD,KAAhC,SAAyCE,UAAzC,eAAsDF,KAAtD;AACD,GARM,CAAP;AASD","file":"helper.js","sourcesContent":["import { REGEXP } from './constant';\nimport emoji, { prefixUrl, ext } from './emoji';\n\nexport function isFunction(functionToCheck) {\n  return (\n    functionToCheck && {}.toString.call(functionToCheck) === '[object Function]'\n  );\n}\n\nexport function isUrl(userInput) {\n  const regexp = /(http(s)?:\\/\\/.)?(www\\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/g;\n  var res = userInput.match(regexp);\n  if (res === null) return false;\n  else return true;\n}\n\n/**\n * 将对象数组转换为对象\n * @param {array} array Array of Objects\n * @param {string} keyField string\n */\nexport function arrayToObject(array, keyField) {\n  return array.reduce((obj, item) => {\n    obj[item[keyField]] = item;\n    return obj;\n  }, {});\n}\n\n/**\n * 渲染编辑器\n * [x] => <img src=\"x\" />\n * @param {strig} content\n */\nexport function renderContent(content, onClick) {\n  return content.replace(REGEXP, function(a, b) {\n    const src = a.slice(1, -1);\n    if (isUrl(src)) {\n      return `<img src=\"${src}\" alt=\"${src}\" style=\"max-width: 300px\" />`;\n    }\n    const emojiObejct = arrayToObject(emoji, 'title');\n    const value = emojiObejct[src].value;\n    return `<img src=\"${prefixUrl}${value}.${ext}\" alt=\"${value}\" />`;\n  });\n}\n"]}

+ 13
- 13
lib/index.js View File

@@ -1,20 +1,20 @@
1
-"use strict";
1
+'use strict';
2 2
 
3 3
 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
4 4
 
5
-var _react = require("react");
5
+var _react = require('react');
6 6
 
7 7
 var _react2 = _interopRequireDefault(_react);
8 8
 
9
-var _reactDom = require("react-dom");
9
+var _reactDom = require('react-dom');
10 10
 
11 11
 var _reactDom2 = _interopRequireDefault(_reactDom);
12 12
 
13
-var _App = require("./App");
13
+var _App = require('./App');
14 14
 
15 15
 var _App2 = _interopRequireDefault(_App);
16 16
 
17
-var _registerServiceWorker = require("./registerServiceWorker");
17
+var _registerServiceWorker = require('./registerServiceWorker');
18 18
 
19 19
 var _registerServiceWorker2 = _interopRequireDefault(_registerServiceWorker);
20 20
 
@@ -35,7 +35,7 @@ var Index = function (_Component) {
35 35
     var _this = _possibleConstructorReturn(this, (Index.__proto__ || Object.getPrototypeOf(Index)).call(this, props));
36 36
 
37 37
     _this.state = {
38
-      value: ""
38
+      value: ''
39 39
     };
40 40
     _this.handleChangeValue = _this.handleChangeValue.bind(_this);
41 41
     _this.handleChangeSubmit = _this.handleChangeSubmit.bind(_this);
@@ -43,13 +43,13 @@ var Index = function (_Component) {
43 43
   }
44 44
 
45 45
   _createClass(Index, [{
46
-    key: "handleChangeValue",
46
+    key: 'handleChangeValue',
47 47
     value: function handleChangeValue(value) {
48 48
       this.setState({ value: value });
49
-      console.log("handleChangeValue value: ", value);
49
+      console.log('handleChangeValue value: ', value);
50 50
     }
51 51
   }, {
52
-    key: "handleChangeSubmit",
52
+    key: 'handleChangeSubmit',
53 53
     value: function handleChangeSubmit(value) {
54 54
       var _this2 = this;
55 55
 
@@ -58,15 +58,15 @@ var Index = function (_Component) {
58 58
           _this2.setState({ loading: false });
59 59
         }, 2000);
60 60
       });
61
-      console.log("submit value: ", value);
61
+      console.log('submit value: ', value);
62 62
     }
63 63
   }, {
64
-    key: "render",
64
+    key: 'render',
65 65
     value: function render() {
66 66
       // 最简单的用法
67 67
       return _react2.default.createElement(
68 68
         _App2.default,
69
-        { type: 1, businessId: "test" },
69
+        { type: 1, businessId: 'test' },
70 70
         _react2.default.createElement(_App.Editor, null)
71 71
       );
72 72
 
@@ -114,6 +114,6 @@ var Index = function (_Component) {
114 114
   return Index;
115 115
 }(_react.Component);
116 116
 
117
-_reactDom2.default.render(_react2.default.createElement(Index, null), document.getElementById("root-comment"));
117
+_reactDom2.default.render(_react2.default.createElement(Index, null), document.getElementById('root-comment'));
118 118
 (0, _registerServiceWorker2.default)();
119 119
 //# sourceMappingURL=index.js.map

+ 1
- 1
lib/index.js.map View File

@@ -1 +1 @@
1
-{"version":3,"sources":["../src/index.js"],"names":["Index","props","state","value","handleChangeValue","bind","handleChangeSubmit","setState","console","log","loading","setTimeout","Component","ReactDOM","render","document","getElementById"],"mappings":";;;;AAAA;;;;AACA;;;;AAEA;;;;AACA;;;;;;;;;;;;IAEMA,K;;;AACJ,iBAAYC,KAAZ,EAAmB;AAAA;;AAAA,8GACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa;AACXC,aAAO;AADI,KAAb;AAGA,UAAKC,iBAAL,GAAyB,MAAKA,iBAAL,CAAuBC,IAAvB,OAAzB;AACA,UAAKC,kBAAL,GAA0B,MAAKA,kBAAL,CAAwBD,IAAxB,OAA1B;AANiB;AAOlB;;;;sCAEiBF,K,EAAO;AACvB,WAAKI,QAAL,CAAc,EAAEJ,YAAF,EAAd;AACAK,cAAQC,GAAR,CAAY,2BAAZ,EAAyCN,KAAzC;AACD;;;uCAEkBA,K,EAAO;AAAA;;AACxB,WAAKI,QAAL,CAAc,EAAEG,SAAS,IAAX,EAAd,EAAiC,YAAM;AACrCC,mBAAW,YAAM;AACf,iBAAKJ,QAAL,CAAc,EAAEG,SAAS,KAAX,EAAd;AACD,SAFD,EAEG,IAFH;AAGD,OAJD;AAKAF,cAAQC,GAAR,CAAY,gBAAZ,EAA8BN,KAA9B;AACD;;;6BAEQ;AACP;AACA,aACE;AAAC,qBAAD;AAAA,UAAK,MAAM,CAAX,EAAc,YAAW,MAAzB;AACE,sCAAC,WAAD;AADF,OADF;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACD;;;;EAtEiBS,gB;;AAyEpBC,mBAASC,MAAT,CAAgB,8BAAC,KAAD,OAAhB,EAA2BC,SAASC,cAAT,CAAwB,cAAxB,CAA3B;AACA","file":"index.js","sourcesContent":["import React, { Component } from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { Button, Icon } from \"antd\";\nimport App, { Editor } from \"./App\";\nimport registerServiceWorker from \"./registerServiceWorker\";\n\nclass Index extends Component {\n  constructor(props) {\n    super(props);\n    this.state = {\n      value: \"\"\n    };\n    this.handleChangeValue = this.handleChangeValue.bind(this);\n    this.handleChangeSubmit = this.handleChangeSubmit.bind(this);\n  }\n\n  handleChangeValue(value) {\n    this.setState({ value });\n    console.log(\"handleChangeValue value: \", value);\n  }\n\n  handleChangeSubmit(value) {\n    this.setState({ loading: true }, () => {\n      setTimeout(() => {\n        this.setState({ loading: false });\n      }, 2000);\n    });\n    console.log(\"submit value: \", value);\n  }\n\n  render() {\n    // 最简单的用法\n    return (\n      <App type={1} businessId=\"test\">\n        <Editor />\n      </App>\n    );\n\n    // 复杂的用户法\n    // const props = {\n    //   type: 1,\n    //   businessId: \"1\",\n    //   API: \"http://api.links123.net/comment/v1\",\n    //   showList: true\n    // };\n\n    // const editorProps = {\n    //   showEmoji: true,\n    //   placeholder: \"说点什么吧\",\n    //   rows: 5,\n    //   btnLoading: this.state.loading,\n    //   btnDisable: this.state.loading,\n    //   btnSubmitText: \"提交\",\n    //   value: this.state.value,\n    //   onChange: v => this.handleChangeValue(v),\n    //   onSubmit: v => this.handleChangeSubmit(v),\n    //   button: (\n    //     <Button\n    //       type=\"primary\"\n    //       ghost\n    //       // onClick={() => console.log('click btn: ', this.state.value)}\n    //     >\n    //       自定义按钮\n    //     </Button>\n    //   ),\n    //   emojiToolIcon: <Icon type=\"smile\" style={{ fontSize: 23 }} />,\n    //   imageToolIcon: (\n    //     <Icon type=\"cloud-upload-o\" style={{ fontSize: 25, marginLeft: 10 }} />\n    //   )\n    // };\n\n    // return (\n    //   <App {...props}>\n    //     <Editor {...editorProps} />\n    //   </App>\n    // );\n  }\n}\n\nReactDOM.render(<Index />, document.getElementById(\"root-comment\"));\nregisterServiceWorker();\n"]}
1
+{"version":3,"sources":["../src/index.js"],"names":["Index","props","state","value","handleChangeValue","bind","handleChangeSubmit","setState","console","log","loading","setTimeout","Component","ReactDOM","render","document","getElementById"],"mappings":";;;;AAAA;;;;AACA;;;;AAEA;;;;AACA;;;;;;;;;;;;IAEMA,K;;;AACJ,iBAAYC,KAAZ,EAAmB;AAAA;;AAAA,8GACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa;AACXC,aAAO;AADI,KAAb;AAGA,UAAKC,iBAAL,GAAyB,MAAKA,iBAAL,CAAuBC,IAAvB,OAAzB;AACA,UAAKC,kBAAL,GAA0B,MAAKA,kBAAL,CAAwBD,IAAxB,OAA1B;AANiB;AAOlB;;;;sCAEiBF,K,EAAO;AACvB,WAAKI,QAAL,CAAc,EAAEJ,YAAF,EAAd;AACAK,cAAQC,GAAR,CAAY,2BAAZ,EAAyCN,KAAzC;AACD;;;uCAEkBA,K,EAAO;AAAA;;AACxB,WAAKI,QAAL,CAAc,EAAEG,SAAS,IAAX,EAAd,EAAiC,YAAM;AACrCC,mBAAW,YAAM;AACf,iBAAKJ,QAAL,CAAc,EAAEG,SAAS,KAAX,EAAd;AACD,SAFD,EAEG,IAFH;AAGD,OAJD;AAKAF,cAAQC,GAAR,CAAY,gBAAZ,EAA8BN,KAA9B;AACD;;;6BAEQ;AACP;AACA,aACE;AAAC,qBAAD;AAAA,UAAK,MAAM,CAAX,EAAc,YAAW,MAAzB;AACE,sCAAC,WAAD;AADF,OADF;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACD;;;;EAtEiBS,gB;;AAyEpBC,mBAASC,MAAT,CAAgB,8BAAC,KAAD,OAAhB,EAA2BC,SAASC,cAAT,CAAwB,cAAxB,CAA3B;AACA","file":"index.js","sourcesContent":["import React, { Component } from 'react';\nimport ReactDOM from 'react-dom';\nimport { Button, Icon } from 'antd';\nimport App, { Editor } from './App';\nimport registerServiceWorker from './registerServiceWorker';\n\nclass Index extends Component {\n  constructor(props) {\n    super(props);\n    this.state = {\n      value: '',\n    };\n    this.handleChangeValue = this.handleChangeValue.bind(this);\n    this.handleChangeSubmit = this.handleChangeSubmit.bind(this);\n  }\n\n  handleChangeValue(value) {\n    this.setState({ value });\n    console.log('handleChangeValue value: ', value);\n  }\n\n  handleChangeSubmit(value) {\n    this.setState({ loading: true }, () => {\n      setTimeout(() => {\n        this.setState({ loading: false });\n      }, 2000);\n    });\n    console.log('submit value: ', value);\n  }\n\n  render() {\n    // 最简单的用法\n    return (\n      <App type={1} businessId=\"test\">\n        <Editor />\n      </App>\n    );\n\n    // 复杂的用户法\n    // const props = {\n    //   type: 1,\n    //   businessId: \"1\",\n    //   API: \"http://api.links123.net/comment/v1\",\n    //   showList: true\n    // };\n\n    // const editorProps = {\n    //   showEmoji: true,\n    //   placeholder: \"说点什么吧\",\n    //   rows: 5,\n    //   btnLoading: this.state.loading,\n    //   btnDisable: this.state.loading,\n    //   btnSubmitText: \"提交\",\n    //   value: this.state.value,\n    //   onChange: v => this.handleChangeValue(v),\n    //   onSubmit: v => this.handleChangeSubmit(v),\n    //   button: (\n    //     <Button\n    //       type=\"primary\"\n    //       ghost\n    //       // onClick={() => console.log('click btn: ', this.state.value)}\n    //     >\n    //       自定义按钮\n    //     </Button>\n    //   ),\n    //   emojiToolIcon: <Icon type=\"smile\" style={{ fontSize: 23 }} />,\n    //   imageToolIcon: (\n    //     <Icon type=\"cloud-upload-o\" style={{ fontSize: 25, marginLeft: 10 }} />\n    //   )\n    // };\n\n    // return (\n    //   <App {...props}>\n    //     <Editor {...editorProps} />\n    //   </App>\n    // );\n  }\n}\n\nReactDOM.render(<Index />, document.getElementById('root-comment'));\nregisterServiceWorker();\n"]}

+ 11
- 11
lib/lang/index.js View File

@@ -1,4 +1,4 @@
1
-"use strict";
1
+'use strict';
2 2
 
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
@@ -6,16 +6,16 @@ Object.defineProperty(exports, "__esModule", {
6 6
 // 语言包
7 7
 // 英文短语和中文提示的对应
8 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": "获取回复列表失败"
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 19
 };
20 20
 
21 21
 exports.default = data;

+ 1
- 1
lib/lang/index.js.map View File

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

+ 14
- 14
lib/registerServiceWorker.js View File

@@ -1,4 +1,4 @@
1
-"use strict";
1
+'use strict';
2 2
 
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
@@ -15,14 +15,14 @@ exports.unregister = unregister;
15 15
 // To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
16 16
 // This link also includes instructions on opting out of this behavior.
17 17
 
18
-var isLocalhost = Boolean(window.location.hostname === "localhost" ||
18
+var isLocalhost = Boolean(window.location.hostname === 'localhost' ||
19 19
 // [::1] is the IPv6 localhost address.
20
-window.location.hostname === "[::1]" ||
20
+window.location.hostname === '[::1]' ||
21 21
 // 127.0.0.1/8 is considered localhost for IPv4.
22 22
 window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));
23 23
 
24 24
 function register() {
25
-  if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
25
+  if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
26 26
     // The URL constructor is available in all browsers that support SW.
27 27
     var publicUrl = new URL(process.env.PUBLIC_URL, window.location);
28 28
     if (publicUrl.origin !== window.location.origin) {
@@ -32,8 +32,8 @@ function register() {
32 32
       return;
33 33
     }
34 34
 
35
-    window.addEventListener("load", function () {
36
-      var swUrl = process.env.PUBLIC_URL + "/service-worker.js";
35
+    window.addEventListener('load', function () {
36
+      var swUrl = process.env.PUBLIC_URL + '/service-worker.js';
37 37
 
38 38
       if (isLocalhost) {
39 39
         // This is running on localhost. Lets check if a service worker still exists or not.
@@ -42,7 +42,7 @@ function register() {
42 42
         // Add some additional logging to localhost, pointing developers to the
43 43
         // service worker/PWA documentation.
44 44
         navigator.serviceWorker.ready.then(function () {
45
-          console.log("This web app is being served cache-first by a service " + "worker. To learn more, visit https://goo.gl/SC7cgQ");
45
+          console.log('This web app is being served cache-first by a service ' + 'worker. To learn more, visit https://goo.gl/SC7cgQ');
46 46
         });
47 47
       } else {
48 48
         // Is not local host. Just register service worker
@@ -57,24 +57,24 @@ function registerValidSW(swUrl) {
57 57
     registration.onupdatefound = function () {
58 58
       var installingWorker = registration.installing;
59 59
       installingWorker.onstatechange = function () {
60
-        if (installingWorker.state === "installed") {
60
+        if (installingWorker.state === 'installed') {
61 61
           if (navigator.serviceWorker.controller) {
62 62
             // At this point, the old content will have been purged and
63 63
             // the fresh content will have been added to the cache.
64 64
             // It's the perfect time to display a "New content is
65 65
             // available; please refresh." message in your web app.
66
-            console.log("New content is available; please refresh.");
66
+            console.log('New content is available; please refresh.');
67 67
           } else {
68 68
             // At this point, everything has been precached.
69 69
             // It's the perfect time to display a
70 70
             // "Content is cached for offline use." message.
71
-            console.log("Content is cached for offline use.");
71
+            console.log('Content is cached for offline use.');
72 72
           }
73 73
         }
74 74
       };
75 75
     };
76 76
   }).catch(function (error) {
77
-    console.error("Error during service worker registration:", error);
77
+    console.error('Error during service worker registration:', error);
78 78
   });
79 79
 }
80 80
 
@@ -82,7 +82,7 @@ function checkValidServiceWorker(swUrl) {
82 82
   // Check if the service worker can be found. If it can't reload the page.
83 83
   fetch(swUrl).then(function (response) {
84 84
     // Ensure service worker exists, and that we really are getting a JS file.
85
-    if (response.status === 404 || response.headers.get("content-type").indexOf("javascript") === -1) {
85
+    if (response.status === 404 || response.headers.get('content-type').indexOf('javascript') === -1) {
86 86
       // No service worker found. Probably a different app. Reload the page.
87 87
       navigator.serviceWorker.ready.then(function (registration) {
88 88
         registration.unregister().then(function () {
@@ -94,12 +94,12 @@ function checkValidServiceWorker(swUrl) {
94 94
       registerValidSW(swUrl);
95 95
     }
96 96
   }).catch(function () {
97
-    console.log("No internet connection found. App is running in offline mode.");
97
+    console.log('No internet connection found. App is running in offline mode.');
98 98
   });
99 99
 }
100 100
 
101 101
 function unregister() {
102
-  if ("serviceWorker" in navigator) {
102
+  if ('serviceWorker' in navigator) {
103 103
     navigator.serviceWorker.ready.then(function (registration) {
104 104
       registration.unregister();
105 105
     });

+ 1
- 1
lib/registerServiceWorker.js.map
File diff suppressed because it is too large
View File


+ 1
- 1
package.json View File

@@ -31,7 +31,7 @@
31 31
   },
32 32
   "scripts": {
33 33
     "precommit": "lint-staged",
34
-    "prettier": "prettier --single-quote --trailing-comma --write 'src/**/*.{js,jsx,json,css,less}'",
34
+    "prettier": "prettier --single-quote --trailing-comma=es5 --write 'src/**/*.{js,jsx,json,css,less}'",
35 35
     "start": "react-app-rewired start",
36 36
     "build": "react-app-rewired build",
37 37
     "test": "react-app-rewired test --env=jsdom",

+ 20
- 17
src/App.js View File

@@ -156,7 +156,7 @@ class App extends Component {
156 156
    * 添加评论
157 157
    * @param {object} {content} comment content
158 158
    */
159
-  sCreateComment({ content } = {}) {
159
+  sCreateComment({ content } = {}, cb) {
160 160
     if (!content) return message.error("评论内容不能为空 ");
161 161
     this.handleChangeLoading("sCreateComment", true);
162 162
     const { API, type, businessId } = this.props;
@@ -171,6 +171,7 @@ class App extends Component {
171 171
     })
172 172
       .then(response => {
173 173
         message.success("评论成功!");
174
+        if (isFunction(cb)) cb();
174 175
         // 将数据写入到 list 中
175 176
         // 临时插入
176 177
         // 等到获取数据之后,删除临时数据
@@ -199,7 +200,6 @@ class App extends Component {
199 200
    * @param {object} data { comment_id, content, [reply_id] }
200 201
    */
201 202
   sCreateReply(data, cb) {
202
-    // console.log("list: ", this.state.list);
203 203
     if (!data.content) return message.error("回复内容不能为空 ");
204 204
     this.handleChangeLoading("sCreateReply", true);
205 205
     const { API } = this.props;
@@ -283,30 +283,33 @@ class App extends Component {
283 283
    */
284 284
   sReplyFavor(replyId, commentId, favored) {
285 285
     this.handleChangeLoading("sReplyFavor", true);
286
-    console.log("replyId, commentId ", replyId, commentId);
287
-
288 286
     const { API } = this.props;
289 287
     this.axios(`${API}/replies/${replyId}/favor`, {
290 288
       method: favored ? "delete" : "put",
291
-      daa: {
289
+      data: {
292 290
         comment_id: commentId
293 291
       },
294 292
       withCredentials: true
295 293
     })
296 294
       .then(response => {
297
-        console.log("response: ", response);
298
-
299 295
         message.success(favored ? "取消点赞成功!" : "点赞成功!");
300
-        // TODO: (2018.07.20 node) 对评论的回复点赞,报错
301
-        // // 更新 list 中的该项数据的 favored
302
-        // const list = this.state.list.map(item => {
303
-        //   if (item.id === replyId) {
304
-        //     item.favored = !favored;
305
-        //     item.favor_count += favored ? -1 : 1;
306
-        //   }
307
-        //   return item;
308
-        // });
309
-        // this.setState({ list });
296
+        // 更新 list 中的该项数据的 favored
297
+        const list = this.state.list.map(item => {
298
+          if (item.id === commentId) {
299
+            item.replies = item.replies.map(r => {
300
+              if (r.id === replyId) {
301
+                r.favored = !favored;
302
+                // r.favor_count =  response.data.favor_count;
303
+                // 点赞数 +1,而不是使用后端返回的点赞数
304
+                // 不然如果返回的不是增加 1,用户可能以为程序错误
305
+                r.favor_count += favored ? -1 : 1;
306
+              }
307
+              return r;
308
+            });
309
+          }
310
+          return item;
311
+        });
312
+        this.setState({ list });
310 313
       })
311 314
       .catch(error => {
312 315
         if (error.response && error.response.data && error.response.data.msg) {

+ 12
- 4
src/components/CommentInput/index.js View File

@@ -9,12 +9,20 @@ class CommentInput extends Component {
9 9
     this.handleSubmit = this.handleSubmit.bind(this);
10 10
   }
11 11
 
12
-  handleSubmit(value) {
12
+  /**
13
+   * 提交评论
14
+   * @param {string} value 需要提交的评论的值
15
+   * @param {function} cb 提交成功后的回掉
16
+   */
17
+  handleSubmit(value, cb) {
13 18
     const { action, commentId, replyId, callback } = this.props;
14 19
     if (action === "comment") {
15
-      this.props.app.sCreateComment({
16
-        content: value
17
-      });
20
+      this.props.app.sCreateComment(
21
+        {
22
+          content: value
23
+        },
24
+        cb
25
+      );
18 26
     } else if (action === "reply") {
19 27
       this.props.app.sCreateReply(
20 28
         {

+ 3
- 0
src/components/ContentItem/index.css View File

@@ -29,6 +29,9 @@
29 29
   margin-left: 5px;
30 30
   cursor: pointer;
31 31
 }
32
+.comment-favor {
33
+  font-size: 20px;
34
+}
32 35
 .comment-favored {
33 36
   color: #4a90e2;
34 37
 }

+ 5
- 1
src/components/ContentItem/index.js View File

@@ -113,7 +113,11 @@ class CommentItem extends Component {
113 113
             >
114 114
               <Icon
115 115
                 type="like-o"
116
-                className={content.favored ? "comment-favored" : ""}
116
+                className={
117
+                  content.favored
118
+                    ? "comment-favor comment-favored"
119
+                    : "comment-favor"
120
+                }
117 121
               />
118 122
               &nbsp;{content.favor_count}
119 123
             </div>

+ 11
- 4
src/components/Editor/index.js View File

@@ -75,7 +75,7 @@ class Editor extends React.Component {
75 75
   }
76 76
 
77 77
   /**
78
-   * 上传文件 TODO:
78
+   * 上传文件
79 79
    * @param {object} param 文件对象
80 80
    */
81 81
   handleUpload({ uid, path }) {
@@ -97,7 +97,14 @@ class Editor extends React.Component {
97 97
         value += `[${OSS_LINK}${fileMap[item.uid]}]`;
98 98
       });
99 99
     }
100
-    this.props.onSubmit(value);
100
+    this.props.onSubmit(value, () => {
101
+      this.setState({
102
+        showUpload: false,
103
+        value: "",
104
+        fileList: [],
105
+        fileMap: {}
106
+      });
107
+    });
101 108
   }
102 109
 
103 110
   render() {
@@ -114,10 +121,10 @@ class Editor extends React.Component {
114 121
       emojiToolIcon,
115 122
       imageToolIcon
116 123
     } = this.props;
117
-
118 124
     const handleSubmit = this.handleSubmit;
119 125
     const disabledSubmit =
120
-      btnDisabled || (!this.props.value && !this.state.value);
126
+      btnDisabled ||
127
+      (!this.props.value && !this.state.value && !this.state.fileList.length);
121 128
     return (
122 129
       <div className="comment-editor">
123 130
         <TextArea

+ 1
- 1
src/index.js View File

@@ -32,7 +32,7 @@ class Index extends Component {
32 32
     // 最简单的用法
33 33
     return (
34 34
       <App type={1} businessId="test">
35
-        <Editor value="" />
35
+        <Editor />
36 36
       </App>
37 37
     );
38 38