Browse Source

Merge branch 'master' of Hepper/comment into master

AdamFu 5 years ago
parent
commit
d8df69c94d

+ 4
- 0
lib/App.css View File

28
 .comment-img {
28
 .comment-img {
29
   max-width: 100%;
29
   max-width: 100%;
30
 }
30
 }
31
+
32
+.ant-upload-picture-card-wrapper {
33
+  width: 100%;
34
+}

+ 2
- 1
lib/App.js View File

406
             total = _state.total;
406
             total = _state.total;
407
 
407
 
408
         list.unshift(_extends({}, response.data, {
408
         list.unshift(_extends({}, response.data, {
409
+          replies: [],
409
           isTemporary: true // 临时的数据
410
           isTemporary: true // 临时的数据
410
         }));
411
         }));
411
         _this5.setState({ list: list, total: total + 1 });
412
         _this5.setState({ list: list, total: total + 1 });
789
   onPageChange: function onPageChange(page) {},
790
   onPageChange: function onPageChange(page) {},
790
   onDelete: function onDelete() {},
791
   onDelete: function onDelete() {},
791
   onUpdateComment: function onUpdateComment() {},
792
   onUpdateComment: function onUpdateComment() {},
792
-  onReforeUpdateComment: function onReforeUpdateComment() {},
793
+  onBeforeUpdateComment: function onBeforeUpdateComment() {},
793
   onCountChange: function onCountChange() {}
794
   onCountChange: function onCountChange() {}
794
 };
795
 };
795
 
796
 

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


+ 7
- 3
lib/components/CommentInput/index.js View File

77
       if (action === "comment") {
77
       if (action === "comment") {
78
         this.props.app.sCreateComment({
78
         this.props.app.sCreateComment({
79
           content: value
79
           content: value
80
-        }, cb);
80
+        }, function (data) {
81
+          return cb(data, action);
82
+        });
81
       } else if (action === "reply") {
83
       } else if (action === "reply") {
82
         this.props.app.sCreateReply({
84
         this.props.app.sCreateReply({
83
           comment_id: commentId,
85
           comment_id: commentId,
84
           content: value,
86
           content: value,
85
           business_user_id: userId
87
           business_user_id: userId
86
         }, function (data) {
88
         }, function (data) {
87
-          return callback && callback(data);
89
+          callback && callback(data);
90
+          cb(data, action);
88
         });
91
         });
89
       } else if (action === "replyToReply") {
92
       } else if (action === "replyToReply") {
90
         this.props.app.sCreateReply({
93
         this.props.app.sCreateReply({
93
           reply_id: replyId,
96
           reply_id: replyId,
94
           business_user_id: userId
97
           business_user_id: userId
95
         }, function (data) {
98
         }, function (data) {
96
-          return callback && callback(data);
99
+          callback && callback(data);
100
+          cb(data, action);
97
         });
101
         });
98
       }
102
       }
99
     }
103
     }

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


+ 5
- 1
lib/components/ContentItem/index.css View File

71
   background: url(../../assert/icon_answer@2x.png);
71
   background: url(../../assert/icon_answer@2x.png);
72
   background-size: 100% 100%;
72
   background-size: 100% 100%;
73
   margin-right: 18px;
73
   margin-right: 18px;
74
-  margin-left: 10px;
74
+  /* margin-left: 10px; */
75
 }
75
 }
76
 .comment-item-like {
76
 .comment-item-like {
77
   background: url(../../assert/icon_like@2x.png);
77
   background: url(../../assert/icon_like@2x.png);
83
   margin-left: 20px;
83
   margin-left: 20px;
84
   cursor: pointer;
84
   cursor: pointer;
85
   color: red;
85
   color: red;
86
+} 
87
+.comment-item-bottom-left {
88
+  color: #71c135;
89
+  margin-right: 20px;
86
 }
90
 }
