node преди 6 години
родител
ревизия
30c30d6538
променени са 40 файла, в които са добавени 455 реда и са изтрити 198 реда
  1. 5
    0
      CHANGELOG.md
  2. 42
    33
      README.md
  3. 2
    2
      assets/example.html
  4. 10
    7
      assets/example.js
  5. 0
    1
      assets/static/css/main.81c08691.css.map
  6. 2
    2
      assets/static/css/main.a3c3a441.css
  7. 1
    0
      assets/static/css/main.a3c3a441.css.map
  8. 2
    0
      assets/static/js/main.426815d8.js
  9. 1
    0
      assets/static/js/main.426815d8.js.map
  10. 0
    2
      assets/static/js/main.9d10db91.js
  11. 0
    1
      assets/static/js/main.9d10db91.js.map
  12. 112
    56
      lib/App.js
  13. 1
    1
      lib/App.js.map
  14. 7
    2
      lib/components/CommentBox/index.js
  15. 1
    1
      lib/components/CommentBox/index.js.map
  16. 6
    4
      lib/components/CommentList/index.js
  17. 1
    1
      lib/components/CommentList/index.js.map
  18. 23
    10
      lib/components/ContentItem/index.js
  19. 1
    1
      lib/components/ContentItem/index.js.map
  20. 5
    1
      lib/components/Editor/Upload.js
  21. 1
    1
      lib/components/Editor/Upload.js.map
  22. 20
    26
      lib/components/Editor/index.js
  23. 1
    1
      lib/components/Editor/index.js.map
  24. 7
    2
      lib/components/ImagePreviewer/ImagePreviewer.js
  25. 1
    1
      lib/components/ImagePreviewer/ImagePreviewer.js.map
  26. 5
    0
      lib/constant.js
  27. 1
    1
      lib/constant.js.map
  28. 24
    10
      lib/index.js
  29. 1
    1
      lib/index.js.map
  30. 43
    0
      lib/lang/en-US.js
  31. 1
    0
      lib/lang/en-US.js.map
  32. 37
    15
      lib/lang/index.js
  33. 1
    1
      lib/lang/index.js.map
  34. 43
    0
      lib/lang/zh-CN.js
  35. 1
    0
      lib/lang/zh-CN.js.map
  36. 1
    1
      package.json
  37. 6
    2
      src/App.js
  38. 8
    6
      src/components/Editor/index.js
  39. 5
    0
      src/constant.js
  40. 26
    5
      src/index.js

+ 5
- 0
CHANGELOG.md Целия файл

@@ -1,8 +1,13 @@
1 1
 # CHANGELOG
2 2
 
3
+<<<<<<< HEAD
3 4
 ## 1.0.0
4 5
 
5 6
 - [x] 完成通用评论国际化
7
+=======
8
+## 0.5.14
9
+- [x] 增加onDelete回调
10
+>>>>>>> upstream/master
6 11
 
7 12
 ## 0.5.13
8 13
 - [x] emoji增加到每页30个

+ 42
- 33
README.md Целия файл

@@ -2,7 +2,7 @@
2 2
 
3 3
 通用评论系统及编辑器
4 4
 
5
-**`version 0.5.13`**
5
+**`version 0.5.14`**
6 6
 
7 7
 ```js
8 8
 import Comment, { Editor, RenderText } from 'comment';
@@ -42,11 +42,14 @@ render() {
42 42
 
43 43
 ### 在非 React.js 项目中使用 ~~作为静态文件引入~~
44 44
 
45
-1. 引入通用评论的 css 和 js 文件。在 `./assets/static` 目录。
45
+**使用`assets` 分支的 `./assets/static` 目录[https://git.links123.net/npm/comment/src/branch/assets/assets/static](https://git.links123.net/npm/comment/src/branch/assets/assets/static)的静态文件**
46
+
47
+1. 引入通用评论的 css 和 js 文件。在 `assets` 分支的 `./assets/static` 目录: [https://git.links123.net/npm/comment/src/branch/assets/assets/static](https://git.links123.net/npm/comment/src/branch/assets/assets/static)。
46 48
 2. 调用 `window.renderComment` 方法并传入对应参数来渲染通用评论。参数列表:
47 49
   - `id`: string, 必填, 渲染评论的节点的 ID
48 50
   - `type`: number, 必填, 评论的 type    
49
-  - `businessId`: string, 必填, 评论的 businessId    
51
+  - `businessId`: string, 选填, 评论的 businessId,默认 test
52
+  - `API`: string, 选填, 评论的 businessId,默认 http://api.links123.net/comment/v1
50 53
 
51 54
 具体可参考 `./assets/example.html`。
52 55
 
@@ -74,10 +77,11 @@ render() {
74 77
   <script type="text/javascript">
75 78
     // 调用 renderComment 这个方法,渲染通用评论
76 79
     window.renderComment({
77
-      id: 'comment', // 渲染通用评论到 comment 这个节点,id 名称可 自定义
78
-      type: 1, // 评论的 type
79
-      businessId: 'test' // 评论的 businessId
80
-    })
80
+      id: 'comment', // required, 渲染通用评论到 comment 这个节点,id 名称可 自定义
81
+      type: 1, // required, 评论的 type
82
+      businessId: 'test' // 评论的 businessId, 默认 test
83
+      API: 'http://api.links123.net/comment/v1', // API 前缀, 默认 http://api.links123.net/comment/v1 
84
+    });
81 85
   </script>
82 86
 </body>
83 87
 </html>
@@ -98,11 +102,11 @@ render() {
98 102
 
99 103
 ```html
100 104
 <!-- ... -->
101
-  <link rel="stylesheet" type="text/css" media="screen" href="./static/css/comment.0.5.13.css" />
105
+  <link rel="stylesheet" type="text/css" media="screen" href="./static/css/xxx.css" />
102 106
 <!-- ... -->
103 107
   <div id="RENDER_ELEMENT_WRAPPER"></div>
104 108
 <!-- ... -->
105
-  <script type="text/javascript" src="./static/js/comment.0.5.13.js"></script>
109
+  <script type="text/javascript" src="./static/js/xxx.js"></script>
106 110
 <!-- ... -->
107 111
 ```
108 112
 
@@ -143,7 +147,8 @@ function main() {
143 147
     window.renderComment({
144 148
       id: id,
145 149
       type: 1,
146
-      businessId: 'test'
150
+      businessId: 'test',
151
+      API: 'http://api.links123.net/comment/v1',
147 152
     })
148 153
   })
149 154
   
@@ -154,22 +159,24 @@ function main() {
154 159
     window.renderComment({
155 160
       id: id,
156 161
       type: 1,
157
-      businessId: 'test1'
162
+      businessId: 'test1',
163
+      API: 'http://api.links123.net/comment/v1',
158 164
     })
159 165
   })
160
-
161 166
 }
162 167
 
163 168
 main();
164 169
 ```
165 170
 
166
-#### class 样式冲突
171
+#### ~~class 样式冲突~~
167 172
 
