Explorar el Código

Merge branch 'master' of Hepper/comment into master

AdamFu hace 5 años
padre
commit
be33f5364e

+ 1
- 1
lib/components/ContentItem/AvatarHoverCard.js Ver fichero

@@ -53,7 +53,7 @@ var AvatarHoverCard = function (_Component) {
53 53
   _createClass(AvatarHoverCard, [{
54 54
     key: "componentDidMount",
55 55
     value: function componentDidMount() {
56
-      var isLogin = this.props.currentUser.user_id > 0;
56
+      var isLogin = this.props.currentUser.user_id > 0 || this.props.currentUser.id > 0;
57 57
       this.props.getUserInfo({
58 58
         id: this.props.user_id,
59 59
         noCheckFollowed: !isLogin

+ 1
- 1
lib/components/ContentItem/AvatarHoverCard.js.map
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 2
- 2
lib/components/ContentItem/index.js Ver fichero

@@ -225,7 +225,7 @@ var CommentItem = function (_Component) {
225 225
         }
226 226
       }
227 227
       var IconColor = content.favor_count > 0 ? "#71C135" : "#4a90e2";
228
-
228
+      var showDivider = content.reply_count || showEdit && app.userId === content.user_id || app.userId === content.user_id;
229 229
       return _react2.default.createElement(
230 230
         "div",
231 231
         { className: "comment-item-box" },
@@ -381,7 +381,7 @@ var CommentItem = function (_Component) {
381 381
               },
382 382
               _react2.default.createElement("i", { className: "comment-item-delete" })
383 383
             ),
384
-            _react2.default.createElement("span", { className: "comment-item-divider" }),
384
+            showDivider && _react2.default.createElement("span", { className: "comment-item-divider" }),
385 385
             _react2.default.createElement(
386 386
               "div",
387 387
               {

+ 1
- 1
lib/components/ContentItem/index.js.map
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 0
- 1
lib/components/Editor/Upload.js Ver fichero

@@ -157,7 +157,6 @@ var App = function (_React$Component) {
157 157
 
158 158
       var file = info.file;
159 159
 
160
-      console.log(file);
161 160
       info.onProgress({ percent: 10 });
162 161
       var reader = new FileReader();
163 162
       reader.readAsDataURL(info.file);

+ 1
- 1
lib/components/Editor/Upload.js.map
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 30
- 26
lib/components/Editor/index.js Ver fichero

@@ -144,11 +144,15 @@ var Editor = function (_React$Component) {
144 144
   _createClass(Editor, [{
145 145
     key: "componentDidMount",
146 146
     value: function componentDidMount() {
147
-      if (this.props.app.currentUser && this.props.app.currentUser.user_id > 0) {
148
-        this.props.app.sOssSts();
147
+      var _props = this.props,
148
+          app = _props.app,
149
+          onRef = _props.onRef;
150
+
151
+      if (app.currentUser && (app.currentUser.user_id > 0 || app.currentUser.id > 0)) {
152
+        app.sOssSts();
149 153
       }
150
-      if ((0, _helper.isFunction)(this.props.onRef)) {
151
-        this.props.onRef(this);
154
+      if ((0, _helper.isFunction)(onRef)) {
155
+        onRef(this);
152 156
       }
153 157
     }
154 158
   }, {
@@ -373,10 +377,10 @@ var Editor = function (_React$Component) {
373 377
   }, {
374 378
     key: "checkDisabledSubmit",
375 379
     value: function checkDisabledSubmit() {
376
-      var _props = this.props,
377
-          btnDisabled = _props.btnDisabled,
378
-          value = _props.value,
379
-          fileList = _props.fileList;
380
+      var _props2 = this.props,
381
+          btnDisabled = _props2.btnDisabled,
382
+          value = _props2.value,
383
+          fileList = _props2.fileList;
380 384
 
381 385
       if (btnDisabled) {
382 386
         return true;
@@ -400,24 +404,24 @@ var Editor = function (_React$Component) {
400 404
     value: function render() {
401 405
       var _this4 = this;
402 406
 
403
-      var _props2 = this.props,
404
-          value = _props2.value,
405
-          rows = _props2.rows,
406
-          showEmoji = _props2.showEmoji,
407
-          showUpload = _props2.showUpload,
408
-          multiple = _props2.multiple,
409
-          emojiPopoverPlacement = _props2.emojiPopoverPlacement,
410
-          uploadPopoverPlacement = _props2.uploadPopoverPlacement,
411
-          uploadOverlayClassName = _props2.uploadOverlayClassName,
412
-          fileList = _props2.fileList,
413
-          maxUpload = _props2.maxUpload,
414
-          btnLoading = _props2.btnLoading,
415
-          button = _props2.button,
416
-          emojiToolIcon = _props2.emojiToolIcon,
417
-          imageToolIcon = _props2.imageToolIcon,
418
-          maxLength = _props2.maxLength,
419
-          autoFocus = _props2.autoFocus,
420
-          app = _props2.app;
407
+      var _props3 = this.props,
408
+          value = _props3.value,
409
+          rows = _props3.rows,
410
+          showEmoji = _props3.showEmoji,
411
+          showUpload = _props3.showUpload,
412
+          multiple = _props3.multiple,
413
+          emojiPopoverPlacement = _props3.emojiPopoverPlacement,
414
+          uploadPopoverPlacement = _props3.uploadPopoverPlacement,
415
+          uploadOverlayClassName = _props3.uploadOverlayClassName,
416
+          fileList = _props3.fileList,
417
+          maxUpload = _props3.maxUpload,
418
+          btnLoading = _props3.btnLoading,
419
+          button = _props3.button,
420
+          emojiToolIcon = _props3.emojiToolIcon,
421
+          imageToolIcon = _props3.imageToolIcon,
422
+          maxLength = _props3.maxLength,
423
+          autoFocus = _props3.autoFocus,
424
+          app = _props3.app;
421 425
 
422 426
       var placeholder = this.props.placeholder || _reactIntlUniversal2.default.get("editor.placeholder");
423 427
       var btnSubmitText = this.props.btnSubmitText || _reactIntlUniversal2.default.get("editor.SubmitBtn");

+ 1
- 1
lib/components/Editor/index.js.map
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 3
- 3
lib/version.json Ver fichero

@@ -1,8 +1,8 @@
1 1
 {
2 2
     "name":       "comment",
3
-    "buildDate":  1565080180929,
3
+    "buildDate":  1565244799639,
4 4
     "version":    "1.0.4",
5
-    "numCommits": 181,
6
-    "hash":       "d2c0f01",
5
+    "numCommits": 182,
6
+    "hash":       "59ff040",
7 7
     "dirty":      false
8 8
 }

+ 12
- 4
src/App.js Ver fichero

@@ -310,7 +310,10 @@ class App extends Component {
310 310
         this.setState({ list, total: total + 1 });
311 311
         this.props.onCountChange(total + 1);
312 312
       })
313
-      .catch(this.errorHandler)
313
+      .catch(error => {
314
+        this.props.onCommentFail(error.response.status);
315
+        this.errorHandler(error);
316
+      })
314 317
       .finally(() => {
315 318
         this.handleChangeLoading("sCreateComment", false);
316 319
       });
@@ -407,7 +410,10 @@ class App extends Component {
407 410
         });
408 411
         this.setState({ list });
409 412
       })
410
-      .catch(this.errorHandler)
413
+      .catch(error => {
414
+        this.props.onCommentFail(error.response.status);
415
+        this.errorHandler(error);
416
+      })
411 417
       .finally(() => {
412 418
         this.handleChangeLoading("sCreateReply", false);
413 419
       });
@@ -640,7 +646,8 @@ App.propTypes = {
640 646
   onDelete: PropTypes.func,
641 647
   onUpdateComment: PropTypes.func,
642 648
   locales: PropTypes.string, //  传入的语言环境, en-US/zh-CN
643
-  onCountChange: PropTypes.func // 评论数量变更时的回调
649
+  onCountChange: PropTypes.func, // 评论数量变更时的回调
650
+  onCommentFail: PropTypes.func // 评论失败时的回调
644 651
 };
645 652
 
646 653
 App.defaultProps = {
@@ -665,7 +672,8 @@ App.defaultProps = {
665 672
   onDelete: () => {},
666 673
   onUpdateComment: () => {},
667 674
   onBeforeUpdateComment: () => {},
668
-  onCountChange: () => {}
675
+  onCountChange: () => {},
676
+  onCommentFail: () => {}
669 677
 };
670 678
 
671 679
 export { Editor, RenderText };

+ 2
- 1
src/components/ContentItem/AvatarHoverCard.js Ver fichero

@@ -12,7 +12,8 @@ class AvatarHoverCard extends Component {
12 12
   }
13 13
 
14 14
   componentDidMount() {
15
-    const isLogin = this.props.currentUser.user_id > 0;
15
+    const isLogin =
16
+      this.props.currentUser.user_id > 0 || this.props.currentUser.id > 0;
16 17
     this.props.getUserInfo({
17 18
       id: this.props.user_id,
18 19
       noCheckFollowed: !isLogin

+ 5
- 2
src/components/ContentItem/index.js Ver fichero

@@ -130,7 +130,10 @@ class CommentItem extends Component {
130 130
       }
131 131
     }
132 132
     const IconColor = content.favor_count > 0 ? "#71C135" : "#4a90e2";
133
-
133
+    const showDivider =
134
+      content.reply_count ||
135
+      (showEdit && app.userId === content.user_id) ||
136
+      app.userId === content.user_id;
134 137
     return (
135 138
       <div className="comment-item-box">
136 139
         <div className="comment-item-left">
@@ -296,7 +299,7 @@ class CommentItem extends Component {
296 299
                 <i className="comment-item-delete" />
297 300
               </Popconfirm>
298 301
             )}
299
-            <span className="comment-item-divider" />
302
+            {showDivider && <span className="comment-item-divider" />}
300 303
             <div
301 304
               className="comment-item-bottom-right"
302 305
               onClick={() => {

+ 0
- 1
src/components/Editor/Upload.js Ver fichero

@@ -88,7 +88,6 @@ class App extends React.Component {
88 88
 
89 89
   customRequest(info) {
90 90
     const { file } = info;
91
-    console.log(file);
92 91
     info.onProgress({ percent: 10 });
93 92
     let reader = new FileReader();
94 93
     reader.readAsDataURL(info.file);

+ 8
- 4
src/components/Editor/index.js Ver fichero

@@ -72,11 +72,15 @@ class Editor extends React.Component {
72 72
   }
73 73
 
74 74
   componentDidMount() {
75
-    if (this.props.app.currentUser && this.props.app.currentUser.user_id > 0) {
76
-      this.props.app.sOssSts();
75
+    const { app, onRef } = this.props;
76
+    if (
77
+      app.currentUser &&
78
+      (app.currentUser.user_id > 0 || app.currentUser.id > 0)
79
+    ) {
80
+      app.sOssSts();
77 81
     }
78
-    if (isFunction(this.props.onRef)) {
79
-      this.props.onRef(this);
82
+    if (isFunction(onRef)) {
83
+      onRef(this);
80 84
     }
81 85
   }
82 86
 

+ 3
- 0
src/index.js Ver fichero

@@ -147,6 +147,9 @@ if (process.env.NODE_ENV !== "production") {
147 147
     onDelete: (type, data) => {
148 148
       console.log(type, data);
149 149
     },
150
+    onCommentFail: data => {
151
+      console.log("onCommentFail", data);
152
+    },
150 153
     onUpdateComment: (type, data) => {
151 154
       console.log("onUpdateComment", type);
152 155
     },