Browse Source

renderComment 暴露所有配置

narrowizard 6 years ago
parent
commit
683ff01fa8
1 changed files with 4 additions and 12 deletions
  1. 4
    12
      src/index.js

+ 4
- 12
src/index.js View File

5
 
5
 
6
 const Index = props => (
6
 const Index = props => (
7
   <App showAlertComment showAlertReply showAlertFavor showError {...props}>
7
   <App showAlertComment showAlertReply showAlertFavor showError {...props}>
8
-    <Editor maxUpload={9} autoFocus />
8
+    <Editor maxUpload={9} autoFocus {...props.editorProps} />
9
   </App>
9
   </App>
10
 );
10
 );
11
 
11
 
26
   }
26
   }
27
   if (!config.businessId) {
27
   if (!config.businessId) {
28
     // throw new Error("businessId is required");
28
     // throw new Error("businessId is required");
29
+    config.businessId = "test";
29
     console.warn("没有传入 businessId 参数,默认使用: test");
30
     console.warn("没有传入 businessId 参数,默认使用: test");
30
   }
31
   }
31
   if (!config.API) {
32
   if (!config.API) {
32
     // throw new Error("API is required");
33
     // throw new Error("API is required");
34
+    config.API = "http://api.links123.net/comment/v1";
33
     console.warn(
35
     console.warn(
34
       "没有传入 API 参数,默认使用: http://api.links123.net/comment/v1"
36
       "没有传入 API 参数,默认使用: http://api.links123.net/comment/v1"
35
     );
37
     );
36
   }
38
   }
37
-  const {
38
-    id,
39
-    type = 1,
40
-    businessId = "test",
41
-    API = "http://api.links123.net/comment/v1",
42
-    userId
43
-  } = config;
44
 
39
 
45
-  ReactDOM.render(
46
-    <Index type={type} businessId={businessId} API={API} userId={userId} />,
47
-    document.getElementById(id)
48
-  );
40
+  ReactDOM.render(<Index {...config} />, document.getElementById(config.id));
49
   // registerServiceWorker();
41
   // registerServiceWorker();
50
 }
42
 }
51
 
43