87
 .comment-favor {
91
 .comment-favor {
88
   font-size: 20px;
92
   font-size: 20px;

+ 0
- 1
lib/components/ContentItem/index.js View File

203
           showEdit = _props$app.showEdit;
203
           showEdit = _props$app.showEdit;
204
       var showInput = this.state.showInput;
204
       var showInput = this.state.showInput;
205
 
205
 
206
-
207
       var newContent = content.content;
206
       var newContent = content.content;
208
       var images = "";
207
       var images = "";
209
       if (newContent.indexOf(_constant.IMAGE_SPLIT) !== -1) {
208
       if (newContent.indexOf(_constant.IMAGE_SPLIT) !== -1) {

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


+ 16
- 3
lib/components/EditComment/EditComment.css View File

58
 .editCommetModal .comment-toolbar-right .ant-btn {
58
 .editCommetModal .comment-toolbar-right .ant-btn {
59
   height: 36px;
59
   height: 36px;
60
 }
60
 }
61
-
62
 .expression-btn-wrap,
61
 .expression-btn-wrap,
63
 .picture-btn-wrap {
62
 .picture-btn-wrap {
64
   float: left;
63
   float: left;
71
   font-size: 24px !important;
70
   font-size: 24px !important;
72
   margin: 0 !important;
71
   margin: 0 !important;
73
 }
72
 }
74
-.expression-btn-wrap .text,
75
-.picture-btn-wrap .text {
73
+.expression-btn-wrap .icon-tool-text,
74
+.picture-btn-wrap .icon-tool-text {
76
   float: left;
75
   float: left;
77
   font-size: 16px;
76
   font-size: 16px;
78
   color: #393939;
77
   color: #393939;
84
 .picture-btn-wrap .icon {
83
 .picture-btn-wrap .icon {
85
   color: rgba(113, 193, 53, 1);
84
   color: rgba(113, 193, 53, 1);
86
 }
85
 }
86
+
87
+@media (max-width: 575px) {
88
+  .editCommetModal .ant-modal,
89
+  .editCommetModal .ant-modal-content {
90
+    width: 100% !important;
91
+    height: 286px;
92
+  }
93
+  .editCommetModal .icon-tool-text {
94
+    display: none;
95
+  }
96
+  .editCommetModal .picture-btn-wrap {
97
+    margin-left: 18px;
98
+  }
99
+}

+ 4
- 4
lib/components/EditComment/EditComment.js View File

137
         _react2.default.createElement(_icon2.default, { type: "smile", className: "icon" }),
137
         _react2.default.createElement(_icon2.default, { type: "smile", className: "icon" }),
138
         _react2.default.createElement(
138
         _react2.default.createElement(
139
           "span",
139
           "span",
140
-          { className: "text" },
140
+          { className: "icon-tool-text" },
141
           _reactIntlUniversal2.default.get("bilingually.emoji")
141
           _reactIntlUniversal2.default.get("bilingually.emoji")
142
         )
142
         )
143
       );
143
       );
151
         _react2.default.createElement(_icon2.default, { type: "picture", className: "icon" }),
151
         _react2.default.createElement(_icon2.default, { type: "picture", className: "icon" }),
152
         _react2.default.createElement(
152
         _react2.default.createElement(
153
           "span",
153
           "span",
154
-          { className: "text" },
154
+          { className: "icon-tool-text" },
155
           _reactIntlUniversal2.default.get("bilingually.pic")
155
           _reactIntlUniversal2.default.get("bilingually.pic")
156
         )
156
         )
157
       );
157
       );
185
         _react2.default.createElement(
185
         _react2.default.createElement(
186
           "div",
186
           "div",
187
           { className: "title" },
187
           { className: "title" },
188
-          _reactIntlUniversal2.default.get("bilingually.imgtxt.edit_imgtxt")
188
+          _reactIntlUniversal2.default.get("comment.edit")
189
         ),
189
         ),
190
         _react2.default.createElement(_CommentInput2.default, {
190
         _react2.default.createElement(_CommentInput2.default, {
191
           content: _react2.default.createElement(_Editor2.default, {
191
           content: _react2.default.createElement(_Editor2.default, {
213
             imageToolIcon: this.getImageToolIcon(),
213
             imageToolIcon: this.getImageToolIcon(),
214
             emojiPopoverPlacement: "bottom",
214
             emojiPopoverPlacement: "bottom",
215
             uploadPopoverPlacement: "bottom",
215
             uploadPopoverPlacement: "bottom",
216
-            btnSubmitText: _reactIntlUniversal2.default.get("bilingually.imgtxt.update")
216
+            btnSubmitText: _reactIntlUniversal2.default.get("comment.update")
217
           })
217
           })
218
         })
218
         })
219
       );
219
       );

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


+ 5
- 4
lib/components/Editor/index.js View File

