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

Merged
AdamFu merged 1 commits from Hepper/comment:master into master 5 years ago

+ 12
- 4
lib/App.js View File

430
         }));
430
         }));
431
         _this6.setState({ list: list, total: total + 1 });
431
         _this6.setState({ list: list, total: total + 1 });
432
         _this6.props.onCountChange(total + 1);
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
         _this6.handleChangeLoading("sCreateComment", false);
437
         _this6.handleChangeLoading("sCreateComment", false);
435
       });
438
       });
436
     }
439
     }
545
           return item;
548
           return item;
546
         });
549
         });
547
         _this9.setState({ list: list });
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
         _this9.handleChangeLoading("sCreateReply", false);
555
         _this9.handleChangeLoading("sCreateReply", false);
550
       });
556
       });
551
     }
557
     }
790
   onDelete: _propTypes2.default.func,
796
   onDelete: _propTypes2.default.func,
791
   onUpdateComment: _propTypes2.default.func,
797
   onUpdateComment: _propTypes2.default.func,
792
   locales: _propTypes2.default.string, //  传入的语言环境, en-US/zh-CN
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
 App.defaultProps = {
803
 App.defaultProps = {
812
   onDelete: function onDelete() {},
819
   onDelete: function onDelete() {},
813
   onUpdateComment: function onUpdateComment() {},
820
   onUpdateComment: function onUpdateComment() {},
814
   onBeforeUpdateComment: function onBeforeUpdateComment() {},
821
   onBeforeUpdateComment: function onBeforeUpdateComment() {},
815
-  onCountChange: function onCountChange() {}
822
+  onCountChange: function onCountChange() {},
823
+  onCommentFail: function onCommentFail() {}
816
 };
824
 };
817
 
825
 
818
 exports.Editor = _Editor2.default;
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
   align-items: center;
26
   align-items: center;
27
   justify-content: center;
27
   justify-content: center;
28
 }
28
 }
29
-
29
+.ant-upload-list-picture-card {
30
+  float: none!important;
31
+}
30
 .upload-close-icon {
32
 .upload-close-icon {
31
   position: absolute;
33
   position: absolute;
32
   background: url("../../assert/close.png");
34
   background: url("../../assert/close.png");

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

429
       var disabledSubmit = this.checkDisabledSubmit();
429
       var disabledSubmit = this.checkDisabledSubmit();
430
       var inputValue = value || this.state.value;
430
       var inputValue = value || this.state.value;
431
       var uploadFileList = fileList || this.state.fileList;
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
       return _react2.default.createElement(
433
       return _react2.default.createElement(
434
         "div",
434
         "div",
435
         { className: "comment-editor-container", onPaste: this.handlePaste },
435
         { className: "comment-editor-container", onPaste: this.handlePaste },
646
   btnDisabled: false,
646
   btnDisabled: false,
647
   showError: true,
647
   showError: true,
648
   maxLength: 5000,
648
   maxLength: 5000,
649
+  app: {},
649
   handleChangeFileList: function handleChangeFileList() {}
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
     onDelete: function onDelete(type, data) {
182
     onDelete: function onDelete(type, data) {
183
       console.log(type, data);
183
       console.log(type, data);
184
     },
184
     },
185
+    onCommentFail: function onCommentFail(data) {
186
+      console.log("onCommentFail", data);
187
+    },
185
     onUpdateComment: function onUpdateComment(type, data) {
188
     onUpdateComment: function onUpdateComment(type, data) {
186
       console.log("onUpdateComment", type);
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
 {
1
 {
2
     "name":       "comment",
2
     "name":       "comment",
3
-    "buildDate":  1565244799639,
3
+    "buildDate":  1565745352505,
4
     "version":    "1.0.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
   align-items: center;
26
   align-items: center;
27
   justify-content: center;
27
   justify-content: center;
28
 }
28
 }
29
-
29
+.ant-upload-list-picture-card {
30
+  float: none !important;
31
+}
30
 .upload-close-icon {
32
 .upload-close-icon {
31
   position: absolute;
33
   position: absolute;
32
   background: url("../../assert/close.png");
34
   background: url("../../assert/close.png");

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

322
     const disabledSubmit = this.checkDisabledSubmit();
322
     const disabledSubmit = this.checkDisabledSubmit();
323
     const inputValue = value || this.state.value;
323
     const inputValue = value || this.state.value;
324
     const uploadFileList = fileList || this.state.fileList;
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
     return (
328
     return (
327
       <div className="comment-editor-container" onPaste={this.handlePaste}>
329
       <div className="comment-editor-container" onPaste={this.handlePaste}>
328
         {isLogin ? (
330
         {isLogin ? (
521
   btnDisabled: false,
523
   btnDisabled: false,
522
   showError: true,
524
   showError: true,
523
   maxLength: 5000,
525
   maxLength: 5000,
526
+  app: {},
524
   handleChangeFileList: () => {}
527
   handleChangeFileList: () => {}
525
 };
528
 };
526
 
529