168
-`master` 分支的图片预览 `container` 样式和 boostrap 有冲突。在 [`fix/classname`](https://git.links123.net/node/npmcomment/src/branch/fix/classname) 分支对评论的样式名称做了修改,改为了 `comment-image-preview-container`
173
+> assets 分支已修复
169 174
 
170
-解决办法就是使用 [`fix/classname`](https://git.links123.net/node/npmcomment/src/branch/fix/classname) 分支中的静态文件:
175
+~~`master` 分支的图片预览 `container` 样式和 boostrap 有冲突。在 [`fix/classname`](https://git.links123.net/node/npmcomment/src/branch/fix/classname) 分支对评论的样式名称做了修改,改为了 `comment-image-preview-container`。~~
171 176
 
177
+解决办法就是使用 [`fix/classname`](https://git.links123.net/node/npmcomment/src/branch/fix/classname) 分支中的静态文件:
172 178
 
179
+- [https://git.links123.net/node/npmcomment/src/branch/fix/classname](https://git.links123.net/node/npmcomment/src/branch/fix/classname)
173 180
 - static: [https://git.links123.net/node/npmcomment/src/branch/fix/classname/assets/static](https://git.links123.net/node/npmcomment/src/branch/fix/classname/assets/static)
174 181
 
175 182
 
@@ -181,24 +188,26 @@ main();
181 188
 - 标记了`deprecated`的配置项表示不推荐使用,并且可能在将来版本中不再受支持。
182 189
 
183 190
 
184
-| props            | type           | default                            | required | description                                                                       |
185
-| ---------------- | -------------- | ---------------------------------- | -------- | --------------------------------------------------------------------------------- |
186
-| type             | number         |                                    | true     | 评论的 type                                                                       |
187
-| businessId       | string         |                                    | true     | 评论的 business id                                                                |
188
-| API              | string         | http://api.links123.net/comment/v1 | false    | API 前缀                                                                          |
189
-| showList         | boolean        | true                               | false    | 是否显示评论列表                                                                  |
190
-| showEditor       | boolean        | true                               | false    | 是否显示评论输入框                                                                |
191
-| showAlertComment | boolean        | false                              | false    | 评论成功之后,是否通过 Antd 的 Message 组件进行提示                               |
192
-| showAlertReply   | boolean        | false                              | false    | 回复成功之后,是否通过 Antd 的 Message 组件进行提示                               |
193
-| showAlertFavor   | boolean        | false                              | false    | 点赞/取消点赞成功之后,是否通过 Antd 的 Message 组件进行提示                      |
194
-| showError        | boolean        | true                               | false    | 是否使用Antd的Message组件提示错误信息                                             |
195
-| onError          | function(msg)  |                                    | false    | 错误回调, 出错了会被调用                                                          |
196
-| userId           | number         |                                    | false    | 用户id, comment内部不维护用户id, 调用组件时传递过来, 目前用于判断是否显示删除按钮 |
197
-| token            | string         |                                    | false    | [deprecated] token,用于身份认证,非必须。默认使用 cookie                         |
198
-| pageType         | string         | more                               | false    | 分页类别, more-加载更多 pagination-页码                                          |
199
-| page             | number         |                                    | false    | 页码受控模式,如果传递了此参数,则需要通过onPageChange回调手动维护page.             |
200
-| onPageChange     | function(page) |                                    | false    | 页码发生变化时的回调,注意:分页数据获取还是在组件内部处理的                        |
201
-| locales          | string         | 语言                                | false    | 语言,zh-CN/en-US。默认根据 url 中的 lang 参数来获取。所以一般情况可不传入       |
191
+| props            | type           | default                            | required | description                                                                           |
192
+| ---------------- | -------------- | ---------------------------------- | -------- | ------------------------------------------------------------------------------------- |
193
+| type             | number         |                                    | true     | 评论的 type                                                                           |
194
+| businessId       | string         |                                    | true     | 评论的 business id                                                                    |
195
+| API              | string         | http://api.links123.net/comment/v1 | false    | API 前缀                                                                              |
196
+| showList         | boolean        | true                               | false    | 是否显示评论列表                                                                      |
197
+| showEditor       | boolean        | true                               | false    | 是否显示评论输入框                                                                    |
198
+| showAlertComment | boolean        | false                              | false    | 评论成功之后,是否通过 Antd 的 Message 组件进行提示                                   |
199
+| showAlertReply   | boolean        | false                              | false    | 回复成功之后,是否通过 Antd 的 Message 组件进行提示                                   |
200
+| showAlertFavor   | boolean        | false                              | false    | 点赞/取消点赞成功之后,是否通过 Antd 的 Message 组件进行提示                          |
201
+| showError        | boolean        | true                               | false    | 是否使用Antd的Message组件提示错误信息                                                 |
202
+| onError          | function(msg)  |                                    | false    | 错误回调, 出错了会被调用                                                              |
203
+| userId           | number         |                                    | false    | 用户id, comment内部不维护用户id, 调用组件时传递过来, 目前用于判断是否显示删除按钮     |
204
+| token            | string         |                                    | false    | [deprecated] token,用于身份认证,非必须。默认使用 cookie                             |
205
+| pageType         | string         | more                               | false    | 分页类别, more-加载更多 pagination-页码                                              |
206
+| page             | number         |                                    | false    | 页码受控模式,如果传递了此参数,则需要通过onPageChange回调手动维护page.                 |
207
+| onPageChange     | function(page) |                                    | false    | 页码发生变化时的回调,注意:分页数据获取还是在组件内部处理的                            |
208
+| onDelete         | function(type) |                                    | false    | 评论或回复删除成功后的回调, type: "comment" \| "reply" , 用于区分删除的是评论还是回复 |
209
+| locales          | string         | 语言                                | false    | 语言,zh-CN/en-US。默认根据 url 中的 lang 参数来获取。所以一般情况可不传入       
210
+
202 211
 
203 212
 ## Editor
204 213
 

+ 2
- 2
assets/example.html Целия файл

@@ -5,7 +5,7 @@
5 5
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 6
   <title>通用评论 demo</title>
7 7
   <meta name="viewport" content="width=device-width, initial-scale=1">
8
-  <link rel="stylesheet" type="text/css" media="screen" href="./static/css/main.81c08691.css" />
8
+  <link rel="stylesheet" type="text/css" media="screen" href="./static/css/main.a3c3a441.css" />
9 9
 </head>
10 10
 <body>
11 11
   <div>
@@ -20,7 +20,7 @@
20 20
   </div>
21 21
   
22 22
   <script src="http://gosspublic.alicdn.com/aliyun-oss-sdk.min.js"></script>
23
-  <script type="text/javascript" src="./static/js/main.9d10db91.js"></script>
23
+  <script type="text/javascript" src="./static/js/main.426815d8.js"></script>
24 24
   <script type="text/javascript" src="example.js"></script>
25 25
 </body>
26 26
 </html>

+ 10
- 7
assets/example.js Целия файл

@@ -8,7 +8,7 @@ var RENDER_ELEMENT_COMMENT = 'comment'; // 渲染评论的标签的 id
8 8
 function createElement(id) {
9 9
   var node = document.createElement('div');
10 10
   node.setAttribute("id", id);
11
-  document.getElementById(RENDER_ELEMENT_WRAPPER).appendChild(node); 
11
+  document.getElementById(RENDER_ELEMENT_WRAPPER).appendChild(node);
12 12
 }
13 13
 
14 14
 /**
@@ -25,7 +25,7 @@ function removeChild(id) {
25 25
 
26 26
 
27 27
 function main() {
28
-  document.getElementById('render').addEventListener('click', function() {
28
+  document.getElementById('render').addEventListener('click', function () {
29 29
     // 首先清空父标签的内容
30 30
     removeChild(RENDER_ELEMENT_WRAPPER);
31 31
 
@@ -36,22 +36,25 @@ function main() {
36 36
     window.renderComment({
37 37
       id: id,
38 38
       type: 1,
39
-      businessId: 'test'
39
+      businessId: 'test',
40
+      userId: 71299
40 41
     })
41 42
   })
42
-  
43
-  document.getElementById('re-render').addEventListener('click', function() {
43
+
44
+  document.getElementById('re-render').addEventListener('click', function () {
44 45
     removeChild(RENDER_ELEMENT_WRAPPER)
45 46
     var id = RENDER_ELEMENT_COMMENT;
46 47
     createElement(id)
47 48
     window.renderComment({
48 49
       id: id,
49 50
       type: 1,
50
-      businessId: 'test1'
51
+      businessId: 'test1',
52
+      userId: 71299
51 53
     })
52 54
   })
53
-  
55
+
54 56
 }
55 57
 
56 58
 
59
+
57 60
 main();

+ 0
- 1
assets/static/css/main.81c08691.css.map
Файловите разлики са ограничени, защото са твърде много
Целия файл


assets/static/css/main.a3c3a441.css
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 1
- 0
assets/static/css/main.a3c3a441.css.map
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 2
- 0
assets/static/js/main.426815d8.js
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 1
- 0
assets/static/js/main.426815d8.js.map
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 0
- 2
assets/static/js/main.9d10db91.js
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 0
- 1
assets/static/js/main.9d10db91.js.map
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 112
- 56
lib/App.js Целия файл

@@ -27,6 +27,10 @@ var _axios = require("axios");
27 27
 
28 28
 var _axios2 = _interopRequireDefault(_axios);
29 29
 
30
+var _reactIntlUniversal = require("react-intl-universal");
31
+
32
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
33
+
30 34
 var _constant = require("./constant");
31 35
 
32 36
 var _Comment = require("./Comment");
@@ -51,19 +55,30 @@ var _RenderText2 = _interopRequireDefault(_RenderText);
51 55
 
52 56
 var _lang = require("./lang");
53 57
 
54
-var _lang2 = _interopRequireDefault(_lang);
58
+var _enUS = require("./lang/en-US.js");
59
+
60
+var _enUS2 = _interopRequireDefault(_enUS);
61
+
62
+var _zhCN = require("./lang/zh-CN.js");
63
+
64
+var _zhCN2 = _interopRequireDefault(_zhCN);
55 65
 
56 66
 require("./App.css");
57 67
 
58 68
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
59 69
 
70
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
71
+
60 72
 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
61 73
 
62 74
 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
63 75
 
64 76
 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
65 77
 
66
-// import styles from "./App.module.css";
78
+var LOCALES = {
79
+  "zh-CN": _zhCN2.default,
80
+  "en-US": _enUS2.default
81
+};
67 82
 
68 83
 var App = function (_Component) {
69 84
   _inherits(App, _Component);
@@ -84,7 +99,9 @@ var App = function (_Component) {
84 99
       page: 1,
85 100
       total: 0,
86 101
       // 是否没有更多评论了
87
-      isNoMoreComment: false
102
+      isNoMoreComment: false,
103
+      initDone: false,
104
+      locale: "zh-CN"
88 105
     };
89 106
     _this.handleChangeLoading = _this.handleChangeLoading.bind(_this);
90 107
     _this.sCreateComment = _this.sCreateComment.bind(_this);
@@ -111,7 +128,38 @@ var App = function (_Component) {
111 128
     }
112 129
   }, {
113 130
     key: "componentDidMount",
114
-    value: function componentDidMount() {}
131
+    value: function componentDidMount() {
132
+      this.loadLocales();
133
+    }
134
+
135
+    /**
136
+     * 加载语言包
137
+     * 只能根据url或者传入的props来确定加载哪个语言包
138
+     * 优先级:传入的props > url
139
+     */
140
+
141
+  }, {
142
+    key: "loadLocales",
143
+    value: function loadLocales() {
144
+      var _this2 = this;
145
+
146
+      var currentLocale = this.props.locales;
147
+
148
+      if (!currentLocale) {
149
+        currentLocale = _reactIntlUniversal2.default.determineLocale({
150
+          urlLocaleKey: "lang"
151
+        });
152
+      }
153
+      currentLocale = _lang.SUPPORT_LOCALES.find(function (item) {
154
+        return item.value === currentLocale;
155
+      }) ? currentLocale : "zh-CN";
156
+      _reactIntlUniversal2.default.init({
157
+        currentLocale: currentLocale,
158
+        locales: _defineProperty({}, currentLocale, LOCALES[currentLocale])
159
+      }).then(function () {
160
+        _this2.setState({ initDone: true, locale: currentLocale });
161
+      });
162
+    }
115 163
   }, {
116 164
     key: "error",
117 165
     value: function error(msg) {
@@ -127,13 +175,16 @@ var App = function (_Component) {
127 175
   }, {
128 176
     key: "errorHandler",
129 177
     value: function errorHandler(error) {
178
+      var locale = this.state.locale;
179
+
180
+      var localResponse = _lang.LOCALES_RESPONSE[locale];
130 181
       if (error.response && error.response.data && error.response.data.msg) {
131
-        this.error(_lang2.default[error.response.data.msg] || _constant.ERROR_DEFAULT, {
182
+        this.error(localResponse[error.response.data.msg] || _constant.ERROR_DEFAULT, {
132 183
           response: error.response
133 184
         });
134 185
         return;
135 186
       }
136
-      this.error(_lang2.default[error.message] || _constant.ERROR_DEFAULT, {
187
+      this.error(localResponse[error.response.data.msg] || _constant.ERROR_DEFAULT, {
137 188
         response: error.response
138 189
       });
139 190
     }
@@ -160,7 +211,7 @@ var App = function (_Component) {
160 211
   }, {
161 212
     key: "sGetComment",
162 213
     value: function sGetComment() {
163
-      var _this2 = this;
214
+      var _this3 = this;
164 215
 
165 216
       var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
166 217
           _ref$page = _ref.page,
@@ -182,7 +233,7 @@ var App = function (_Component) {
182 233
 
183 234
         if (list) {
184 235
           var newList = list;
185
-          var oldList = _this2.state.list;
236
+          var oldList = _this3.state.list;
186 237
 
187 238
           if (pageType === "more") {
188 239
             if (page > 1) {
@@ -197,19 +248,19 @@ var App = function (_Component) {
197 248
             window.scrollTo(0, 0);
198 249
           }
199 250
 
200
-          _this2.setState({
251
+          _this3.setState({
201 252
             list: newList,
202 253
             page: page,
203 254
             total: total
204 255
           });
205 256
         } else {
206
-          _message3.default.info("没有更多评论了");
207
-          _this2.setState({
257
+          _message3.default.info(_reactIntlUniversal2.default.get("message.noMoreComment"));
258
+          _this3.setState({
208 259
             isNoMoreComment: true
209 260
           });
210 261
         }
211 262
       }).catch(this.errorHandler).finally(function () {
212
-        _this2.handleChangeLoading("sGetComment", false);
263
+        _this3.handleChangeLoading("sGetComment", false);
213 264
       });
214 265
     }
215 266
 
@@ -220,7 +271,7 @@ var App = function (_Component) {
220 271
   }, {
221 272
     key: "sGetReply",
222 273
     value: function sGetReply() {
223
-      var _this3 = this;
274
+      var _this4 = this;
224 275
 
225 276
       var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
226 277
           commentId = _ref2.commentId,
@@ -232,9 +283,9 @@ var App = function (_Component) {
232 283
 
233 284
       this.axios.get(API + "/replies?comment_id=" + commentId + "&page=" + page + "&limit=" + _constant.LIMIT).then(function (response) {
234 285
         if (!response.data.list) {
235
-          _message3.default.info("没有更多数据了!");
286
+          _message3.default.info(_reactIntlUniversal2.default.get("message.noMoreData"));
236 287
         }
237
-        var list = _this3.state.list.map(function (item) {
288
+        var list = _this4.state.list.map(function (item) {
238 289
           if (item.id === commentId) {
239 290
             if (!item.replies) item.replies = [];
240 291
             if (response.data.list) {
@@ -256,9 +307,9 @@ var App = function (_Component) {
256 307
           }
257 308
           return item;
258 309
         });
259
-        _this3.setState({ list: list });
310
+        _this4.setState({ list: list });
260 311
       }).catch(this.errorHandler).finally(function () {
261
-        _this3.handleChangeLoading("sGetReply", false);
312
+        _this4.handleChangeLoading("sGetReply", false);
262 313
       });
263 314
     }
264 315
 
@@ -270,14 +321,14 @@ var App = function (_Component) {
270 321
   }, {
271 322
     key: "sCreateComment",
272 323
     value: function sCreateComment() {
273
-      var _this4 = this;
324
+      var _this5 = this;
274 325
 
275 326
       var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
276 327
           content = _ref3.content;
277 328
 
278 329
       var cb = arguments[1];
279 330
 
280
-      if (!content) return this.error("评论内容不能为空 ");
331
+      if (!content) return this.error(_reactIntlUniversal2.default.get("message.notNull"));
281 332
       this.handleChangeLoading("sCreateComment", true);
282 333
       var _props2 = this.props,
283 334
           API = _props2.API,
@@ -293,23 +344,23 @@ var App = function (_Component) {
293 344
         },
294 345
         withCredentials: true
295 346
       }).then(function (response) {
296
-        if (_this4.props.showAlertComment) {
297
-          _message3.default.success("评论成功!");
347
+        if (_this5.props.showAlertComment) {
348
+          _message3.default.success(_reactIntlUniversal2.default.get("message.success"));
298 349
         }
299 350
         if ((0, _helper.isFunction)(cb)) cb();
300 351
         // 将数据写入到 list 中
301 352
         // 临时插入
302 353
         // 等到获取数据之后,删除临时数据
303
-        var _state = _this4.state,
354
+        var _state = _this5.state,
304 355
             list = _state.list,
305 356
             total = _state.total;
306 357
 
307 358
         list.unshift(_extends({}, response.data, {
308 359
           isTemporary: true // 临时的数据
309 360
         }));
310
-        _this4.setState({ list: list, total: total + 1 });
361
+        _this5.setState({ list: list, total: total + 1 });
311 362
       }).catch(this.errorHandler).finally(function () {
312
-        _this4.handleChangeLoading("sCreateComment", false);
363
+        _this5.handleChangeLoading("sCreateComment", false);
313 364
       });
314 365
     }
315 366
 
@@ -320,7 +371,7 @@ var App = function (_Component) {
320 371
   }, {
321 372
     key: "sDeleteComment",
322 373
     value: function sDeleteComment(commentId) {
323
-      var _this5 = this;
374
+      var _this6 = this;
324 375
 
325 376
       this.handleChangeLoading("sDeleteComment", true);
326 377
       var API = this.props.API;
@@ -329,16 +380,17 @@ var App = function (_Component) {
329 380
         method: "delete",
330 381
         withCredentials: true
331 382
       }).then(function () {
332
-        var _state2 = _this5.state,
383
+        var _state2 = _this6.state,
333 384
             list = _state2.list,
334 385
             total = _state2.total;
335 386
 
336 387
         var res = list.filter(function (item) {
337 388
           return item.id !== commentId;
338 389
         });
339
-        _this5.setState({ list: res, total: total - 1 });
390
+        _this6.setState({ list: res, total: total - 1 });
391
+        _this6.props.onDelete(_constant.COMMENT_TYPE.COMMENT);
340 392
       }).catch(this.errorHandler).finally(function () {
341
-        _this5.handleChangeLoading("sDeleteComment", false);
393
+        _this6.handleChangeLoading("sDeleteComment", false);
342 394
       });
343 395
     }
344 396
 
@@ -351,9 +403,9 @@ var App = function (_Component) {
351 403
   }, {
352 404
     key: "sCreateReply",
353 405
     value: function sCreateReply(data, cb) {
354
-      var _this6 = this;
406
+      var _this7 = this;
355 407
 
356
-      if (!data.content) return this.error("回复内容不能为空 ");
408
+      if (!data.content) return this.error(_reactIntlUniversal2.default.get("message.replyNoNull"));
357 409
       this.handleChangeLoading("sCreateReply", true);
358 410
       var API = this.props.API;
359 411
 
@@ -362,14 +414,14 @@ var App = function (_Component) {
362 414
         data: data,
363 415
         withCredentials: true
364 416
       }).then(function (response) {
365
-        if (_this6.props.showAlertReply) {
366
-          _message3.default.success("回复成功!");
417
+        if (_this7.props.showAlertReply) {
418
+          _message3.default.success(_reactIntlUniversal2.default.get("message.replySuccess"));
367 419
         }
368 420
         if ((0, _helper.isFunction)(cb)) cb();
369 421
         // 将数据写入到 list 中
370 422
         // 临时插入
371 423
         // 等到获取数据之后,删除临时数据
372
-        var list = _this6.state.list.map(function (item) {
424
+        var list = _this7.state.list.map(function (item) {
373 425
           if (item.id === data.comment_id) {
374 426
             if (!item.replies) item.replies = [];
375 427
             item.replies.push(_extends({}, response.data, {
@@ -379,9 +431,9 @@ var App = function (_Component) {
379 431
           }
380 432
           return item;
381 433
         });
382
-        _this6.setState({ list: list });
434
+        _this7.setState({ list: list });
383 435
       }).catch(this.errorHandler).finally(function () {
384
-        _this6.handleChangeLoading("sCreateReply", false);
436
+        _this7.handleChangeLoading("sCreateReply", false);
385 437
       });
386 438
     }
387 439
 
@@ -394,7 +446,7 @@ var App = function (_Component) {
394 446
   }, {
395 447
     key: "sDeleteReply",
396 448
     value: function sDeleteReply(replyId, commentId) {
397
-      var _this7 = this;
449
+      var _this8 = this;
398 450
 
399 451
       this.handleChangeLoading("sDeleteReply", true);
400 452
       var API = this.props.API;
@@ -403,7 +455,7 @@ var App = function (_Component) {
403 455
         method: "delete",
404 456
         withCredentials: true
405 457
       }).then(function () {
406
-        var list = _this7.state.list.map(function (item) {
458
+        var list = _this8.state.list.map(function (item) {
407 459
           if (item.id === commentId) {
408 460
             var replies = item.replies.filter(function (item) {
409 461
               return item.id !== replyId;
@@ -413,9 +465,10 @@ var App = function (_Component) {
413 465
           }
414 466
           return item;
415 467
         });
416
-        _this7.setState({ list: list });
468
+        _this8.setState({ list: list });
469
+        _this8.props.onDelete(_constant.COMMENT_TYPE.REPLY);
417 470
       }).catch(this.errorHandler).finally(function () {
418
-        _this7.handleChangeLoading("sDeleteReply", false);
471
+        _this8.handleChangeLoading("sDeleteReply", false);
419 472
       });
420 473
     }
421 474
 
@@ -428,7 +481,7 @@ var App = function (_Component) {
428 481
   }, {
429 482
     key: "sCommentFavor",
430 483
     value: function sCommentFavor(commentId, favored) {
431
-      var _this8 = this;
484
+      var _this9 = this;
432 485
 
433 486
       this.handleChangeLoading("sCommentFavor", true);
434 487
       var API = this.props.API;
@@ -437,20 +490,20 @@ var App = function (_Component) {
437 490
         method: favored ? "delete" : "put",
438 491
         withCredentials: true
439 492
       }).then(function (response) {
440
-        if (_this8.props.showAlertFavor) {
441
-          _message3.default.success(favored ? "取消点赞成功!" : "点赞成功!");
493
+        if (_this9.props.showAlertFavor) {
494
+          _message3.default.success(favored ? _reactIntlUniversal2.default.get("message.cancelLickSuccess") : _reactIntlUniversal2.default.get("message.likeSuccess"));
442 495
         }
443 496
         // 更新 list 中的该项数据的 favored
444
-        var list = _this8.state.list.map(function (item) {
497
+        var list = _this9.state.list.map(function (item) {
445 498
           if (item.id === commentId) {
446 499
             item.favored = !favored;
447 500
             item.favor_count += favored ? -1 : 1;
448 501
           }
449 502
           return item;
450 503
         });
451
-        _this8.setState({ list: list });
504
+        _this9.setState({ list: list });
452 505
       }).catch(this.errorHandler).finally(function () {
453
-        _this8.handleChangeLoading("sCommentFavor", false);
506
+        _this9.handleChangeLoading("sCommentFavor", false);
454 507
       });
455 508
     }
456 509
 
@@ -464,7 +517,7 @@ var App = function (_Component) {
464 517
   }, {
465 518
     key: "sReplyFavor",
466 519
     value: function sReplyFavor(replyId, commentId, favored) {
467
-      var _this9 = this;
520
+      var _this10 = this;
468 521
 
469 522
       this.handleChangeLoading("sReplyFavor", true);
470 523
       var API = this.props.API;
@@ -476,9 +529,9 @@ var App = function (_Component) {
476 529
         },
477 530
         withCredentials: true
478 531
       }).then(function (response) {
479
-        _message3.default.success(favored ? "取消点赞成功!" : "点赞成功!");
532
+        _message3.default.success(favored ? _reactIntlUniversal2.default.get("message.cancelLickSuccess") : _reactIntlUniversal2.default.get("message.likeSuccess"));
480 533
         // 更新 list 中的该项数据的 favored
481
-        var list = _this9.state.list.map(function (item) {
534
+        var list = _this10.state.list.map(function (item) {
482 535
           if (item.id === commentId) {
483 536
             item.replies = item.replies.map(function (r) {
484 537
               if (r.id === replyId) {
@@ -493,9 +546,9 @@ var App = function (_Component) {
493 546
           }
494 547
           return item;
495 548
         });
496
-        _this9.setState({ list: list });
549
+        _this10.setState({ list: list });
497 550
       }).catch(this.errorHandler).finally(function () {
498
-        _this9.handleChangeLoading("sReplyFavor", false);
551
+        _this10.handleChangeLoading("sReplyFavor", false);
499 552
       });
500 553
     }
501 554
 
@@ -506,15 +559,15 @@ var App = function (_Component) {
506 559
   }, {
507 560
     key: "sOssSts",
508 561
     value: function sOssSts() {
509
-      var _this10 = this;
562
+      var _this11 = this;
510 563
 
511 564
       this.handleChangeLoading("sOssSts", true);
512 565
       var API = this.props.API;
513 566
 
514 567
       this.axios.get(API + "/oss/sts").then(function (response) {
515
-        _this10.setState({ oss: _extends({}, response.data) });
568
+        _this11.setState({ oss: _extends({}, response.data) });
516 569
       }).catch(this.errorHandler).finally(function () {
517
-        _this10.handleChangeLoading("sOssSts", false);
570
+        _this11.handleChangeLoading("sOssSts", false);
518 571
       });
519 572
     }
520 573
   }, {
@@ -533,7 +586,7 @@ var App = function (_Component) {
533 586
         sDeleteReply: this.sDeleteReply
534 587
       });
535 588
 
536
-      return _react2.default.createElement(
589
+      return this.state.initDone && _react2.default.createElement(
537 590
         _Comment.CommentContext.Provider,
538 591
         { value: value },
539 592
         _react2.default.createElement(
@@ -567,7 +620,9 @@ App.propTypes = {
567 620
   userId: _propTypes2.default.number, // 用户id, comment内部不维护用户id, 调用组件时传递过来, 目前用于判断是否显示删除按钮
568 621
   pageType: _propTypes2.default.string, // 分页类型
569 622
   page: _propTypes2.default.number, // 页码
570
-  onPageChange: _propTypes2.default.func // 页码变化回调
623
+  onPageChange: _propTypes2.default.func, // 页码变化回调
624
+  onDelete: _propTypes2.default.func,
625
+  locales: _propTypes2.default.string //  传入的语言环境, en-US/zh-CN
571 626
 };
572 627
 
573 628
 App.defaultProps = {
@@ -579,7 +634,8 @@ App.defaultProps = {
579 634
   showAlertFavor: false,
580 635
   showError: true,
581 636
   pageType: "more",
582
-  onPageChange: function onPageChange(page) {}
637
+  onPageChange: function onPageChange(page) {},
638
+  onDelete: function onDelete() {}
583 639
 };
584 640
 
585 641
 exports.Editor = _Editor2.default;

+ 1
- 1
lib/App.js.map
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 7
- 2
lib/components/CommentBox/index.js Целия файл

@@ -20,6 +20,10 @@ var _propTypes = require("prop-types");
20 20
 
21 21
 var _propTypes2 = _interopRequireDefault(_propTypes);
22 22
 
23
+var _reactIntlUniversal = require("react-intl-universal");
24
+
25
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
26
+
23 27
 var _Comment = require("../../Comment");
24 28
 
25 29
 var _Comment2 = _interopRequireDefault(_Comment);
@@ -122,7 +126,7 @@ var CommentBox = function (_Component) {
122 126
                       return _this2.handleGetMoreReply(commentId);
123 127
                     }
124 128
                   },
125
-                  "\u67E5\u770B\u66F4\u591A\u56DE\u590D"
129
+                  _reactIntlUniversal2.default.get("reply.moreReply")
126 130
                 ),
127 131
                 _react2.default.createElement(
128 132
                   "a",
@@ -131,7 +135,8 @@ var CommentBox = function (_Component) {
131 135
                     onClick: _this2.handleToggleReply
132 136
                   },
133 137
                   _react2.default.createElement(_icon2.default, { type: "up" }),
134
-                  " \u6536\u8D77\u56DE\u590D"
138
+                  " ",
139
+                  _reactIntlUniversal2.default.get("reply.collapse")
135 140
                 )
136 141
               )];
137 142
             }

+ 1
- 1
lib/components/CommentBox/index.js.map
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 6
- 4
lib/components/CommentList/index.js Целия файл

@@ -22,6 +22,10 @@ var _react = require("react");
22 22
 
23 23
 var _react2 = _interopRequireDefault(_react);
24 24
 
25
+var _reactIntlUniversal = require("react-intl-universal");
26
+
27
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
28
+
25 29
 var _Comment = require("../../Comment");
26 30
 
27 31
 var _Comment2 = _interopRequireDefault(_Comment);
@@ -85,7 +89,7 @@ var CommentList = function (_Component) {
85 89
             _react2.default.createElement(
86 90
               "span",
87 91
               null,
88
-              "\u67E5\u770B\u66F4\u591A\u8BC4\u8BBA"
92
+              _reactIntlUniversal2.default.get("comment.moreComment")
89 93
             )
90 94
           );
91 95
         } else {
@@ -126,9 +130,7 @@ var CommentList = function (_Component) {
126 130
           _react2.default.createElement(
127 131
             "div",
128 132
             null,
129
-            "\u5171 ",
130
-            total,
131
-            " \u6761\u8BC4\u8BBA"
133
+            _reactIntlUniversal2.default.get("comment.totalComment", { total: total })
132 134
           ),
133 135
           list.map(function (item) {
134 136
             return _react2.default.createElement(_CommentBox2.default, { content: item, key: item.id, commentId: item.id });

+ 1
- 1
lib/components/CommentList/index.js.map Целия файл

@@ -1 +1 @@
1
-{"version":3,"sources":["../../../src/components/CommentList/index.js"],"names":["CommentList","props","state","app","sGetComment","page","list","total","pageType","isNoMoreComment","onPageChange","length","LIMIT","p","loading","spinning","Boolean","sCommentFavor","sReplyFavor","map","item","id","renderPagination","Component","propTypes"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;AAEA;;;;AACA;;;;AACA;;AACA;;;;;;;;;;IAEMA,W;;;AACJ,uBAAYC,KAAZ,EAAmB;AAAA;;AAAA,0HACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa,EAAb;AAFiB;AAGlB;;;;yCAEoB;AACnB,WAAKD,KAAL,CAAWE,GAAX,CAAeC,WAAf,CAA2B,EAAEC,MAAM,KAAKJ,KAAL,CAAWE,GAAX,CAAeE,IAAvB,EAA3B;AACD;;;uCAEkB;AAAA,uBASb,KAAKJ,KAAL,CAAWE,GATE;AAAA,UAEfG,IAFe,cAEfA,IAFe;AAAA,UAGfC,KAHe,cAGfA,KAHe;AAAA,UAIfF,IAJe,cAIfA,IAJe;AAAA,UAKfG,QALe,cAKfA,QALe;AAAA,UAMfC,eANe,cAMfA,eANe;AAAA,UAOfL,WAPe,cAOfA,WAPe;AAAA,UAQfM,YARe,cAQfA,YARe;;AAUjB,UAAIF,aAAa,MAAjB,EAAyB;AACvB,YAAI,CAACC,eAAD,IAAoBH,KAAKK,MAAL,KAAgBJ,KAAxC,EAA+C;AAC7C,iBACE;AAAA;AAAA;AACE,yBAAU,wBADZ;AAEE,uBAAS,mBAAM;AACbH,4BAAY,EAAEC,MAAMA,OAAO,CAAf,EAAZ;AACAK,6BAAaL,OAAO,CAApB;AACD;AALH;AAOE;AAAA;AAAA;AAAA;AAAA;AAPF,WADF;AAWD,SAZD,MAYO;AACL,iBAAO,IAAP;AACD;AACF,OAhBD,MAgBO,IAAIG,aAAa,YAAjB,EAA+B;AACpC,eACE;AAAA;AAAA,YAAK,WAAU,yBAAf;AACE;AACE,sBAAUI,eADZ;AAEE,qBAASP,IAFX;AAGE,mBAAOE,KAHT;AAIE,sBAAU,qBAAK;AACbH,0BAAY,EAAEC,MAAMQ,CAAR,EAAZ;AACAH,2BAAaG,CAAb;AACD;AAPH;AADF,SADF;AAaD;AACF;;;6BAEQ;AAAA,wBAC0B,KAAKZ,KAAL,CAAWE,GADrC;AAAA,UACCG,IADD,eACCA,IADD;AAAA,UACOC,KADP,eACOA,KADP;AAAA,UACcO,OADd,eACcA,OADd;;;AAGP,UAAMC,WAAWC,QACfF,QAAQV,WAAR,IAAuBU,QAAQG,aAA/B,IAAgDH,QAAQI,WADzC,CAAjB;AAGA,aACE;AAAA;AAAA;AACE;AAAA;AAAA,YAAM,UAAUH,QAAhB;AACE;AAAA;AAAA;AAAA;AAAQR,iBAAR;AAAA;AAAA,WADF;AAEGD,eAAKa,GAAL,CAAS;AAAA,mBACR,8BAAC,oBAAD,IAAY,SAASC,IAArB,EAA2B,KAAKA,KAAKC,EAArC,EAAyC,WAAWD,KAAKC,EAAzD,GADQ;AAAA,WAAT,CAFH;AAKG,eAAKC,gBAAL;AALH;AADF,OADF;AAWD;;;;EAtEuBC,gB;;AAyE1BvB,YAAYwB,SAAZ,GAAwB,EAAxB;;kBAEe,uBAAQxB,WAAR,C","file":"index.js","sourcesContent":["import React, { Component } from \"react\";\nimport { Spin, Pagination } from \"antd\";\nimport Comment from \"../../Comment\";\nimport CommentBox from \"../CommentBox\";\nimport \"./index.css\";\nimport { LIMIT } from \"../../constant\";\n\nclass CommentList extends Component {\n  constructor(props) {\n    super(props);\n    this.state = {};\n  }\n\n  componentWillMount() {\n    this.props.app.sGetComment({ page: this.props.app.page });\n  }\n\n  renderPagination() {\n    const {\n      list,\n      total,\n      page,\n      pageType,\n      isNoMoreComment,\n      sGetComment,\n      onPageChange\n    } = this.props.app;\n    if (pageType === \"more\") {\n      if (!isNoMoreComment && list.length !== total) {\n        return (\n          <div\n            className=\"comment-list-show-more\"\n            onClick={() => {\n              sGetComment({ page: page + 1 });\n              onPageChange(page + 1);\n            }}\n          >\n            <span>查看更多评论</span>\n          </div>\n        );\n      } else {\n        return null;\n      }\n    } else if (pageType === \"pagination\") {\n      return (\n        <div className=\"comment-list-pagination\">\n          <Pagination\n            pageSize={LIMIT}\n            current={page}\n            total={total}\n            onChange={p => {\n              sGetComment({ page: p });\n              onPageChange(p);\n            }}\n          />\n        </div>\n      );\n    }\n  }\n\n  render() {\n    const { list, total, loading } = this.props.app;\n\n    const spinning = Boolean(\n      loading.sGetComment || loading.sCommentFavor || loading.sReplyFavor\n    );\n    return (\n      <div>\n        <Spin spinning={spinning}>\n          <div>共 {total} 条评论</div>\n          {list.map(item => (\n            <CommentBox content={item} key={item.id} commentId={item.id} />\n          ))}\n          {this.renderPagination()}\n        </Spin>\n      </div>\n    );\n  }\n}\n\nCommentList.propTypes = {};\n\nexport default Comment(CommentList);\n"]}
1
+{"version":3,"sources":["../../../src/components/CommentList/index.js"],"names":["CommentList","props","state","app","sGetComment","page","list","total","pageType","isNoMoreComment","onPageChange","length","intl","get","LIMIT","p","loading","spinning","Boolean","sCommentFavor","sReplyFavor","map","item","id","renderPagination","Component","propTypes"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;AAEA;;;;AACA;;;;AACA;;;;AACA;;AACA;;;;;;;;;;IAEMA,W;;;AACJ,uBAAYC,KAAZ,EAAmB;AAAA;;AAAA,0HACXA,KADW;;AAEjB,UAAKC,KAAL,GAAa,EAAb;AAFiB;AAGlB;;;;yCAEoB;AACnB,WAAKD,KAAL,CAAWE,GAAX,CAAeC,WAAf,CAA2B,EAAEC,MAAM,KAAKJ,KAAL,CAAWE,GAAX,CAAeE,IAAvB,EAA3B;AACD;;;uCAEkB;AAAA,uBASb,KAAKJ,KAAL,CAAWE,GATE;AAAA,UAEfG,IAFe,cAEfA,IAFe;AAAA,UAGfC,KAHe,cAGfA,KAHe;AAAA,UAIfF,IAJe,cAIfA,IAJe;AAAA,UAKfG,QALe,cAKfA,QALe;AAAA,UAMfC,eANe,cAMfA,eANe;AAAA,UAOfL,WAPe,cAOfA,WAPe;AAAA,UAQfM,YARe,cAQfA,YARe;;AAUjB,UAAIF,aAAa,MAAjB,EAAyB;AACvB,YAAI,CAACC,eAAD,IAAoBH,KAAKK,MAAL,KAAgBJ,KAAxC,EAA+C;AAC7C,iBACE;AAAA;AAAA;AACE,yBAAU,wBADZ;AAEE,uBAAS,mBAAM;AACbH,4BAAY,EAAEC,MAAMA,OAAO,CAAf,EAAZ;AACAK,6BAAaL,OAAO,CAApB;AACD;AALH;AAOE;AAAA;AAAA;AAAOO,2CAAKC,GAAL,CAAS,qBAAT;AAAP;AAPF,WADF;AAWD,SAZD,MAYO;AACL,iBAAO,IAAP;AACD;AACF,OAhBD,MAgBO,IAAIL,aAAa,YAAjB,EAA+B;AACpC,eACE;AAAA;AAAA,YAAK,WAAU,yBAAf;AACE;AACE,sBAAUM,eADZ;AAEE,qBAAST,IAFX;AAGE,mBAAOE,KAHT;AAIE,sBAAU,qBAAK;AACbH,0BAAY,EAAEC,MAAMU,CAAR,EAAZ;AACAL,2BAAaK,CAAb;AACD;AAPH;AADF,SADF;AAaD;AACF;;;6BAEQ;AAAA,wBAC0B,KAAKd,KAAL,CAAWE,GADrC;AAAA,UACCG,IADD,eACCA,IADD;AAAA,UACOC,KADP,eACOA,KADP;AAAA,UACcS,OADd,eACcA,OADd;;;AAGP,UAAMC,WAAWC,QACfF,QAAQZ,WAAR,IAAuBY,QAAQG,aAA/B,IAAgDH,QAAQI,WADzC,CAAjB;AAGA,aACE;AAAA;AAAA;AACE;AAAA;AAAA,YAAM,UAAUH,QAAhB;AAEE;AAAA;AAAA;AAAML,yCAAKC,GAAL,CAAS,sBAAT,EAAiC,EAAEN,YAAF,EAAjC;AAAN,WAFF;AAGGD,eAAKe,GAAL,CAAS;AAAA,mBACR,8BAAC,oBAAD,IAAY,SAASC,IAArB,EAA2B,KAAKA,KAAKC,EAArC,EAAyC,WAAWD,KAAKC,EAAzD,GADQ;AAAA,WAAT,CAHH;AAMG,eAAKC,gBAAL;AANH;AADF,OADF;AAYD;;;;EAvEuBC,gB;;AA0E1BzB,YAAY0B,SAAZ,GAAwB,EAAxB;;kBAEe,uBAAQ1B,WAAR,C","file":"index.js","sourcesContent":["import React, { Component } from \"react\";\nimport { Spin, Pagination } from \"antd\";\nimport intl from \"react-intl-universal\";\nimport Comment from \"../../Comment\";\nimport CommentBox from \"../CommentBox\";\nimport \"./index.css\";\nimport { LIMIT } from \"../../constant\";\n\nclass CommentList extends Component {\n  constructor(props) {\n    super(props);\n    this.state = {};\n  }\n\n  componentWillMount() {\n    this.props.app.sGetComment({ page: this.props.app.page });\n  }\n\n  renderPagination() {\n    const {\n      list,\n      total,\n      page,\n      pageType,\n      isNoMoreComment,\n      sGetComment,\n      onPageChange\n    } = this.props.app;\n    if (pageType === \"more\") {\n      if (!isNoMoreComment && list.length !== total) {\n        return (\n          <div\n            className=\"comment-list-show-more\"\n            onClick={() => {\n              sGetComment({ page: page + 1 });\n              onPageChange(page + 1);\n            }}\n          >\n            <span>{intl.get(\"comment.moreComment\")}</span>\n          </div>\n        );\n      } else {\n        return null;\n      }\n    } else if (pageType === \"pagination\") {\n      return (\n        <div className=\"comment-list-pagination\">\n          <Pagination\n            pageSize={LIMIT}\n            current={page}\n            total={total}\n            onChange={p => {\n              sGetComment({ page: p });\n              onPageChange(p);\n            }}\n          />\n        </div>\n      );\n    }\n  }\n\n  render() {\n    const { list, total, loading } = this.props.app;\n\n    const spinning = Boolean(\n      loading.sGetComment || loading.sCommentFavor || loading.sReplyFavor\n    );\n    return (\n      <div>\n        <Spin spinning={spinning}>\n          {/* <div>共 {total} 条评论</div> */}\n          <div>{intl.get(\"comment.totalComment\", { total })}</div>\n          {list.map(item => (\n            <CommentBox content={item} key={item.id} commentId={item.id} />\n          ))}\n          {this.renderPagination()}\n        </Spin>\n      </div>\n    );\n  }\n}\n\nCommentList.propTypes = {};\n\nexport default Comment(CommentList);\n"]}

+ 23
- 10
lib/components/ContentItem/index.js Целия файл

@@ -48,6 +48,10 @@ var _relativeTime = require("dayjs/plugin/relativeTime");
48 48
 
49 49
 var _relativeTime2 = _interopRequireDefault(_relativeTime);
50 50
 
51
+var _reactIntlUniversal = require("react-intl-universal");
52
+
53
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
54
+
51 55
 var _Comment = require("../../Comment");
52 56
 
53 57
 var _Comment2 = _interopRequireDefault(_Comment);
@@ -79,10 +83,16 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
79 83
 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
80 84
 
81 85
 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
86
+// import 'dayjs/locale/es';
87
+
82 88
 
83
-_dayjs2.default.locale("zh-cn");
89
+// dayjs.locale("zh-cn");
84 90
 _dayjs2.default.extend(_relativeTime2.default);
85 91
 
92
+var LOCALES = {
93
+  "zh-CN": "zh-cn"
94
+};
95
+
86 96
 var CommentItem = function (_Component) {
87 97
   _inherits(CommentItem, _Component);
88 98
 
@@ -159,6 +169,7 @@ var CommentItem = function (_Component) {
159 169
           showReply = _props.showReply,
160 170
           onShowReply = _props.onShowReply,
161 171
           app = _props.app;
172
+      var locale = this.props.app.locale;
162 173
       var showInput = this.state.showInput;
163 174
 
164 175
 
@@ -201,7 +212,7 @@ var CommentItem = function (_Component) {
201 212
             _react2.default.createElement(
202 213
               "strong",
203 214
               null,
204
-              content.user_name || "游客"
215
+              content.user_name || _reactIntlUniversal2.default.get("comment.tourist")
205 216
             ),
206 217
             _react2.default.createElement(
207 218
               "span",
@@ -212,7 +223,7 @@ var CommentItem = function (_Component) {
212 223
                   placement: "top",
213 224
                   title: (0, _dayjs2.default)(content.created * 1000).format("YYYY-MM-DD HH:mm:ss")
214 225
                 },
215
-                (0, _dayjs2.default)(content.created * 1000).fromNow()
226
+                LOCALES[locale] ? (0, _dayjs2.default)(content.created * 1000).locale(LOCALES[locale]).fromNow() : (0, _dayjs2.default)(content.created * 1000).fromNow()
216 227
               )
217 228
             )
218 229
           ),
@@ -274,15 +285,15 @@ var CommentItem = function (_Component) {
274 285
               _react2.default.createElement(
275 286
                 "a",
276 287
                 { className: "comment-item-bottom-left", onClick: onShowReply },
277
-                content.reply_count,
278
-                " \u6761\u56DE\u590D",
288
+                _reactIntlUniversal2.default.get("reply.totalReply", { total: content.reply_count }),
279 289
                 showReply ? _react2.default.createElement(_icon2.default, { type: "up" }) : _react2.default.createElement(_icon2.default, { type: "down" })
280 290
               )
281 291
             ) : null,
282 292
             app.userId === content.user_id && _react2.default.createElement(
283 293
               _popconfirm2.default,
284 294
               {
285
-                title: "\u786E\u5B9A\u8981\u5220\u9664\u5417?",
295
+                // title="确定要删除吗?"
296
+                title: _reactIntlUniversal2.default.get("popConfirm.title"),
286 297
                 onConfirm: function onConfirm() {
287 298
                   if (replyId) {
288 299
                     app.sDeleteReply(content.id, commentId);
@@ -290,13 +301,14 @@ var CommentItem = function (_Component) {
290 301
                   }
291 302
                   app.sDeleteComment(content.id);
292 303
                 },
293
-                okText: "\u786E\u5B9A",
294
-                cancelText: "\u53D6\u6D88"
304
+                okText: _reactIntlUniversal2.default.get("popConfirm.ok"),
305
+                cancelText: _reactIntlUniversal2.default.get("popConfirm.cancel")
295 306
               },
296 307
               _react2.default.createElement(
297 308
                 "a",
298 309
                 { className: "comment-item-bottom-right" },
299
-                "\xA0 \u5220\u9664"
310
+                "\xA0 ",
311
+                _reactIntlUniversal2.default.get("popConfirm.delete")
300 312
               )
301 313
             ),
302 314
             _react2.default.createElement(
@@ -305,7 +317,8 @@ var CommentItem = function (_Component) {
305 317
                 onClick: this.handleToggleInput,
306 318
                 className: "comment-item-bottom-right"
307 319
               },
308
-              "\xA0 \u56DE\u590D"
320
+              "\xA0 ",
321
+              _reactIntlUniversal2.default.get("comment.reply")
309 322
             ),
310 323
             _react2.default.createElement(
311 324
               "div",

+ 1
- 1
lib/components/ContentItem/index.js.map
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 5
- 1
lib/components/Editor/Upload.js Целия файл

@@ -42,6 +42,10 @@ var _shortid = require("shortid");
42 42
 
43 43
 var _shortid2 = _interopRequireDefault(_shortid);
44 44
 
45
+var _reactIntlUniversal = require("react-intl-universal");
46
+
47
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
48
+
45 49
 var _constant = require("../../constant");
46 50
 
47 51
 var _Comment = require("../../Comment");
@@ -173,7 +177,7 @@ var App = function (_React$Component) {
173 177
         _react2.default.createElement(
174 178
           "div",
175 179
           { className: "ant-upload-text" },
176
-          "\u4E0A\u4F20"
180
+          _reactIntlUniversal2.default.get("editor.uploadBtn")
177 181
         )
178 182
       );
179 183
       return _react2.default.createElement(

+ 1
- 1
lib/components/Editor/Upload.js.map
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 20
- 26
lib/components/Editor/index.js Целия файл

@@ -48,6 +48,10 @@ var _classnames = require("classnames");
48 48
 
49 49
 var _classnames2 = _interopRequireDefault(_classnames);
50 50
 
51
+var _reactIntlUniversal = require("react-intl-universal");
52
+
53
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
54
+
51 55
 var _constant = require("../../constant");
52 56
 
53 57
 var _helper = require("../../helper");
@@ -218,7 +222,8 @@ var Editor = function (_React$Component) {
218 222
           fileList = _state.fileList;
219 223
 
220 224
       if (value.length > maxLength) {
221
-        _message3.default.error("\u5B57\u6570\u4E0D\u5F97\u8D85\u8FC7" + maxLength + "\u5B57");
225
+        // message.error(`字数不得超过${maxLength}字`);
226
+        _message3.default.error(_reactIntlUniversal2.default.get("editor.maxLength", { maxLength: maxLength }));
222 227
         return;
223 228
       }
224 229
       var files = [];
@@ -267,13 +272,11 @@ var Editor = function (_React$Component) {
267 272
 
268 273
       var _props = this.props,
269 274
           value = _props.value,
270
-          placeholder = _props.placeholder,
271 275
           rows = _props.rows,
272 276
           showEmoji = _props.showEmoji,
273 277
           showUpload = _props.showUpload,
274 278
           closeUploadWhenBlur = _props.closeUploadWhenBlur,
275 279
           maxUpload = _props.maxUpload,
276
-          btnSubmitText = _props.btnSubmitText,
277 280
           btnLoading = _props.btnLoading,
278 281
           btnDisabled = _props.btnDisabled,
279 282
           button = _props.button,
@@ -282,6 +285,8 @@ var Editor = function (_React$Component) {
282 285
           maxLength = _props.maxLength,
283 286
           autoFocus = _props.autoFocus;
284 287
 
288
+      var placeholder = this.props.placeholder || _reactIntlUniversal2.default.get("editor.placeholder");
289
+      var btnSubmitText = this.props.placeholder || _reactIntlUniversal2.default.get("editor.SubmitBtn");
285 290
       var handleSubmit = this.handleSubmit;
286 291
       var disabledSubmit = btnDisabled || !this.props.value && !this.state.value && !this.state.fileList.length;
287 292
       var inputValue = value || this.state.value;
@@ -296,11 +301,10 @@ var Editor = function (_React$Component) {
296 301
               "comment-editor-toolbar-error": inputValue.length > maxLength
297 302
             })
298 303
           },
299
-          "\u5DF2\u8F93\u5165 ",
300
-          inputValue.length,
301
-          " / ",
302
-          maxLength,
303
-          " \u5B57"
304
+          _reactIntlUniversal2.default.get("editor.alreadyEntered", {
305
+            count: inputValue.length,
306
+            maxLength: maxLength
307
+          })
304 308
         ),
305 309
         _react2.default.createElement(
306 310
           "div",
@@ -346,9 +350,10 @@ var Editor = function (_React$Component) {
346 350
               showUpload ? _react2.default.createElement(
347 351
                 _popover2.default,
348 352
                 {
349
-                  trigger: "click",
350
-                  visible: this.state.showUpload,
351
-                  overlayStyle: { zIndex: 999 },
353
+                  trigger: "click"
354
+                  // TODO: 针对非 react.js,直接使用 click 事件来控制展开或关闭
355
+                  // visible={this.state.showUpload}
356
+                  , overlayStyle: { zIndex: 999 },
352 357
                   onVisibleChange: closeUploadWhenBlur ? function (visible) {
353 358
                     _this3.handleShowUpload(visible);
354 359
                   } : null,
@@ -378,7 +383,7 @@ var Editor = function (_React$Component) {
378 383
                     _react2.default.createElement(
379 384
                       "span",
380 385
                       null,
381
-                      "\u4E0A\u4F20\u56FE\u7247",
386
+                      _reactIntlUniversal2.default.get("editor.uploadTip"),
382 387
                       maxUpload >= 2 ? _react2.default.createElement(
383 388
                         "span",
384 389
                         { style: { color: "#666", fontWeight: 400 } },
@@ -386,18 +391,7 @@ var Editor = function (_React$Component) {
386 391
                         maxUpload - this.state.fileList.length,
387 392
                         "\u5F20\u56FE\u7247)"
388 393
                       ) : null
389
-                    ),
390
-                    _react2.default.createElement(_icon2.default, {
391
-                      type: "close",
392
-                      onClick: function onClick() {
393
-                        return _this3.handleShowUpload(false);
394
-                      },
395
-                      style: {
396
-                        float: "right",
397
-                        cursor: "pointer",
398
-                        marginTop: 4
399
-                      }
400
-                    })
394
+                    )
401 395
                   )
402 396
                 },
403 397
                 imageToolIcon ? _react2.default.cloneElement(imageToolIcon, {
@@ -465,12 +459,12 @@ Editor.propTypes = {
465 459
 
466 460
 Editor.defaultProps = {
467 461
   rows: 5,
468
-  placeholder: "说点什么吧...",
462
+  // placeholder: "说点什么吧",
469 463
   showEmoji: true,
470 464
   showUpload: true,
471 465
   closeUploadWhenBlur: false,
472 466
   maxUpload: 1,
473
-  btnSubmitText: "发表",
467
+  // btnSubmitText: "发表",
474 468
   btnLoading: false,
475 469
   btnDisabled: false,
476 470
   showError: true,

+ 1
- 1
lib/components/Editor/index.js.map
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 7
- 2
lib/components/ImagePreviewer/ImagePreviewer.js Целия файл

@@ -26,6 +26,10 @@ var _classnames = require("classnames");
26 26
 
27 27
 var _classnames2 = _interopRequireDefault(_classnames);
28 28
 
29
+var _reactIntlUniversal = require("react-intl-universal");
30
+
31
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
32
+
29 33
 require("./ImagePreviewer.less");
30 34
 
31 35
 var _helper = require("../../helper");
@@ -161,13 +165,14 @@ var ImagePreviewer = function (_React$Component) {
161 165
             "span",
162 166
             { className: "button", onClick: onFold },
163 167
             _react2.default.createElement(_icon2.default, { type: "to-top" }),
164
-            "\u6536\u8D77"
168
+            _reactIntlUniversal2.default.get("picture.collapse")
165 169
           ),
166 170
           _react2.default.createElement(
167 171
             "span",
168 172
             { className: "button", onClick: this.onOrigin },
169 173
             _react2.default.createElement(_icon2.default, { type: "search" }),
170
-            " \u67E5\u770B\u539F\u56FE"
174
+            " ",
175
+            _reactIntlUniversal2.default.get("picture.viewOriginal")
171 176
           )
172 177
         ),
173 178
         _react2.default.createElement(

+ 1
- 1
lib/components/ImagePreviewer/ImagePreviewer.js.map
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 5
- 0
lib/constant.js Целия файл

@@ -26,4 +26,9 @@ var IMAGE_SPLIT = exports.IMAGE_SPLIT = "IMAGE_SPLIT";
26 26
 var IMAGE_PROCESS = exports.IMAGE_PROCESS = "?x-oss-process=image/resize,h_350";
27 27
 var IMAGE_PROCESS_SMALL = exports.IMAGE_PROCESS_SMALL = "?x-oss-process=image/resize,h_100";
28 28
 var IMAGE_PROCESS_LARGE = exports.IMAGE_PROCESS_LARGE = "?x-oss-process=image/resize,h_500";
29
+
30
+var COMMENT_TYPE = exports.COMMENT_TYPE = {
31
+  COMMENT: "comment",
32
+  REPLY: "reply"
33
+};
29 34
 //# sourceMappingURL=constant.js.map

+ 1
- 1
lib/constant.js.map Целия файл

@@ -1 +1 @@
1
-{"version":3,"sources":["../src/constant.js"],"names":["ERROR_DEFAULT","LIMIT","OSS_ENDPOINT","OSS_BUCKET","DRIVER_LICENSE_PATH","OSS_LINK","MAX_UPLOAD_NUMBER","URL_REGEXP","REGEXP","AVATAR","IMAGE_SPLIT","IMAGE_PROCESS","IMAGE_PROCESS_SMALL","IMAGE_PROCESS_LARGE"],"mappings":";;;;;AAAO,IAAMA,wCAAgB,MAAtB;;AAEA,IAAMC,wBAAQ,EAAd,C,CAAkB;;AAElB,IAAMC,sCAAe,6BAArB;AACA,IAAMC,kCAAa,eAAnB;AACA,IAAMC,oDAAsB,UAA5B;;AAEA,IAAMC,8BAAW,6CAAjB;;AAEA,IAAMC,gDAAoB,CAA1B;;AAEA,IAAMC,kCAAa,oGAAnB;;AAEA,IAAMC,0BAAS,eAAf;;AAEA,IAAMC,0BAAS,EAAf;;AAEA,IAAMC,oCAAc,aAApB;;AAEA,IAAMC,wCAAgB,mCAAtB;AACA,IAAMC,oDAAsB,mCAA5B;AACA,IAAMC,oDAAsB,mCAA5B","file":"constant.js","sourcesContent":["export const ERROR_DEFAULT = \"出错了!\";\n\nexport const LIMIT = 10; // 默认 limit\n\nexport const OSS_ENDPOINT = \"oss-cn-beijing.aliyuncs.com\";\nexport const OSS_BUCKET = \"links-comment\";\nexport const DRIVER_LICENSE_PATH = \"/comment\";\n\nexport const OSS_LINK = \"//links-comment.oss-cn-beijing.aliyuncs.com\";\n\nexport const MAX_UPLOAD_NUMBER = 4;\n\nexport const URL_REGEXP = /((http(s)?:)?\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/g;\n\nexport const REGEXP = /\\[[^[\\]]+?\\]/g;\n\nexport const AVATAR = \"\";\n\nexport const IMAGE_SPLIT = \"IMAGE_SPLIT\";\n\nexport const IMAGE_PROCESS = \"?x-oss-process=image/resize,h_350\";\nexport const IMAGE_PROCESS_SMALL = \"?x-oss-process=image/resize,h_100\";\nexport const IMAGE_PROCESS_LARGE = \"?x-oss-process=image/resize,h_500\";\n"]}
1
+{"version":3,"sources":["../src/constant.js"],"names":["ERROR_DEFAULT","LIMIT","OSS_ENDPOINT","OSS_BUCKET","DRIVER_LICENSE_PATH","OSS_LINK","MAX_UPLOAD_NUMBER","URL_REGEXP","REGEXP","AVATAR","IMAGE_SPLIT","IMAGE_PROCESS","IMAGE_PROCESS_SMALL","IMAGE_PROCESS_LARGE","COMMENT_TYPE","COMMENT","REPLY"],"mappings":";;;;;AAAO,IAAMA,wCAAgB,MAAtB;;AAEA,IAAMC,wBAAQ,EAAd,C,CAAkB;;AAElB,IAAMC,sCAAe,6BAArB;AACA,IAAMC,kCAAa,eAAnB;AACA,IAAMC,oDAAsB,UAA5B;;AAEA,IAAMC,8BAAW,6CAAjB;;AAEA,IAAMC,gDAAoB,CAA1B;;AAEA,IAAMC,kCAAa,oGAAnB;;AAEA,IAAMC,0BAAS,eAAf;;AAEA,IAAMC,0BAAS,EAAf;;AAEA,IAAMC,oCAAc,aAApB;;AAEA,IAAMC,wCAAgB,mCAAtB;AACA,IAAMC,oDAAsB,mCAA5B;AACA,IAAMC,oDAAsB,mCAA5B;;AAEA,IAAMC,sCAAe;AAC1BC,WAAS,SADiB;AAE1BC,SAAO;AAFmB,CAArB","file":"constant.js","sourcesContent":["export const ERROR_DEFAULT = \"出错了!\";\n\nexport const LIMIT = 10; // 默认 limit\n\nexport const OSS_ENDPOINT = \"oss-cn-beijing.aliyuncs.com\";\nexport const OSS_BUCKET = \"links-comment\";\nexport const DRIVER_LICENSE_PATH = \"/comment\";\n\nexport const OSS_LINK = \"//links-comment.oss-cn-beijing.aliyuncs.com\";\n\nexport const MAX_UPLOAD_NUMBER = 4;\n\nexport const URL_REGEXP = /((http(s)?:)?\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/g;\n\nexport const REGEXP = /\\[[^[\\]]+?\\]/g;\n\nexport const AVATAR = \"\";\n\nexport const IMAGE_SPLIT = \"IMAGE_SPLIT\";\n\nexport const IMAGE_PROCESS = \"?x-oss-process=image/resize,h_350\";\nexport const IMAGE_PROCESS_SMALL = \"?x-oss-process=image/resize,h_100\";\nexport const IMAGE_PROCESS_LARGE = \"?x-oss-process=image/resize,h_500\";\n\nexport const COMMENT_TYPE = {\n  COMMENT: \"comment\",\n  REPLY: \"reply\"\n};\n"]}

+ 24
- 10
lib/index.js Целия файл

@@ -14,12 +14,10 @@ var _App = require("./App");
14 14
 
15 15
 var _App2 = _interopRequireDefault(_App);
16 16
 
17
-var _registerServiceWorker = require("./registerServiceWorker");
18
-
19
-var _registerServiceWorker2 = _interopRequireDefault(_registerServiceWorker);
20
-
21 17
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22 18
 
19
+// import registerServiceWorker from "./registerServiceWorker";
20
+
23 21
 var Index = function Index(props) {
24 22
   return _react2.default.createElement(
25 23
     _App2.default,
@@ -34,33 +32,49 @@ var Index = function Index(props) {
34 32
  *  - {string} id 渲染评论的DOM的 ID
35 33
  *  - {number} type 评论的 type
36 34
  *  - {string} businessId 评论的 businessId
35
+ *  - {string} API, API 前缀, 默认 http://api.links123.net/comment/v1
37 36
  */
38 37
 function renderComment(config) {
39 38
   if (!config.id) {
40 39
     throw new Error("id is required");
41 40
   }
42
-  if (!config.id) {
41
+  if (!config.type) {
43 42
     throw new Error("type is required");
44 43
   }
45
-  if (!config.id) {
46
-    throw new Error("businessId is required");
44
+  if (!config.businessId) {
45
+    // throw new Error("businessId is required");
46
+    console.warn("没有传入 businessId 参数,默认使用: test");
47
+  }
48
+  if (!config.API) {
49
+    // throw new Error("API is required");
50
+    console.warn("没有传入 API 参数,默认使用: http://api.links123.net/comment/v1");
47 51
   }
48 52
   var id = config.id,
49 53
       _config$type = config.type,
50 54
       type = _config$type === undefined ? 1 : _config$type,
51 55
       _config$businessId = config.businessId,
52
-      businessId = _config$businessId === undefined ? "test" : _config$businessId;
56
+      businessId = _config$businessId === undefined ? "test" : _config$businessId,
57
+      _config$API = config.API,
58
+      API = _config$API === undefined ? "http://api.links123.net/comment/v1" : _config$API,
59
+      userId = config.userId;
53 60
 
54 61
 
55
-  _reactDom2.default.render(_react2.default.createElement(Index, { type: type, businessId: businessId }), document.getElementById(id));
62
+  _reactDom2.default.render(_react2.default.createElement(Index, { type: type, businessId: businessId, API: API, userId: userId }), document.getElementById(id));
56 63
   // registerServiceWorker();
57 64
 }
58 65
 
59 66
 window.renderComment = renderComment;
60 67
 
68
+renderComment({
69
+  id: "root-comment",
70
+  type: 1,
71
+  businessId: "test"
72
+});
73
+
61 74
 // renderComment({
62 75
 //   id: "root-comment",
63 76
 //   type: 1,
64
-//   businessId: "test"
77
+//   businessId: "test",
78
+//   API: 'http://api.links123.net/comment/v1',
65 79
 // });
66 80
 //# sourceMappingURL=index.js.map

+ 1
- 1
lib/index.js.map Целия файл

@@ -1 +1 @@
1
-{"version":3,"sources":["../src/index.js"],"names":["Index","props","renderComment","config","id","Error","type","businessId","ReactDOM","render","document","getElementById","window"],"mappings":";;;;AAAA;;;;AACA;;;;AACA;;;;AACA;;;;;;AAEA,IAAMA,QAAQ,SAARA,KAAQ;AAAA,SACZ;AAAC,iBAAD;AAAA,eAAK,sBAAL,EAAsB,oBAAtB,EAAqC,oBAArC,EAAoD,eAApD,IAAkEC,KAAlE;AACE,kCAAC,WAAD,IAAQ,WAAW,CAAnB,EAAsB,eAAtB;AADF,GADY;AAAA,CAAd;;AAMA;;;;;;;AAOA,SAASC,aAAT,CAAuBC,MAAvB,EAA+B;AAC7B,MAAI,CAACA,OAAOC,EAAZ,EAAgB;AACd,UAAM,IAAIC,KAAJ,CAAU,gBAAV,CAAN;AACD;AACD,MAAI,CAACF,OAAOC,EAAZ,EAAgB;AACd,UAAM,IAAIC,KAAJ,CAAU,kBAAV,CAAN;AACD;AACD,MAAI,CAACF,OAAOC,EAAZ,EAAgB;AACd,UAAM,IAAIC,KAAJ,CAAU,wBAAV,CAAN;AACD;AAT4B,MAUrBD,EAVqB,GAUiBD,MAVjB,CAUrBC,EAVqB;AAAA,qBAUiBD,MAVjB,CAUjBG,IAViB;AAAA,MAUjBA,IAViB,gCAUV,CAVU;AAAA,2BAUiBH,MAVjB,CAUPI,UAVO;AAAA,MAUPA,UAVO,sCAUM,MAVN;;;AAY7BC,qBAASC,MAAT,CACE,8BAAC,KAAD,IAAO,MAAMH,IAAb,EAAmB,YAAYC,UAA/B,GADF,EAEEG,SAASC,cAAT,CAAwBP,EAAxB,CAFF;AAIA;AACD;;AAEDQ,OAAOV,aAAP,GAAuBA,aAAvB;;AAEA;AACA;AACA;AACA;AACA","file":"index.js","sourcesContent":["import React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport App, { Editor } from \"./App\";\nimport registerServiceWorker from \"./registerServiceWorker\";\n\nconst Index = props => (\n  <App showAlertComment showAlertReply showAlertFavor showError {...props}>\n    <Editor maxUpload={9} autoFocus />\n  </App>\n);\n\n/**\n * 渲染评论组件\n * @param {object} config 编辑器配置\n *  - {string} id 渲染评论的DOM的 ID\n *  - {number} type 评论的 type\n *  - {string} businessId 评论的 businessId\n */\nfunction renderComment(config) {\n  if (!config.id) {\n    throw new Error(\"id is required\");\n  }\n  if (!config.id) {\n    throw new Error(\"type is required\");\n  }\n  if (!config.id) {\n    throw new Error(\"businessId is required\");\n  }\n  const { id, type = 1, businessId = \"test\" } = config;\n\n  ReactDOM.render(\n    <Index type={type} businessId={businessId} />,\n    document.getElementById(id)\n  );\n  // registerServiceWorker();\n}\n\nwindow.renderComment = renderComment;\n\n// renderComment({\n//   id: \"root-comment\",\n//   type: 1,\n//   businessId: \"test\"\n// });\n"]}
1
+{"version":3,"sources":["../src/index.js"],"names":["Index","props","renderComment","config","id","Error","type","businessId","console","warn","API","userId","ReactDOM","render","document","getElementById","window"],"mappings":";;;;AAAA;;;;AACA;;;;AACA;;;;;;AACA;;AAEA,IAAMA,QAAQ,SAARA,KAAQ;AAAA,SACZ;AAAC,iBAAD;AAAA,eAAK,sBAAL,EAAsB,oBAAtB,EAAqC,oBAArC,EAAoD,eAApD,IAAkEC,KAAlE;AACE,kCAAC,WAAD,IAAQ,WAAW,CAAnB,EAAsB,eAAtB;AADF,GADY;AAAA,CAAd;;AAMA;;;;;;;;AAQA,SAASC,aAAT,CAAuBC,MAAvB,EAA+B;AAC7B,MAAI,CAACA,OAAOC,EAAZ,EAAgB;AACd,UAAM,IAAIC,KAAJ,CAAU,gBAAV,CAAN;AACD;AACD,MAAI,CAACF,OAAOG,IAAZ,EAAkB;AAChB,UAAM,IAAID,KAAJ,CAAU,kBAAV,CAAN;AACD;AACD,MAAI,CAACF,OAAOI,UAAZ,EAAwB;AACtB;AACAC,YAAQC,IAAR,CAAa,+BAAb;AACD;AACD,MAAI,CAACN,OAAOO,GAAZ,EAAiB;AACf;AACAF,YAAQC,IAAR,CACE,sDADF;AAGD;AAhB4B,MAkB3BL,EAlB2B,GAuBzBD,MAvByB,CAkB3BC,EAlB2B;AAAA,qBAuBzBD,MAvByB,CAmB3BG,IAnB2B;AAAA,MAmB3BA,IAnB2B,gCAmBpB,CAnBoB;AAAA,2BAuBzBH,MAvByB,CAoB3BI,UApB2B;AAAA,MAoB3BA,UApB2B,sCAoBd,MApBc;AAAA,oBAuBzBJ,MAvByB,CAqB3BO,GArB2B;AAAA,MAqB3BA,GArB2B,+BAqBrB,oCArBqB;AAAA,MAsB3BC,MAtB2B,GAuBzBR,MAvByB,CAsB3BQ,MAtB2B;;;AAyB7BC,qBAASC,MAAT,CACE,8BAAC,KAAD,IAAO,MAAMP,IAAb,EAAmB,YAAYC,UAA/B,EAA2C,KAAKG,GAAhD,EAAqD,QAAQC,MAA7D,GADF,EAEEG,SAASC,cAAT,CAAwBX,EAAxB,CAFF;AAIA;AACD;;AAEDY,OAAOd,aAAP,GAAuBA,aAAvB;;AAEAA,cAAc;AACZE,MAAI,cADQ;AAEZE,QAAM,CAFM;AAGZC,cAAY;AAHA,CAAd;;AAMA;AACA;AACA;AACA;AACA;AACA","file":"index.js","sourcesContent":["import React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport App, { Editor } from \"./App\";\n// import registerServiceWorker from \"./registerServiceWorker\";\n\nconst Index = props => (\n  <App showAlertComment showAlertReply showAlertFavor showError {...props}>\n    <Editor maxUpload={9} autoFocus />\n  </App>\n);\n\n/**\n * 渲染评论组件\n * @param {object} config 编辑器配置\n *  - {string} id 渲染评论的DOM的 ID\n *  - {number} type 评论的 type\n *  - {string} businessId 评论的 businessId\n *  - {string} API, API 前缀, 默认 http://api.links123.net/comment/v1\n */\nfunction renderComment(config) {\n  if (!config.id) {\n    throw new Error(\"id is required\");\n  }\n  if (!config.type) {\n    throw new Error(\"type is required\");\n  }\n  if (!config.businessId) {\n    // throw new Error(\"businessId is required\");\n    console.warn(\"没有传入 businessId 参数,默认使用: test\");\n  }\n  if (!config.API) {\n    // throw new Error(\"API is required\");\n    console.warn(\n      \"没有传入 API 参数,默认使用: http://api.links123.net/comment/v1\"\n    );\n  }\n  const {\n    id,\n    type = 1,\n    businessId = \"test\",\n    API = \"http://api.links123.net/comment/v1\",\n    userId\n  } = config;\n\n  ReactDOM.render(\n    <Index type={type} businessId={businessId} API={API} userId={userId} />,\n    document.getElementById(id)\n  );\n  // registerServiceWorker();\n}\n\nwindow.renderComment = renderComment;\n\nrenderComment({\n  id: \"root-comment\",\n  type: 1,\n  businessId: \"test\"\n});\n\n// renderComment({\n//   id: \"root-comment\",\n//   type: 1,\n//   businessId: \"test\",\n//   API: 'http://api.links123.net/comment/v1',\n// });\n"]}

+ 43
- 0
lib/lang/en-US.js Целия файл

@@ -0,0 +1,43 @@
1
+"use strict";
2
+
3
+Object.defineProperty(exports, "__esModule", {
4
+  value: true
5
+});
6
+var USdata = {
7
+  "editor.alreadyEntered": "already entered {count}/{maxLength}",
8
+  "editor.placeholder": "say...",
9
+  "editor.maxLength": "Input number must < {maxLength}",
10
+  "editor.SubmitBtn": "Submit",
11
+  "editor.uploadTip": "Upload Pictures",
12
+  "editor.uploadCount": "(You can also upload {count} images)",
13
+  "editor.uploadBtn": "upload",
14
+
15
+  "comment.tourist": "tourist",
16
+  "comment.totalComment": "total {total, plural, =1 {one comment} other {# comments}}",
17
+  "comment.reply": "reply",
18
+  "comment.moreComment": "More",
19
+
20
+  "reply.totalReply": "{total, plural, =1 {one reply} other {# replies}}",
21
+  "reply.moreReply": "More",
22
+  "reply.collapse": "clloasp reply",
23
+
24
+  "picture.collapse": "collapse",
25
+  "picture.viewOriginal": "view original picture",
26
+
27
+  "popConfirm.title": "Sure?",
28
+  "popConfirm.ok": "Ok",
29
+  "popConfirm.cancel": "Cancel",
30
+  "popConfirm.delete": "Delete",
31
+
32
+  "message.noMoreComment": "no more comment",
33
+  "message.noMoreData": "no more data",
34
+  "message.notNull": "comment not null",
35
+  "message.success": "comment success",
36
+  "message.replyNoNull": "reply not null",
37
+  "message.replySuccess": "reply success",
38
+  "message.cancelLickSuccess": "cancel like success",
39
+  "message.likeSuccess": "like success"
40
+};
41
+
42
+exports.default = USdata;
43
+//# sourceMappingURL=en-US.js.map

+ 1
- 0
lib/lang/en-US.js.map Целия файл

@@ -0,0 +1 @@
1
+{"version":3,"sources":["../../src/lang/en-US.js"],"names":["USdata"],"mappings":";;;;;AAAA,IAAMA,SAAS;AACb,2BAAyB,qCADZ;AAEb,wBAAsB,QAFT;AAGb,sBAAoB,iCAHP;AAIb,sBAAoB,QAJP;AAKb,sBAAoB,iBALP;AAMb,wBAAsB,sCANT;AAOb,sBAAoB,QAPP;;AASb,qBAAmB,SATN;AAUb,0BACE,4DAXW;AAYb,mBAAiB,OAZJ;AAab,yBAAuB,MAbV;;AAeb,sBAAoB,mDAfP;AAgBb,qBAAmB,MAhBN;AAiBb,oBAAkB,eAjBL;;AAmBb,sBAAoB,UAnBP;AAoBb,0BAAwB,uBApBX;;AAsBb,sBAAoB,OAtBP;AAuBb,mBAAiB,IAvBJ;AAwBb,uBAAqB,QAxBR;AAyBb,uBAAqB,QAzBR;;AA2Bb,2BAAyB,iBA3BZ;AA4Bb,wBAAsB,cA5BT;AA6Bb,qBAAmB,kBA7BN;AA8Bb,qBAAmB,iBA9BN;AA+Bb,yBAAuB,gBA/BV;AAgCb,0BAAwB,eAhCX;AAiCb,+BAA6B,qBAjChB;AAkCb,yBAAuB;AAlCV,CAAf;;kBAqCeA,M","file":"en-US.js","sourcesContent":["const USdata = {\n  \"editor.alreadyEntered\": \"already entered {count}/{maxLength}\",\n  \"editor.placeholder\": \"say...\",\n  \"editor.maxLength\": \"Input number must < {maxLength}\",\n  \"editor.SubmitBtn\": \"Submit\",\n  \"editor.uploadTip\": \"Upload Pictures\",\n  \"editor.uploadCount\": \"(You can also upload {count} images)\",\n  \"editor.uploadBtn\": \"upload\",\n\n  \"comment.tourist\": \"tourist\",\n  \"comment.totalComment\":\n    \"total {total, plural, =1 {one comment} other {# comments}}\",\n  \"comment.reply\": \"reply\",\n  \"comment.moreComment\": \"More\",\n\n  \"reply.totalReply\": \"{total, plural, =1 {one reply} other {# replies}}\",\n  \"reply.moreReply\": \"More\",\n  \"reply.collapse\": \"clloasp reply\",\n\n  \"picture.collapse\": \"collapse\",\n  \"picture.viewOriginal\": \"view original picture\",\n\n  \"popConfirm.title\": \"Sure?\",\n  \"popConfirm.ok\": \"Ok\",\n  \"popConfirm.cancel\": \"Cancel\",\n  \"popConfirm.delete\": \"Delete\",\n\n  \"message.noMoreComment\": \"no more comment\",\n  \"message.noMoreData\": \"no more data\",\n  \"message.notNull\": \"comment not null\",\n  \"message.success\": \"comment success\",\n  \"message.replyNoNull\": \"reply not null\",\n  \"message.replySuccess\": \"reply success\",\n  \"message.cancelLickSuccess\": \"cancel like success\",\n  \"message.likeSuccess\": \"like success\"\n};\n\nexport default USdata;\n"]}

+ 37
- 15
lib/lang/index.js Целия файл

@@ -3,20 +3,42 @@
3 3
 Object.defineProperty(exports, "__esModule", {
4 4
   value: true
5 5
 });
6
-// 语言包
7
-// 英文短语和中文提示的对应
8
-var data = {
9
-  "not found": "没有数据",
10
-  "auth failed": "请先登录",
11
-  "create comment failed": "创建评论失败",
12
-  "comment favor failed": "评论点赞失败",
13
-  "delete comment favor failed": "评论取消点赞失败",
14
-  "get comments failed": "获取评论列表失败",
15
-  "create reply failed": "创建回复失败",
16
-  "reply favor failed": "回复点赞失败",
17
-  "delete reply favor failed": "删除回复点赞失败",
18
-  "get replies failed": "获取回复列表失败"
19
-};
6
+/**
7
+ * 当前支持的语言
8
+ */
9
+var SUPPORT_LOCALES = exports.SUPPORT_LOCALES = [{
10
+  name: "English",
11
+  value: "en-US"
12
+}, {
13
+  name: "简体中文",
14
+  value: "zh-CN"
15
+}];
20 16
 
21
-exports.default = data;
17
+// 服务端返回的英文短语和中文提示的对应
18
+var LOCALES_RESPONSE = exports.LOCALES_RESPONSE = {
19
+  "zh-CN": {
20
+    "not found": "没有数据",
21
+    "auth failed": "请先登录",
22
+    "create comment failed": "创建评论失败",
23
+    "comment favor failed": "评论点赞失败",
24
+    "delete comment favor failed": "评论取消点赞失败",
25
+    "get comments failed": "获取评论列表失败",
26
+    "create reply failed": "创建回复失败",
27
+    "reply favor failed": "回复点赞失败",
28
+    "delete reply favor failed": "删除回复点赞失败",
29
+    "get replies failed": "获取回复列表失败"
30
+  },
31
+  "en-US": {
32
+    "not found": "no data",
33
+    "auth failed": "please log in first",
34
+    "create comment failed": "Failed to create comment",
35
+    "comment favor failed": "Comment likes failure",
36
+    "delete comment favor failed": "评论取消点赞失败",
37
+    "get comments failed": "Comment cancels praise failure",
38
+    "create reply failed": "Create reply failed",
39
+    "reply favor failed": "Reply to praise failed",
40
+    "delete reply favor failed": "Delete reply clicks failed",
41
+    "get replies failed": "Failed to get reply list"
42
+  }
43
+};
22 44
 //# sourceMappingURL=index.js.map

+ 1
- 1
lib/lang/index.js.map Целия файл

@@ -1 +1 @@
1
-{"version":3,"sources":["../../src/lang/index.js"],"names":["data"],"mappings":";;;;;AAAA;AACA;AACA,IAAMA,OAAO;AACX,eAAa,MADF;AAEX,iBAAe,MAFJ;AAGX,2BAAyB,QAHd;AAIX,0BAAwB,QAJb;AAKX,iCAA+B,UALpB;AAMX,yBAAuB,UANZ;AAOX,yBAAuB,QAPZ;AAQX,wBAAsB,QARX;AASX,+BAA6B,UATlB;AAUX,wBAAsB;AAVX,CAAb;;kBAaeA,I","file":"index.js","sourcesContent":["// 语言包\n// 英文短语和中文提示的对应\nconst data = {\n  \"not found\": \"没有数据\",\n  \"auth failed\": \"请先登录\",\n  \"create comment failed\": \"创建评论失败\",\n  \"comment favor failed\": \"评论点赞失败\",\n  \"delete comment favor failed\": \"评论取消点赞失败\",\n  \"get comments failed\": \"获取评论列表失败\",\n  \"create reply failed\": \"创建回复失败\",\n  \"reply favor failed\": \"回复点赞失败\",\n  \"delete reply favor failed\": \"删除回复点赞失败\",\n  \"get replies failed\": \"获取回复列表失败\"\n};\n\nexport default data;\n"]}
1
+{"version":3,"sources":["../../src/lang/index.js"],"names":["SUPPORT_LOCALES","name","value","LOCALES_RESPONSE"],"mappings":";;;;;AAAA;;;AAGO,IAAMA,4CAAkB,CAC7B;AACEC,QAAM,SADR;AAEEC,SAAO;AAFT,CAD6B,EAK7B;AACED,QAAM,MADR;AAEEC,SAAO;AAFT,CAL6B,CAAxB;;AAWP;AACO,IAAMC,8CAAmB;AAC9B,WAAS;AACP,iBAAa,MADN;AAEP,mBAAe,MAFR;AAGP,6BAAyB,QAHlB;AAIP,4BAAwB,QAJjB;AAKP,mCAA+B,UALxB;AAMP,2BAAuB,UANhB;AAOP,2BAAuB,QAPhB;AAQP,0BAAsB,QARf;AASP,iCAA6B,UATtB;AAUP,0BAAsB;AAVf,GADqB;AAa9B,WAAS;AACP,iBAAa,SADN;AAEP,mBAAe,qBAFR;AAGP,6BAAyB,0BAHlB;AAIP,4BAAwB,uBAJjB;AAKP,mCAA+B,UALxB;AAMP,2BAAuB,gCANhB;AAOP,2BAAuB,qBAPhB;AAQP,0BAAsB,wBARf;AASP,iCAA6B,4BATtB;AAUP,0BAAsB;AAVf;AAbqB,CAAzB","file":"index.js","sourcesContent":["/**\n * 当前支持的语言\n */\nexport const SUPPORT_LOCALES = [\n  {\n    name: \"English\",\n    value: \"en-US\"\n  },\n  {\n    name: \"简体中文\",\n    value: \"zh-CN\"\n  }\n];\n\n// 服务端返回的英文短语和中文提示的对应\nexport const LOCALES_RESPONSE = {\n  \"zh-CN\": {\n    \"not found\": \"没有数据\",\n    \"auth failed\": \"请先登录\",\n    \"create comment failed\": \"创建评论失败\",\n    \"comment favor failed\": \"评论点赞失败\",\n    \"delete comment favor failed\": \"评论取消点赞失败\",\n    \"get comments failed\": \"获取评论列表失败\",\n    \"create reply failed\": \"创建回复失败\",\n    \"reply favor failed\": \"回复点赞失败\",\n    \"delete reply favor failed\": \"删除回复点赞失败\",\n    \"get replies failed\": \"获取回复列表失败\"\n  },\n  \"en-US\": {\n    \"not found\": \"no data\",\n    \"auth failed\": \"please log in first\",\n    \"create comment failed\": \"Failed to create comment\",\n    \"comment favor failed\": \"Comment likes failure\",\n    \"delete comment favor failed\": \"评论取消点赞失败\",\n    \"get comments failed\": \"Comment cancels praise failure\",\n    \"create reply failed\": \"Create reply failed\",\n    \"reply favor failed\": \"Reply to praise failed\",\n    \"delete reply favor failed\": \"Delete reply clicks failed\",\n    \"get replies failed\": \"Failed to get reply list\"\n  }\n};\n"]}

+ 43
- 0
lib/lang/zh-CN.js Целия файл

@@ -0,0 +1,43 @@
1
+"use strict";
2
+
3
+Object.defineProperty(exports, "__esModule", {
4
+  value: true
5
+});
6
+var CNdata = {
7
+  "editor.alreadyEntered": "已输入{count}/140字",
8
+  "editor.placeholder": "说点什么吧...",
9
+  "editor.maxLength": "字数不过超过{maxLength}字",
10
+  "editor.SubmitBtn": "发表",
11
+  "editor.uploadTip": "上传图片",
12
+  "editor.uploadCount": "(您还能上传{count}张图片)",
13
+  "editor.uploadBtn": "上传",
14
+
15
+  "comment.tourist": "游客",
16
+  "comment.totalComment": "共{total}条评论",
17
+  "comment.reply": "回复",
18
+  "comment.moreComment": "查看更多评论",
19
+
20
+  "reply.totalReply": "{total}条回复",
21
+  "reply.moreReply": "查看更多回复",
22
+  "reply.collapse": "收起回复",
23
+
24
+  "picture.collapse": "收起",
25
+  "picture.viewOriginal": "查看原图",
26
+
27
+  "popConfirm.title": "确定要删除吗",
28
+  "popConfirm.ok": "确定",
29
+  "popConfirm.cancel": "取消",
30
+  "popConfirm.delete": "删除",
31
+
32
+  "message.noMoreComment": "没有更多评论了",
33
+  "message.noMoreData": "没有更多数据了!",
34
+  "message.notNull": "评论内容不能为空",
35
+  "message.success": "评论成功!",
36
+  "message.replyNoNull": "回复内容不能为空",
37
+  "message.replySuccess": "回复成功!",
38
+  "message.cancelLickSuccess": "取消点赞成功!",
39
+  "message.likeSuccess": "点赞成功!"
40
+};
41
+
42
+exports.default = CNdata;
43
+//# sourceMappingURL=zh-CN.js.map

+ 1
- 0
lib/lang/zh-CN.js.map Целия файл

@@ -0,0 +1 @@
1
+{"version":3,"sources":["../../src/lang/zh-CN.js"],"names":["CNdata"],"mappings":";;;;;AAAA,IAAMA,SAAS;AACb,2BAAyB,iBADZ;AAEb,wBAAsB,UAFT;AAGb,sBAAoB,oBAHP;AAIb,sBAAoB,IAJP;AAKb,sBAAoB,MALP;AAMb,wBAAsB,mBANT;AAOb,sBAAoB,IAPP;;AASb,qBAAmB,IATN;AAUb,0BAAwB,aAVX;AAWb,mBAAiB,IAXJ;AAYb,yBAAuB,QAZV;;AAcb,sBAAoB,YAdP;AAeb,qBAAmB,QAfN;AAgBb,oBAAkB,MAhBL;;AAkBb,sBAAoB,IAlBP;AAmBb,0BAAwB,MAnBX;;AAqBb,sBAAoB,QArBP;AAsBb,mBAAiB,IAtBJ;AAuBb,uBAAqB,IAvBR;AAwBb,uBAAqB,IAxBR;;AA0Bb,2BAAyB,SA1BZ;AA2Bb,wBAAsB,UA3BT;AA4Bb,qBAAmB,UA5BN;AA6Bb,qBAAmB,OA7BN;AA8Bb,yBAAuB,UA9BV;AA+Bb,0BAAwB,OA/BX;AAgCb,+BAA6B,SAhChB;AAiCb,yBAAuB;AAjCV,CAAf;;kBAoCeA,M","file":"zh-CN.js","sourcesContent":["const CNdata = {\n  \"editor.alreadyEntered\": \"已输入{count}/140字\",\n  \"editor.placeholder\": \"说点什么吧...\",\n  \"editor.maxLength\": \"字数不过超过{maxLength}字\",\n  \"editor.SubmitBtn\": \"发表\",\n  \"editor.uploadTip\": \"上传图片\",\n  \"editor.uploadCount\": \"(您还能上传{count}张图片)\",\n  \"editor.uploadBtn\": \"上传\",\n\n  \"comment.tourist\": \"游客\",\n  \"comment.totalComment\": \"共{total}条评论\",\n  \"comment.reply\": \"回复\",\n  \"comment.moreComment\": \"查看更多评论\",\n\n  \"reply.totalReply\": \"{total}条回复\",\n  \"reply.moreReply\": \"查看更多回复\",\n  \"reply.collapse\": \"收起回复\",\n\n  \"picture.collapse\": \"收起\",\n  \"picture.viewOriginal\": \"查看原图\",\n\n  \"popConfirm.title\": \"确定要删除吗\",\n  \"popConfirm.ok\": \"确定\",\n  \"popConfirm.cancel\": \"取消\",\n  \"popConfirm.delete\": \"删除\",\n\n  \"message.noMoreComment\": \"没有更多评论了\",\n  \"message.noMoreData\": \"没有更多数据了!\",\n  \"message.notNull\": \"评论内容不能为空\",\n  \"message.success\": \"评论成功!\",\n  \"message.replyNoNull\": \"回复内容不能为空\",\n  \"message.replySuccess\": \"回复成功!\",\n  \"message.cancelLickSuccess\": \"取消点赞成功!\",\n  \"message.likeSuccess\": \"点赞成功!\"\n};\n\nexport default CNdata;\n"]}

+ 1
- 1
package.json Целия файл

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "comment",
3
-  "version": "0.5.13",
3
+  "version": "0.5.14",
4 4
   "main": "lib/App.js",
5 5
   "description": "通用评论",
6 6
   "keywords": [

+ 6
- 2
src/App.js Целия файл

@@ -3,7 +3,7 @@ import PropTypes from "prop-types";
3 3
 import { message } from "antd";
4 4
 import axios from "axios";
5 5
 import intl from "react-intl-universal";
6
-import { ERROR_DEFAULT, LIMIT } from "./constant";
6
+import { ERROR_DEFAULT, LIMIT, COMMENT_TYPE } from "./constant";
7 7
 import { CommentContext } from "./Comment";
8 8
 import { isFunction } from "./helper";
9 9
 import CommentInput from "./components/CommentInput";
@@ -265,6 +265,7 @@ class App extends Component {
265 265
         const { list, total } = this.state;
266 266
         const res = list.filter(item => item.id !== commentId);
267 267
         this.setState({ list: res, total: total - 1 });
268
+        this.props.onDelete(COMMENT_TYPE.COMMENT);
268 269
       })
269 270
       .catch(this.errorHandler)
270 271
       .finally(() => {
@@ -335,6 +336,7 @@ class App extends Component {
335 336
           return item;
336 337
         });
337 338
         this.setState({ list });
339
+        this.props.onDelete(COMMENT_TYPE.REPLY);
338 340
       })
339 341
       .catch(this.errorHandler)
340 342
       .finally(() => {
@@ -491,6 +493,7 @@ App.propTypes = {
491 493
   pageType: PropTypes.string, // 分页类型
492 494
   page: PropTypes.number, // 页码
493 495
   onPageChange: PropTypes.func, // 页码变化回调
496
+  onDelete: PropTypes.func,
494 497
   locales: PropTypes.string //  传入的语言环境, en-US/zh-CN
495 498
 };
496 499
 
@@ -503,7 +506,8 @@ App.defaultProps = {
503 506
   showAlertFavor: false,
504 507
   showError: true,
505 508
   pageType: "more",
506
-  onPageChange: page => {}
509
+  onPageChange: page => {},
510
+  onDelete: () => {}
507 511
 };
508 512
 
509 513
 export { Editor, RenderText };

+ 8
- 6
src/components/Editor/index.js Целия файл

@@ -244,7 +244,8 @@ class Editor extends React.Component {
244 244
               {showUpload ? (
245 245
                 <Popover
246 246
                   trigger="click"
247
-                  visible={this.state.showUpload}
247
+                  // TODO: 针对非 react.js,直接使用 click 事件来控制展开或关闭
248
+                  // visible={this.state.showUpload}
248 249
                   overlayStyle={{ zIndex: 999 }}
249 250
                   onVisibleChange={
250 251
                     closeUploadWhenBlur
@@ -279,13 +280,14 @@ class Editor extends React.Component {
279 280
                         {intl.get("editor.uploadTip")}
280 281
                         {maxUpload >= 2 ? (
281 282
                           <span style={{ color: "#666", fontWeight: 400 }}>
282
-                            {intl.get("editor.uploadCount", {
283
-                              count: maxUpload - this.state.fileList.length
284
-                            })}
283
+                            (您还能上传
284
+                            {maxUpload - this.state.fileList.length}
285
+                            张图片)
285 286
                           </span>
286 287
                         ) : null}
287 288
                       </span>
288
-                      <Icon
289
+                      {/* 因为是点击别的区域关闭,所以不用右上角的 Icon */}
290
+                      {/* <Icon
289 291
                         type="close"
290 292
                         onClick={() => this.handleShowUpload(false)}
291 293
                         style={{
@@ -293,7 +295,7 @@ class Editor extends React.Component {
293 295
                           cursor: "pointer",
294 296
                           marginTop: 4
295 297
                         }}
296
-                      />
298
+                      /> */}
297 299
                     </div>
298 300
                   }
299 301
                 >

+ 5
- 0
src/constant.js Целия файл

@@ -21,3 +21,8 @@ export const IMAGE_SPLIT = "IMAGE_SPLIT";
21 21
 export const IMAGE_PROCESS = "?x-oss-process=image/resize,h_350";
22 22
 export const IMAGE_PROCESS_SMALL = "?x-oss-process=image/resize,h_100";
23 23
 export const IMAGE_PROCESS_LARGE = "?x-oss-process=image/resize,h_500";
24
+
25
+export const COMMENT_TYPE = {
26
+  COMMENT: "comment",
27
+  REPLY: "reply"
28
+};

+ 26
- 5
src/index.js Целия файл

@@ -15,21 +15,35 @@ const Index = props => (
15 15
  *  - {string} id 渲染评论的DOM的 ID
16 16
  *  - {number} type 评论的 type
17 17
  *  - {string} businessId 评论的 businessId
18
+ *  - {string} API, API 前缀, 默认 http://api.links123.net/comment/v1
18 19
  */
19 20
 function renderComment(config) {
20 21
   if (!config.id) {
21 22
     throw new Error("id is required");
22 23
   }
23
-  if (!config.id) {
24
+  if (!config.type) {
24 25
     throw new Error("type is required");
25 26
   }
26
-  if (!config.id) {
27
-    throw new Error("businessId is required");
27
+  if (!config.businessId) {
28
+    // throw new Error("businessId is required");
29
+    console.warn("没有传入 businessId 参数,默认使用: test");
28 30
   }
29
-  const { id, type = 1, businessId = "test" } = config;
31
+  if (!config.API) {
32
+    // throw new Error("API is required");
33
+    console.warn(
34
+      "没有传入 API 参数,默认使用: http://api.links123.net/comment/v1"
35
+    );
36
+  }
37
+  const {
38
+    id,
39
+    type = 1,
40
+    businessId = "test",
41
+    API = "http://api.links123.net/comment/v1",
42
+    userId
43
+  } = config;
30 44
 
31 45
   ReactDOM.render(
32
-    <Index type={type} businessId={businessId} />,
46
+    <Index type={type} businessId={businessId} API={API} userId={userId} />,
33 47
     document.getElementById(id)
34 48
   );
35 49
   // registerServiceWorker();
@@ -42,3 +56,10 @@ renderComment({
42 56
   type: 1,
43 57
   businessId: "test"
44 58
 });
59
+
60
+// renderComment({
61
+//   id: "root-comment",
62
+//   type: 1,
63
+//   businessId: "test",
64
+//   API: 'http://api.links123.net/comment/v1',
65
+// });