247
       if (this.props.beforeSubmit) {
247
       if (this.props.beforeSubmit) {
248
         Promise.resolve(this.props.beforeSubmit({ text: value, files: files })).then(function (res) {
248
         Promise.resolve(this.props.beforeSubmit({ text: value, files: files })).then(function (res) {
249
           if (!(res === false)) {
249
           if (!(res === false)) {
250
-            _this2.props.onSubmit({ text: value, files: files }, function (res) {
250
+            _this2.props.onSubmit({ text: value, files: files }, function (res, action) {
251
               _this2.resetState();
251
               _this2.resetState();
252
-              if (_this2.props.onCommentSuccess) {
252
+              if (action === "comment" && _this2.props.onCommentSuccess) {
253
                 _this2.props.onCommentSuccess(res);
253
                 _this2.props.onCommentSuccess(res);
254
               }
254
               }
255
             });
255
             });
256
           }
256
           }
257
         });
257
         });
258
       } else {
258
       } else {
259
-        this.props.onSubmit({ text: value, files: files }, function (res) {
259
+        this.props.onSubmit({ text: value, files: files }, function (res, action) {
260
           _this2.resetState();
260
           _this2.resetState();
261
-          if (_this2.props.onCommentSuccess) {
261
+          if (action === "comment" && _this2.props.onCommentSuccess) {
262
             _this2.props.onCommentSuccess(res);
262
             _this2.props.onCommentSuccess(res);
263
           }
263
           }
264
         });
264
         });
267
   }, {
267
   }, {
268
     key: "resetState",
268
     key: "resetState",
269
     value: function resetState() {
269
     value: function resetState() {
270
+      this.handleChange("");
270
       this.setState({
271
       this.setState({
271
         showUpload: false,
272
         showUpload: false,
272
         value: "",
273
         value: "",

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


+ 9
- 2
lib/index.js View File

35
     var _this = _possibleConstructorReturn(this, (Index.__proto__ || Object.getPrototypeOf(Index)).call(this, props));
35
     var _this = _possibleConstructorReturn(this, (Index.__proto__ || Object.getPrototypeOf(Index)).call(this, props));
36
 
36
 
37
     _this.state = {
37
     _this.state = {
38
-      fileList: [],
39
-      value: ""
38
+      fileList: [
39
+        // {
40
+        //   url:
41
+        //     "//links-comment.oss-cn-beijing.aliyuncs.com/comment/20190727/YQ-4VC1bL.jpeg",
42
+        //   type: "image/jpeg",
43
+        //   uid: "rc-upload-1564206005248-2"
44
+        // }
45
+      ],
46
+      value: "2"
40
     };
47
     };
41
     return _this;
48
     return _this;
42
   }
49
   }

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


+ 3
- 3
lib/version.json View File

1
 {
1
 {
2
     "name":       "comment",
2
     "name":       "comment",
3
-    "buildDate":  1564144081929,
3
+    "buildDate":  1564190100286,
4
     "version":    "1.0.4",
4
     "version":    "1.0.4",
5
-    "numCommits": 172,
6
-    "hash":       "aef6d87",
5
+    "numCommits": 173,
6
+    "hash":       "b9eeb6a",
7
     "dirty":      true
7
     "dirty":      true
8
 }
8
 }

+ 4
- 0
src/App.css View File

28
 .comment-img {
28
 .comment-img {
29
   max-width: 100%;
29
   max-width: 100%;
30
 }
30
 }
31
+
32
+.ant-upload-picture-card-wrapper {
33
+  width: 100%;
34
+}

+ 5
- 4
src/App.js View File

61
     this.axios = axios;
61
     this.axios = axios;
62
     this.axios.defaults.withCredentials = true;
62
     this.axios.defaults.withCredentials = true;
63
     if (this.props.token) {
63
     if (this.props.token) {
64
-      this.axios.defaults.headers.common["Authorization"] = `Bearer ${
65
-        this.props.token
66
-      }`;
64
+      this.axios.defaults.headers.common[
65
+        "Authorization"
66
+      ] = `Bearer ${this.props.token}`;
67
     }
67
     }
68
   }
68
   }
69
 
69
 
287
         const { list, total } = this.state;
287
         const { list, total } = this.state;
288
         list.unshift({
288
         list.unshift({
289
           ...response.data,
289
           ...response.data,
290
+          replies: [],
290
           isTemporary: true // 临时的数据
291
           isTemporary: true // 临时的数据
291
         });
292
         });
292
         this.setState({ list, total: total + 1 });
293
         this.setState({ list, total: total + 1 });
641
   onPageChange: page => {},
642
   onPageChange: page => {},
642
   onDelete: () => {},
643
   onDelete: () => {},
643
   onUpdateComment: () => {},
644
   onUpdateComment: () => {},
644
-  onReforeUpdateComment: () => {},
645
+  onBeforeUpdateComment: () => {},
645
   onCountChange: () => {}
646
   onCountChange: () => {}
646
 };
647
 };
647
 
648
 

+ 9
- 3
src/components/CommentInput/index.js View File

33
         {
33
         {
34
           content: value
34
           content: value
35
         },
35
         },
36
-        cb
36
+        data => cb(data, action)
37
       );
37
       );
