Browse Source

Merge branch 'release/v1.2.5' of npm/comment into master

AdamFu 4 years ago
parent
commit
fb5b88213a
2 changed files with 20 additions and 5 deletions
  1. 8
    2
      src/App.js
  2. 12
    3
      src/components/EditComment/EditComment.js

+ 8
- 2
src/App.js View File

346
    * 更新评论
346
    * 更新评论
347
    * @param {object} {content} comment content
347
    * @param {object} {content} comment content
348
    */
348
    */
349
-  sUpdateComment({ commentId, content }) {
349
+  sUpdateComment({ commentId, content, successCallback }) {
350
     this.handleChangeLoading("sUpdateComment", true);
350
     this.handleChangeLoading("sUpdateComment", true);
351
     const { API } = this.props;
351
     const { API } = this.props;
352
     this.axios(`${API}/comments/${commentId}`, {
352
     this.axios(`${API}/comments/${commentId}`, {
369
         });
369
         });
370
         this.props.onUpdateComment("comment");
370
         this.props.onUpdateComment("comment");
371
         this.setState({ list });
371
         this.setState({ list });
372
+        if (successCallback) {
373
+          successCallback();
374
+        }
372
       })
375
       })
373
       .catch(error => {
376
       .catch(error => {
374
         this.props.onCommentFail(error.response.status, error.response.data);
377
         this.props.onCommentFail(error.response.status, error.response.data);
458
    * 回复评论/回复回复
461
    * 回复评论/回复回复
459
    * @param {object} data { comment_id, content, reply_id }
462
    * @param {object} data { comment_id, content, reply_id }
460
    */
463
    */
461
-  sUpdateReply({ commentId, content, replyId, replyPage }) {
464
+  sUpdateReply({ commentId, content, replyId, replyPage, successCallback }) {
462
     this.handleChangeLoading("sUpdateReply", true);
465
     this.handleChangeLoading("sUpdateReply", true);
463
     const { API } = this.props;
466
     const { API } = this.props;
464
     this.axios(`${API}/replies/${replyId}`, {
467
     this.axios(`${API}/replies/${replyId}`, {
473
         for (let i = 1; i <= replyPage; i++) {
476
         for (let i = 1; i <= replyPage; i++) {
474
           this.sGetReply({ commentId, page: i });
477
           this.sGetReply({ commentId, page: i });
475
         }
478
         }
479
+        if (successCallback) {
480
+          successCallback();
481
+        }
476
         this.props.onUpdateComment("reply");
482
         this.props.onUpdateComment("reply");
477
       })
483
       })
478
       .catch(error => {
484
       .catch(error => {

+ 12
- 3
src/components/EditComment/EditComment.js View File

30
     if (value.substr(-1) === ",") {
30
     if (value.substr(-1) === ",") {
31
       value = value.slice(0, -1);
31
       value = value.slice(0, -1);
32
     }
32
     }
33
+    // 成功回调,失败不自动关闭
34
+    const successCallback = () => {
35
+      this.props.handleClose();
36
+    };
33
     if (action === "comment") {
37
     if (action === "comment") {
34
-      app.sUpdateComment({ commentId, content: value });
38
+      app.sUpdateComment({ commentId, content: value, successCallback });
35
     } else {
39
     } else {
36
-      app.sUpdateReply({ commentId, content: value, replyId, replyPage });
40
+      app.sUpdateReply({
41
+        commentId,
42
+        content: value,
43
+        replyId,
44
+        replyPage,
45
+        successCallback
46
+      });
37
     }
47
     }
38
-    this.props.handleClose();
39
   }
48
   }
40
 
49
 
41
   getInitValue(props) {
50
   getInitValue(props) {