Browse Source

feat: update params of oSubmit

node 6 years ago
parent
commit
924f2804d1
3 changed files with 14 additions and 6 deletions
  1. 2
    1
      README.md
  2. 9
    2
      src/components/CommentInput/index.js
  3. 3
    3
      src/components/Editor/index.js

+ 2
- 1
README.md View File

@@ -8,6 +8,7 @@
8 8
 import Comment, { Editor } from 'comment';
9 9
 ```
10 10
 
11
+- [deprecate] 表示不推荐使用
11 12
 
12 13
 ## Props
13 14
 
@@ -22,7 +23,7 @@ import Comment, { Editor } from 'comment';
22 23
 | showList   | boolean | true                               | false    | 是否显示评论列表                             |
23 24
 | showEditor | boolean | true                               | false    | 是否显示评论输入框                           |
24 25
 | showHeader | boolean | true                               | false    | 是否显示评论顶部的提示                       |
25
-| token      | string  |                                    | false    | token,用于身份认证,非必须。默认使用 cookie |
26
+| token    | string  |                                    | false    |  [deprecate] token,用于身份认证,非必须。默认使用 cookie |
26 27
 
27 28
 
28 29
 

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

@@ -11,10 +11,17 @@ class CommentInput extends Component {
11 11
 
12 12
   /**
13 13
    * 提交评论
14
-   * @param {string} value 需要提交的评论的值
14
+   * @param {object} { text<string>, files<array> } 需要提交的评论的文本和图片
15 15
    * @param {function} cb 提交成功后的回掉
16 16
    */
17
-  handleSubmit(value, cb) {
17
+  handleSubmit({ text, files }, cb) {
18
+    let value = text;
19
+    if (files && files.length) {
20
+      value += "<br /><br />";
21
+      files.forEach(file => {
22
+        value += `[${file}]`;
23
+      });
24
+    }
18 25
     const { action, commentId, replyId, callback } = this.props;
19 26
     if (action === "comment") {
20 27
       this.props.app.sCreateComment(

+ 3
- 3
src/components/Editor/index.js View File

@@ -91,13 +91,13 @@ class Editor extends React.Component {
91 91
    */
92 92
   handleSubmit() {
93 93
     let { value, fileMap, fileList } = this.state;
94
+    const files = [];
94 95
     if (fileList.length) {
95
-      value += "<br/>";
96 96
       fileList.forEach(item => {
97
-        value += `[${OSS_LINK}${fileMap[item.uid]}]`;
97
+        files.push(`${OSS_LINK}${fileMap[item.uid]}`);
98 98
       });
99 99
     }
100
-    this.props.onSubmit(value, () => {
100
+    this.props.onSubmit({ text: value, files }, () => {
101 101
       this.setState({
102 102
         showUpload: false,
103 103
         value: "",