38
     } else if (action === "reply") {
38
     } else if (action === "reply") {
39
       this.props.app.sCreateReply(
39
       this.props.app.sCreateReply(
42
           content: value,
42
           content: value,
43
           business_user_id: userId
43
           business_user_id: userId
44
         },
44
         },
45
-        data => callback && callback(data)
45
+        data => {
46
+          callback && callback(data);
47
+          cb(data, action);
48
+        }
46
       );
49
       );
47
     } else if (action === "replyToReply") {
50
     } else if (action === "replyToReply") {
48
       this.props.app.sCreateReply(
51
       this.props.app.sCreateReply(
52
           reply_id: replyId,
55
           reply_id: replyId,
53
           business_user_id: userId
56
           business_user_id: userId
54
         },
57
         },
55
-        data => callback && callback(data)
58
+        data => {
59
+          callback && callback(data);
60
+          cb(data, action);
61
+        }
56
       );
62
       );
57
     }
63
     }
58
   }
64
   }

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

71
   background: url(../../assert/icon_answer@2x.png);
71
   background: url(../../assert/icon_answer@2x.png);
72
   background-size: 100% 100%;
72
   background-size: 100% 100%;
73
   margin-right: 18px;
73
   margin-right: 18px;
74
-  margin-left: 10px;
74
+  /* margin-left: 10px; */
75
 }
75
 }
76
 .comment-item-like {
76
 .comment-item-like {
77
   background: url(../../assert/icon_like@2x.png);
77
   background: url(../../assert/icon_like@2x.png);
84
   cursor: pointer;
84
   cursor: pointer;
85
   color: red;
85
   color: red;
86
 }
86
 }
87
+.comment-item-bottom-left {
88
+  color: #71c135;
89
+  margin-right: 20px;
90
+}
87
 .comment-favor {
91
 .comment-favor {
88
   font-size: 20px;
92
   font-size: 20px;
89
 }
93
 }

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

105
     } = this.props;
105
     } = this.props;
106
     const { locale, showHoverCard, showEdit } = this.props.app;
106
     const { locale, showHoverCard, showEdit } = this.props.app;
107
     const { showInput } = this.state;
107
     const { showInput } = this.state;
108
-
109
     let newContent = content.content;
108
     let newContent = content.content;
110
     let images = "";
109
     let images = "";
111
     if (newContent.indexOf(IMAGE_SPLIT) !== -1) {
110
     if (newContent.indexOf(IMAGE_SPLIT) !== -1) {

+ 16
- 3
src/components/EditComment/EditComment.css View File

58
 .editCommetModal .comment-toolbar-right .ant-btn {
58
 .editCommetModal .comment-toolbar-right .ant-btn {
59
   height: 36px;
59
   height: 36px;
60
 }
60
 }
61
-
62
 .expression-btn-wrap,
61
 .expression-btn-wrap,
63
 .picture-btn-wrap {
62
 .picture-btn-wrap {
64
   float: left;
63
   float: left;
71
   font-size: 24px !important;
70
   font-size: 24px !important;
72
   margin: 0 !important;
71
   margin: 0 !important;
73
 }
72
 }
74
-.expression-btn-wrap .text,
75
-.picture-btn-wrap .text {
73
+.expression-btn-wrap .icon-tool-text,
74
+.picture-btn-wrap .icon-tool-text {
76
   float: left;
75
   float: left;
77
   font-size: 16px;
76
   font-size: 16px;
78
   color: #393939;
77
   color: #393939;
84
 .picture-btn-wrap .icon {
83
 .picture-btn-wrap .icon {
85
   color: rgba(113, 193, 53, 1);
84
   color: rgba(113, 193, 53, 1);
86
 }
85
 }
86
+
87
+@media (max-width: 575px) {
88
+  .editCommetModal .ant-modal,
89
+  .editCommetModal .ant-modal-content {
90
+    width: 100% !important;
91
+    height: 286px;
92
+  }
93
+  .editCommetModal .icon-tool-text {
94
+    display: none;
95
+  }
96
+  .editCommetModal .picture-btn-wrap {
97
+    margin-left: 18px;
98
+  }
99
+}

+ 4
- 6
src/components/EditComment/EditComment.js View File

66
     return (
66
     return (
67
       <div className="expression-btn-wrap">
67
       <div className="expression-btn-wrap">
68
         <Icon type="smile" className="icon" />
68
         <Icon type="smile" className="icon" />
69
-        <span className="text">{intl.get("bilingually.emoji")}</span>
69
+        <span className="icon-tool-text">{intl.get("bilingually.emoji")}</span>
70
       </div>
70
       </div>
71
     );
71
     );
72
   }
72
   }
75
     return (
75
     return (
76
       <div className="picture-btn-wrap">
76
       <div className="picture-btn-wrap">
77
         <Icon type="picture" className="icon" />
77
         <Icon type="picture" className="icon" />
78
-        <span className="text">{intl.get("bilingually.pic")}</span>
78
+        <span className="icon-tool-text">{intl.get("bilingually.pic")}</span>
79
       </div>
79
       </div>
80
     );
80
     );
81
   }
81
   }
