Browse Source

fix:editor登录判断增加currentUser.id

zhengyingya 4 years ago
parent
commit
bbef11c1ac

+ 12
- 4
lib/App.js View File

@@ -430,7 +430,10 @@ var App = function (_Component) {
430 430
         }));
431 431
         _this6.setState({ list: list, total: total + 1 });
432 432
         _this6.props.onCountChange(total + 1);
433
-      }).catch(this.errorHandler).finally(function () {
433
+      }).catch(function (error) {
434
+        _this6.props.onCommentFail(error.response.status);
435
+        _this6.errorHandler(error);
436
+      }).finally(function () {
434 437
         _this6.handleChangeLoading("sCreateComment", false);
435 438
       });
436 439
     }
@@ -545,7 +548,10 @@ var App = function (_Component) {
545 548
           return item;
546 549
         });
547 550
         _this9.setState({ list: list });
548
-      }).catch(this.errorHandler).finally(function () {
551
+      }).catch(function (error) {
552
+        _this9.props.onCommentFail(error.response.status);
553
+        _this9.errorHandler(error);
554
+      }).finally(function () {
549 555
         _this9.handleChangeLoading("sCreateReply", false);
550 556
       });
551 557
     }
@@ -790,7 +796,8 @@ App.propTypes = {
790 796
   onDelete: _propTypes2.default.func,
791 797
   onUpdateComment: _propTypes2.default.func,
792 798
   locales: _propTypes2.default.string, //  传入的语言环境, en-US/zh-CN
793
-  onCountChange: _propTypes2.default.func // 评论数量变更时的回调
799
+  onCountChange: _propTypes2.default.func, // 评论数量变更时的回调
800
+  onCommentFail: _propTypes2.default.func // 评论失败时的回调
794 801
 };
795 802
 
796 803
 App.defaultProps = {
@@ -812,7 +819,8 @@ App.defaultProps = {
812 819
   onDelete: function onDelete() {},
813 820
   onUpdateComment: function onUpdateComment() {},
814 821
   onBeforeUpdateComment: function onBeforeUpdateComment() {},
815
-  onCountChange: function onCountChange() {}
822
+  onCountChange: function onCountChange() {},
823
+  onCommentFail: function onCommentFail() {}
816 824
 };
817 825
 
818 826
 exports.Editor = _Editor2.default;

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


+ 3
- 1
lib/components/Editor/Upload.css View File

@@ -26,7 +26,9 @@
26 26
   align-items: center;
27 27
   justify-content: center;
28 28
 }
29
-
29
+.ant-upload-list-picture-card {
30
+  float: none!important;
31
+}
30 32
 .upload-close-icon {
31 33
   position: absolute;
32 34
   background: url("../../assert/close.png");

+ 2
- 1
lib/components/Editor/index.js View File

@@ -429,7 +429,7 @@ var Editor = function (_React$Component) {
429 429
       var disabledSubmit = this.checkDisabledSubmit();
430 430
       var inputValue = value || this.state.value;
431 431
       var uploadFileList = fileList || this.state.fileList;
432
-      var isLogin = app.currentUser && app.currentUser.user_id > 0;
432
+      var isLogin = app.currentUser && (app.currentUser.user_id > 0 || app.currentUser.id > 0);
433 433
       return _react2.default.createElement(
434 434
         "div",
435 435
         { className: "comment-editor-container", onPaste: this.handlePaste },
@@ -646,6 +646,7 @@ Editor.defaultProps = {
646 646
   btnDisabled: false,
647 647
   showError: true,
648 648
   maxLength: 5000,
649
+  app: {},
649 650
   handleChangeFileList: function handleChangeFileList() {}
650 651
 };
651 652
 

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


+ 3
- 0
lib/index.js View File

@@ -182,6 +182,9 @@ if (process.env.NODE_ENV !== "production") {
182 182
     onDelete: function onDelete(type, data) {
183 183
       console.log(type, data);
184 184
     },
185
+    onCommentFail: function onCommentFail(data) {
186
+      console.log("onCommentFail", data);
187
+    },
185 188
     onUpdateComment: function onUpdateComment(type, data) {
186 189
       console.log("onUpdateComment", type);
187 190
     },

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


+ 4
- 4
lib/version.json View File

@@ -1,8 +1,8 @@
1 1
 {
2 2
     "name":       "comment",
3
-    "buildDate":  1565244799639,
3
+    "buildDate":  1565745352505,
4 4
     "version":    "1.0.4",
5
-    "numCommits": 182,
6
-    "hash":       "59ff040",
7
-    "dirty":      false
5
+    "numCommits": 184,
6
+    "hash":       "865439d",
7
+    "dirty":      true
8 8
 }

+ 3
- 1
src/components/Editor/Upload.css View File

@@ -26,7 +26,9 @@
26 26
   align-items: center;
27 27
   justify-content: center;
28 28
 }
29
-
29
+.ant-upload-list-picture-card {
30
+  float: none !important;
31
+}
30 32
 .upload-close-icon {
31 33
   position: absolute;
32 34
   background: url("../../assert/close.png");

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

@@ -322,7 +322,9 @@ class Editor extends React.Component {
322 322
     const disabledSubmit = this.checkDisabledSubmit();
323 323
     const inputValue = value || this.state.value;
324 324
     const uploadFileList = fileList || this.state.fileList;
325
-    const isLogin = app.currentUser && app.currentUser.user_id > 0;
325
+    const isLogin =
326
+      app.currentUser &&
327
+      (app.currentUser.user_id > 0 || app.currentUser.id > 0);
326 328
     return (
327 329
       <div className="comment-editor-container" onPaste={this.handlePaste}>
328 330
         {isLogin ? (
@@ -521,6 +523,7 @@ Editor.defaultProps = {
521 523
   btnDisabled: false,
522 524
   showError: true,
523 525
   maxLength: 5000,
526
+  app: {},
524 527
   handleChangeFileList: () => {}
525 528
 };
526 529