Преглед изворни кода

Merge branch 'master' of Hepper/comment into master

AdamFu пре 5 година
родитељ
комит
5c85f11c90

+ 2
- 2
src/App.js Прегледај датотеку

@@ -246,7 +246,7 @@ class App extends Component {
246 246
         if (this.props.showAlertComment) {
247 247
           message.success(intl.get("message.success"));
248 248
         }
249
-        if (isFunction(cb)) cb();
249
+        if (isFunction(cb)) cb(response.data);
250 250
         // 将数据写入到 list 中
251 251
         // 临时插入
252 252
         // 等到获取数据之后,删除临时数据
@@ -305,7 +305,7 @@ class App extends Component {
305 305
         if (this.props.showAlertReply) {
306 306
           message.success(intl.get("message.replySuccess"));
307 307
         }
308
-        if (isFunction(cb)) cb();
308
+        if (isFunction(cb)) cb(response.data);
309 309
         // 将数据写入到 list 中
310 310
         // 临时插入
311 311
         // 等到获取数据之后,删除临时数据

+ 10
- 9
src/components/CommentInput/index.js Прегледај датотеку

@@ -36,14 +36,15 @@ class CommentInput extends Component {
36 36
         cb
37 37
       );
38 38
     } else if (action === "reply") {
39
-      this.props.app.sCreateReply(
40
-        {
41
-          comment_id: commentId,
42
-          content: value,
43
-          business_user_id: userId
44
-        },
45
-        () => callback && callback()
46
-      );
39
+      console.log("[[[", callback);
40
+      // this.props.app.sCreateReply(
41
+      //   {
42
+      //     comment_id: commentId,
43
+      //     content: value,
44
+      //     business_user_id: userId
45
+      //   },
46
+      //   (data) => callback && callback(data)
47
+      // );
47 48
     } else if (action === "replyToReply") {
48 49
       this.props.app.sCreateReply(
49 50
         {
@@ -52,7 +53,7 @@ class CommentInput extends Component {
52 53
           reply_id: replyId,
53 54
           business_user_id: userId
54 55
         },
55
-        () => callback && callback()
56
+        data => callback && callback(data)
56 57
       );
57 58
     }
58 59
   }

+ 12
- 6
src/components/ContentItem/index.js Прегледај датотеку

@@ -61,6 +61,14 @@ class CommentItem extends Component {
61 61
     });
62 62
   }
63 63
 
64
+  handleUserAvaClick = () => {
65
+    const { user_id } = this.props;
66
+    const { userAvaClick } = this.props.app;
67
+    if (userAvaClick) {
68
+      userAvaClick(user_id);
69
+    }
70
+  };
71
+
64 72
   renderTextWithReply(text, content) {
65 73
     let newText = text;
66 74
     const { reply } = content;
@@ -94,7 +102,7 @@ class CommentItem extends Component {
94 102
       user_id
95 103
     } = this.props;
96 104
 
97
-    const { locale, userAvaClick, showHoverCard } = this.props.app;
105
+    const { locale, showHoverCard } = this.props.app;
98 106
     const { showInput } = this.state;
99 107
 
100 108
     let newContent = content.content;
@@ -147,7 +155,7 @@ class CommentItem extends Component {
147 155
                 style={{
148 156
                   backgroundImage: `url(${content.user_avatar || avatar})`
149 157
                 }}
150
-                onClick={() => userAvaClick(user_id)}
158
+                onClick={this.handleUserAvaClick}
151 159
               />
152 160
             </Popover>
153 161
           ) : (
@@ -156,9 +164,7 @@ class CommentItem extends Component {
156 164
               style={{
157 165
                 backgroundImage: `url(${content.user_avatar || avatar})`
158 166
               }}
159
-              onClick={() => {
160
-                userAvaClick(user_id);
161
-              }}
167
+              onClick={this.handleUserAvaClick}
162 168
             />
163 169
           )}
164 170
         </div>
@@ -168,7 +174,7 @@ class CommentItem extends Component {
168 174
               {content.user_name || "暂无昵称"}
169 175
             </a> */}
170 176
             <strong
171
-              onClick={() => userAvaClick(user_id)}
177
+              onClick={this.handleUserAvaClick}
172 178
               style={{ cursor: "pointer" }}
173 179
             >
174 180
               {content.user_name || intl.get("comment.tourist")}

+ 5
- 0
src/components/Editor/Upload.css Прегледај датотеку

@@ -7,3 +7,8 @@
7 7
   margin-top: 8px;
8 8
   color: #666;
9 9
 }
10
+
11
+.upload-img-preview .ant-modal-close {
12
+  top: -10px;
13
+  right: -15px;
14
+}

+ 1
- 0
src/components/Editor/Upload.js Прегледај датотеку

@@ -124,6 +124,7 @@ class App extends React.Component {
124 124
           {fileList.length >= maxUpload ? null : uploadButton}
125 125
         </Upload>
126 126
         <Modal
127
+          className="upload-img-preview"
127 128
           visible={previewVisible}
128 129
           footer={null}
129 130
           onCancel={this.handleCancel}

+ 4
- 4
src/components/Editor/index.js Прегледај датотеку

@@ -147,20 +147,20 @@ class Editor extends React.Component {
147 147
       Promise.resolve(this.props.beforeSubmit({ text: value, files })).then(
148 148
         res => {
149 149
           if (!(res === false)) {
150
-            this.props.onSubmit({ text: value, files }, () => {
150
+            this.props.onSubmit({ text: value, files }, res => {
151 151
               this.resetState();
152 152
               if (this.props.onCommentSuccess) {
153
-                this.props.onCommentSuccess();
153
+                this.props.onCommentSuccess(res);
154 154
               }
155 155
             });
156 156
           }
157 157
         }
158 158
       );
159 159
     } else {
160
-      this.props.onSubmit({ text: value, files }, () => {
160
+      this.props.onSubmit({ text: value, files }, res => {
161 161
         this.resetState();
162 162
         if (this.props.onCommentSuccess) {
163
-          this.props.onCommentSuccess();
163
+          this.props.onCommentSuccess(res);
164 164
         }
165 165
       });
166 166
     }

+ 5
- 1
src/index.js Прегледај датотеку

@@ -123,7 +123,11 @@ if (process.env.NODE_ENV !== "production") {
123 123
     onCountChange: c => {
124 124
       console.log(c);
125 125
     },
126
-    editorProps: {}
126
+    editorProps: {
127
+      onCommentSuccess: data => {
128
+        console.log(data);
129
+      }
130
+    }
127 131
   });
128 132
 }
129 133