100
         wrapClassName="editCommetModal"
100
         wrapClassName="editCommetModal"
101
         onCancel={this.props.handleClose}
101
         onCancel={this.props.handleClose}
102
       >
102
       >
103
-        <div className="title">
104
-          {intl.get("bilingually.imgtxt.edit_imgtxt")}
105
-        </div>
103
+        <div className="title">{intl.get("comment.edit")}</div>
106
         <CommentInput
104
         <CommentInput
107
           content={
105
           content={
108
             <Editor
106
             <Editor
130
               imageToolIcon={this.getImageToolIcon()}
128
               imageToolIcon={this.getImageToolIcon()}
131
               emojiPopoverPlacement="bottom"
129
               emojiPopoverPlacement="bottom"
132
               uploadPopoverPlacement="bottom"
130
               uploadPopoverPlacement="bottom"
133
-              btnSubmitText={intl.get("bilingually.imgtxt.update")}
131
+              btnSubmitText={intl.get("comment.update")}
134
             />
132
             />
135
           }
133
           }
136
         />
134
         />

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

147
       Promise.resolve(this.props.beforeSubmit({ text: value, files })).then(
147
       Promise.resolve(this.props.beforeSubmit({ text: value, files })).then(
148
         res => {
148
         res => {
149
           if (!(res === false)) {
149
           if (!(res === false)) {
150
-            this.props.onSubmit({ text: value, files }, res => {
150
+            this.props.onSubmit({ text: value, files }, (res, action) => {
151
               this.resetState();
151
               this.resetState();
152
-              if (this.props.onCommentSuccess) {
152
+              if (action === "comment" && this.props.onCommentSuccess) {
153
                 this.props.onCommentSuccess(res);
153
                 this.props.onCommentSuccess(res);
154
               }
154
               }
155
             });
155
             });
157
         }
157
         }
158
       );
158
       );
159
     } else {
159
     } else {
160
-      this.props.onSubmit({ text: value, files }, res => {
160
+      this.props.onSubmit({ text: value, files }, (res, action) => {
161
         this.resetState();
161
         this.resetState();
162
-        if (this.props.onCommentSuccess) {
162
+        if (action === "comment" && this.props.onCommentSuccess) {
163
           this.props.onCommentSuccess(res);
163
           this.props.onCommentSuccess(res);
164
         }
164
         }
165
       });
165
       });
167
   }
167
   }
168
 
168
 
169
   resetState() {
169
   resetState() {
170
+    this.handleChange("");
170
     this.setState({
171
     this.setState({
171
       showUpload: false,
172
       showUpload: false,
172
       value: "",
173
       value: "",

+ 9
- 2
src/index.js View File

7
   constructor(props) {
7
   constructor(props) {
8
     super(props);
8
     super(props);
9
     this.state = {
9
     this.state = {
10
-      fileList: [],
11
-      value: ""
10
+      fileList: [
11
+        // {
12
+        //   url:
13
+        //     "//links-comment.oss-cn-beijing.aliyuncs.com/comment/20190727/YQ-4VC1bL.jpeg",
14
+        //   type: "image/jpeg",
15
+        //   uid: "rc-upload-1564206005248-2"
16
+        // }
17
+      ],
18
+      value: "2"
12
     };
19
     };
13
   }
20
   }
14
 
21