Browse Source

merge master

node 6 years ago
parent
commit
30c30d6538

+ 5
- 0
CHANGELOG.md View File

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

+ 42
- 33
README.md View File

2
 
2
 
3
 通用评论系统及编辑器
3
 通用评论系统及编辑器
4
 
4
 
5
-**`version 0.5.13`**
5
+**`version 0.5.14`**
6
 
6
 
7
 ```js
7
 ```js
8
 import Comment, { Editor, RenderText } from 'comment';
8
 import Comment, { Editor, RenderText } from 'comment';
42
 
42
 
43
 ### 在非 React.js 项目中使用 ~~作为静态文件引入~~
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
 2. 调用 `window.renderComment` 方法并传入对应参数来渲染通用评论。参数列表:
48
 2. 调用 `window.renderComment` 方法并传入对应参数来渲染通用评论。参数列表:
47
   - `id`: string, 必填, 渲染评论的节点的 ID
49
   - `id`: string, 必填, 渲染评论的节点的 ID
48
   - `type`: number, 必填, 评论的 type    
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
 具体可参考 `./assets/example.html`。
54
 具体可参考 `./assets/example.html`。
52
 
55
 
74
   <script type="text/javascript">
77
   <script type="text/javascript">
75
     // 调用 renderComment 这个方法,渲染通用评论
78
     // 调用 renderComment 这个方法,渲染通用评论
76
     window.renderComment({
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
   </script>
85
   </script>
82
 </body>
86
 </body>
83
 </html>
87
 </html>
98
 
102
 
99
 ```html
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
   <div id="RENDER_ELEMENT_WRAPPER"></div>
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
     window.renderComment({
147
     window.renderComment({
144
       id: id,
148
       id: id,
145
       type: 1,
149
       type: 1,
146
-      businessId: 'test'
150
+      businessId: 'test',
151
+      API: 'http://api.links123.net/comment/v1',
147
     })
152
     })
148
   })
153
   })
149
   
154
   
154
     window.renderComment({
159
     window.renderComment({
155
       id: id,
160
       id: id,
156
       type: 1,
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
 main();
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
 - 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)
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
 - 标记了`deprecated`的配置项表示不推荐使用,并且可能在将来版本中不再受支持。
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
 ## Editor
212
 ## Editor
204
 
213
 

+ 2
- 2
assets/example.html View File

5
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
5
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
   <title>通用评论 demo</title>
6
   <title>通用评论 demo</title>
7
   <meta name="viewport" content="width=device-width, initial-scale=1">
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
 </head>
9
 </head>
10
 <body>
10
 <body>
11
   <div>
11
   <div>
20
   </div>
20
   </div>
21
   
21
   
22
   <script src="http://gosspublic.alicdn.com/aliyun-oss-sdk.min.js"></script>
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
   <script type="text/javascript" src="example.js"></script>
24
   <script type="text/javascript" src="example.js"></script>
25
 </body>
25
 </body>
26
 </html>
26
 </html>

+ 10
- 7
assets/example.js View File

8
 function createElement(id) {
8
 function createElement(id) {
9
   var node = document.createElement('div');
9
   var node = document.createElement('div');
10
   node.setAttribute("id", id);
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
 
25
 
26
 
26
 
27
 function main() {
27
 function main() {
28
-  document.getElementById('render').addEventListener('click', function() {
28
+  document.getElementById('render').addEventListener('click', function () {
29
     // 首先清空父标签的内容
29
     // 首先清空父标签的内容
30
     removeChild(RENDER_ELEMENT_WRAPPER);
30
     removeChild(RENDER_ELEMENT_WRAPPER);
31
 
31
 
36
     window.renderComment({
36
     window.renderComment({
37
       id: id,
37
       id: id,
38
       type: 1,
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
     removeChild(RENDER_ELEMENT_WRAPPER)
45
     removeChild(RENDER_ELEMENT_WRAPPER)
45
     var id = RENDER_ELEMENT_COMMENT;
46
     var id = RENDER_ELEMENT_COMMENT;
46
     createElement(id)
47
     createElement(id)
47
     window.renderComment({
48
     window.renderComment({
48
       id: id,
49
       id: id,
49
       type: 1,
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
 main();
60
 main();

+ 0
- 1
assets/static/css/main.81c08691.css.map
File diff suppressed because it is too large
View File


assets/static/css/main.a3c3a441.css
File diff suppressed because it is too large
View File


+ 1
- 0
assets/static/css/main.a3c3a441.css.map
File diff suppressed because it is too large
View File


+ 2
- 0
assets/static/js/main.426815d8.js
File diff suppressed because it is too large
View File


+ 1
- 0
assets/static/js/main.426815d8.js.map
File diff suppressed because it is too large
View File


+ 0
- 2
assets/static/js/main.9d10db91.js
File diff suppressed because it is too large
View File


+ 0
- 1
assets/static/js/main.9d10db91.js.map
File diff suppressed because it is too large
View File


+ 112
- 56
lib/App.js View File

27
 
27
 
28
 var _axios2 = _interopRequireDefault(_axios);
28
 var _axios2 = _interopRequireDefault(_axios);
29
 
29
 
30
+var _reactIntlUniversal = require("react-intl-universal");
31
+
32
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
33
+
30
 var _constant = require("./constant");
34
 var _constant = require("./constant");
31
 
35
 
32
 var _Comment = require("./Comment");
36
 var _Comment = require("./Comment");
51
 
55
 
52
 var _lang = require("./lang");
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
 require("./App.css");
66
 require("./App.css");
57
 
67
 
58
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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
 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
72
 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
61
 
73
 
62
 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; }
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
 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; }
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
 var App = function (_Component) {
83
 var App = function (_Component) {
69
   _inherits(App, _Component);
84
   _inherits(App, _Component);
84
       page: 1,
99
       page: 1,
85
       total: 0,
100
       total: 0,
86
       // 是否没有更多评论了
101
       // 是否没有更多评论了
87
-      isNoMoreComment: false
102
+      isNoMoreComment: false,
103
+      initDone: false,
104
+      locale: "zh-CN"
88
     };
105
     };
89
     _this.handleChangeLoading = _this.handleChangeLoading.bind(_this);
106
     _this.handleChangeLoading = _this.handleChangeLoading.bind(_this);
90
     _this.sCreateComment = _this.sCreateComment.bind(_this);
107
     _this.sCreateComment = _this.sCreateComment.bind(_this);
111
     }
128
     }
112
   }, {
129
   }, {
113
     key: "componentDidMount",
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
     key: "error",
164
     key: "error",
117
     value: function error(msg) {
165
     value: function error(msg) {
127
   }, {
175
   }, {
128
     key: "errorHandler",
176
     key: "errorHandler",
129
     value: function errorHandler(error) {
177
     value: function errorHandler(error) {
178
+      var locale = this.state.locale;
179
+
180
+      var localResponse = _lang.LOCALES_RESPONSE[locale];
130
       if (error.response && error.response.data && error.response.data.msg) {
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
           response: error.response
183
           response: error.response
133
         });
184
         });
134
         return;
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
         response: error.response
188
         response: error.response
138
       });
189
       });
139
     }
190
     }
160
   }, {
211
   }, {
161
     key: "sGetComment",
212
     key: "sGetComment",
162
     value: function sGetComment() {
213
     value: function sGetComment() {
163
-      var _this2 = this;
214
+      var _this3 = this;
164
 
215
 
165
       var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
216
       var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
166
           _ref$page = _ref.page,
217
           _ref$page = _ref.page,
182
 
233
 
183
         if (list) {
234
         if (list) {
184
           var newList = list;
235
           var newList = list;
185
-          var oldList = _this2.state.list;
236
+          var oldList = _this3.state.list;
186
 
237
 
187
           if (pageType === "more") {
238
           if (pageType === "more") {
188
             if (page > 1) {
239
             if (page > 1) {
197
             window.scrollTo(0, 0);
248
             window.scrollTo(0, 0);
198
           }
249
           }
199
 
250
 
200
-          _this2.setState({
251
+          _this3.setState({
201
             list: newList,
252
             list: newList,
202
             page: page,
253
             page: page,
203
             total: total
254
             total: total
204
           });
255
           });
205
         } else {
256
         } else {
206
-          _message3.default.info("没有更多评论了");
207
-          _this2.setState({
257
+          _message3.default.info(_reactIntlUniversal2.default.get("message.noMoreComment"));
258
+          _this3.setState({
208
             isNoMoreComment: true
259
             isNoMoreComment: true
209
           });
260
           });
210
         }
261
         }
211
       }).catch(this.errorHandler).finally(function () {
262
       }).catch(this.errorHandler).finally(function () {
212
-        _this2.handleChangeLoading("sGetComment", false);
263
+        _this3.handleChangeLoading("sGetComment", false);
213
       });
264
       });
214
     }
265
     }
215
 
266
 
220
   }, {
271
   }, {
221
     key: "sGetReply",
272
     key: "sGetReply",
222
     value: function sGetReply() {
273
     value: function sGetReply() {
223
-      var _this3 = this;
274
+      var _this4 = this;
224
 
275
 
225
       var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
276
       var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
226
           commentId = _ref2.commentId,
277
           commentId = _ref2.commentId,
232
 
283
 
233
       this.axios.get(API + "/replies?comment_id=" + commentId + "&page=" + page + "&limit=" + _constant.LIMIT).then(function (response) {
284
       this.axios.get(API + "/replies?comment_id=" + commentId + "&page=" + page + "&limit=" + _constant.LIMIT).then(function (response) {
234
         if (!response.data.list) {
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
           if (item.id === commentId) {
289
           if (item.id === commentId) {
239
             if (!item.replies) item.replies = [];
290
             if (!item.replies) item.replies = [];
240
             if (response.data.list) {
291
             if (response.data.list) {
256
           }
307
           }
257
           return item;
308
           return item;
258
         });
309
         });
259
-        _this3.setState({ list: list });
310
+        _this4.setState({ list: list });
260
       }).catch(this.errorHandler).finally(function () {
311
       }).catch(this.errorHandler).finally(function () {
261
-        _this3.handleChangeLoading("sGetReply", false);
312
+        _this4.handleChangeLoading("sGetReply", false);
262
       });
313
       });
263
     }
314
     }
264
 
315
 
270
   }, {
321
   }, {
271
     key: "sCreateComment",
322
     key: "sCreateComment",
272
     value: function sCreateComment() {
323
     value: function sCreateComment() {
273
-      var _this4 = this;
324
+      var _this5 = this;
274
 
325
 
275
       var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
326
       var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
276
           content = _ref3.content;
327
           content = _ref3.content;
277
 
328
 
278
       var cb = arguments[1];
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
       this.handleChangeLoading("sCreateComment", true);
332
       this.handleChangeLoading("sCreateComment", true);
282
       var _props2 = this.props,
333
       var _props2 = this.props,
283
           API = _props2.API,
334
           API = _props2.API,
293
         },
344
         },
294
         withCredentials: true
345
         withCredentials: true
295
       }).then(function (response) {
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
         if ((0, _helper.isFunction)(cb)) cb();
350
         if ((0, _helper.isFunction)(cb)) cb();
300
         // 将数据写入到 list 中
351
         // 将数据写入到 list 中
301
         // 临时插入
352
         // 临时插入
302
         // 等到获取数据之后,删除临时数据
353
         // 等到获取数据之后,删除临时数据
303
-        var _state = _this4.state,
354
+        var _state = _this5.state,
304
             list = _state.list,
355
             list = _state.list,
305
             total = _state.total;
356
             total = _state.total;
306
 
357
 
307
         list.unshift(_extends({}, response.data, {
358
         list.unshift(_extends({}, response.data, {
308
           isTemporary: true // 临时的数据
359
           isTemporary: true // 临时的数据
309
         }));
360
         }));
310
-        _this4.setState({ list: list, total: total + 1 });
361
+        _this5.setState({ list: list, total: total + 1 });
311
       }).catch(this.errorHandler).finally(function () {
362
       }).catch(this.errorHandler).finally(function () {
312
-        _this4.handleChangeLoading("sCreateComment", false);
363
+        _this5.handleChangeLoading("sCreateComment", false);
313
       });
364
       });
314
     }
365
     }
315
 
366
 
320
   }, {
371
   }, {
321
     key: "sDeleteComment",
372
     key: "sDeleteComment",
322
     value: function sDeleteComment(commentId) {
373
     value: function sDeleteComment(commentId) {
323
-      var _this5 = this;
374
+      var _this6 = this;
324
 
375
 
325
       this.handleChangeLoading("sDeleteComment", true);
376
       this.handleChangeLoading("sDeleteComment", true);
326
       var API = this.props.API;
377
       var API = this.props.API;
329
         method: "delete",
380
         method: "delete",
330
         withCredentials: true
381
         withCredentials: true
331
       }).then(function () {
382
       }).then(function () {
332
-        var _state2 = _this5.state,
383
+        var _state2 = _this6.state,
333
             list = _state2.list,
384
             list = _state2.list,
334
             total = _state2.total;
385
             total = _state2.total;
335
 
386
 
336
         var res = list.filter(function (item) {
387
         var res = list.filter(function (item) {
337
           return item.id !== commentId;
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
       }).catch(this.errorHandler).finally(function () {
392
       }).catch(this.errorHandler).finally(function () {
341
-        _this5.handleChangeLoading("sDeleteComment", false);
393
+        _this6.handleChangeLoading("sDeleteComment", false);
342
       });
394
       });
343
     }
395
     }
344
 
396
 
351
   }, {
403
   }, {
352
     key: "sCreateReply",
404
     key: "sCreateReply",
353
     value: function sCreateReply(data, cb) {
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
       this.handleChangeLoading("sCreateReply", true);
409
       this.handleChangeLoading("sCreateReply", true);
358
       var API = this.props.API;
410
       var API = this.props.API;
359
 
411
 
362
         data: data,
414
         data: data,
363
         withCredentials: true
415
         withCredentials: true
364
       }).then(function (response) {
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
         if ((0, _helper.isFunction)(cb)) cb();
420
         if ((0, _helper.isFunction)(cb)) cb();
369
         // 将数据写入到 list 中
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
           if (item.id === data.comment_id) {
425
           if (item.id === data.comment_id) {
374
             if (!item.replies) item.replies = [];
426
             if (!item.replies) item.replies = [];
375
             item.replies.push(_extends({}, response.data, {
427
             item.replies.push(_extends({}, response.data, {
379
           }
431
           }
380
           return item;
432
           return item;
381
         });
433
         });
382
-        _this6.setState({ list: list });
434
+        _this7.setState({ list: list });
383
       }).catch(this.errorHandler).finally(function () {
435
       }).catch(this.errorHandler).finally(function () {
384
-        _this6.handleChangeLoading("sCreateReply", false);
436
+        _this7.handleChangeLoading("sCreateReply", false);
385
       });
437
       });
386
     }
438
     }
387
 
439
 
394
   }, {
446
   }, {
395
     key: "sDeleteReply",
447
     key: "sDeleteReply",
396
     value: function sDeleteReply(replyId, commentId) {
448
     value: function sDeleteReply(replyId, commentId) {
397
-      var _this7 = this;
449
+      var _this8 = this;
398
 
450
 
399
       this.handleChangeLoading("sDeleteReply", true);
451
       this.handleChangeLoading("sDeleteReply", true);
400
       var API = this.props.API;
452
       var API = this.props.API;
403
         method: "delete",
455
         method: "delete",
404
         withCredentials: true
456
         withCredentials: true
405
       }).then(function () {
457
       }).then(function () {
406
-        var list = _this7.state.list.map(function (item) {
458
+        var list = _this8.state.list.map(function (item) {
407
           if (item.id === commentId) {
459
           if (item.id === commentId) {
408
             var replies = item.replies.filter(function (item) {
460
             var replies = item.replies.filter(function (item) {
409
               return item.id !== replyId;
461
               return item.id !== replyId;
413
           }
465
           }
414
           return item;
466
           return item;
415
         });
467
         });
416
-        _this7.setState({ list: list });
468
+        _this8.setState({ list: list });
469
+        _this8.props.onDelete(_constant.COMMENT_TYPE.REPLY);
417
       }).catch(this.errorHandler).finally(function () {
470
       }).catch(this.errorHandler).finally(function () {
418
-        _this7.handleChangeLoading("sDeleteReply", false);
471
+        _this8.handleChangeLoading("sDeleteReply", false);
419
       });
472
       });
420
     }
473
     }
421
 
474
 
428
   }, {
481
   }, {
429
     key: "sCommentFavor",
482
     key: "sCommentFavor",
430
     value: function sCommentFavor(commentId, favored) {
483
     value: function sCommentFavor(commentId, favored) {
431
-      var _this8 = this;
484
+      var _this9 = this;
432
 
485
 
433
       this.handleChangeLoading("sCommentFavor", true);
486
       this.handleChangeLoading("sCommentFavor", true);
434
       var API = this.props.API;
487
       var API = this.props.API;
437
         method: favored ? "delete" : "put",
490
         method: favored ? "delete" : "put",
438
         withCredentials: true
491
         withCredentials: true
439
       }).then(function (response) {
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
         // 更新 list 中的该项数据的 favored
496
         // 更新 list 中的该项数据的 favored
444
-        var list = _this8.state.list.map(function (item) {
497
+        var list = _this9.state.list.map(function (item) {
445
           if (item.id === commentId) {
498
           if (item.id === commentId) {
446
             item.favored = !favored;
499
             item.favored = !favored;
447
             item.favor_count += favored ? -1 : 1;
500
             item.favor_count += favored ? -1 : 1;
448
           }
501
           }
449
           return item;
502
           return item;
450
         });
503
         });
451
-        _this8.setState({ list: list });
504
+        _this9.setState({ list: list });
452
       }).catch(this.errorHandler).finally(function () {
505
       }).catch(this.errorHandler).finally(function () {
453
-        _this8.handleChangeLoading("sCommentFavor", false);
506
+        _this9.handleChangeLoading("sCommentFavor", false);
454
       });
507
       });
455
     }
508
     }
456
 
509
 
464
   }, {
517
   }, {
465
     key: "sReplyFavor",
518
     key: "sReplyFavor",
466
     value: function sReplyFavor(replyId, commentId, favored) {
519
     value: function sReplyFavor(replyId, commentId, favored) {
467
-      var _this9 = this;
520
+      var _this10 = this;
468
 
521
 
469
       this.handleChangeLoading("sReplyFavor", true);
522
       this.handleChangeLoading("sReplyFavor", true);
470
       var API = this.props.API;
523
       var API = this.props.API;
476
         },
529
         },
477
         withCredentials: true
530
         withCredentials: true
478
       }).then(function (response) {
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
         // 更新 list 中的该项数据的 favored
533
         // 更新 list 中的该项数据的 favored
481
-        var list = _this9.state.list.map(function (item) {
534
+        var list = _this10.state.list.map(function (item) {
482
           if (item.id === commentId) {
535
           if (item.id === commentId) {
483
             item.replies = item.replies.map(function (r) {
536
             item.replies = item.replies.map(function (r) {
484
               if (r.id === replyId) {
537
               if (r.id === replyId) {
493
           }
546
           }
494
           return item;
547
           return item;
495
         });
548
         });
496
-        _this9.setState({ list: list });
549
+        _this10.setState({ list: list });
497
       }).catch(this.errorHandler).finally(function () {
550
       }).catch(this.errorHandler).finally(function () {
498
-        _this9.handleChangeLoading("sReplyFavor", false);
551
+        _this10.handleChangeLoading("sReplyFavor", false);
499
       });
552
       });
500
     }
553
     }
501
 
554
 
506
   }, {
559
   }, {
507
     key: "sOssSts",
560
     key: "sOssSts",
508
     value: function sOssSts() {
561
     value: function sOssSts() {
509
-      var _this10 = this;
562
+      var _this11 = this;
510
 
563
 
511
       this.handleChangeLoading("sOssSts", true);
564
       this.handleChangeLoading("sOssSts", true);
512
       var API = this.props.API;
565
       var API = this.props.API;
513
 
566
 
514
       this.axios.get(API + "/oss/sts").then(function (response) {
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
       }).catch(this.errorHandler).finally(function () {
569
       }).catch(this.errorHandler).finally(function () {
517
-        _this10.handleChangeLoading("sOssSts", false);
570
+        _this11.handleChangeLoading("sOssSts", false);
518
       });
571
       });
519
     }
572
     }
520
   }, {
573
   }, {
533
         sDeleteReply: this.sDeleteReply
586
         sDeleteReply: this.sDeleteReply
534
       });
587
       });
535
 
588
 
536
-      return _react2.default.createElement(
589
+      return this.state.initDone && _react2.default.createElement(
537
         _Comment.CommentContext.Provider,
590
         _Comment.CommentContext.Provider,
538
         { value: value },
591
         { value: value },
539
         _react2.default.createElement(
592
         _react2.default.createElement(
567
   userId: _propTypes2.default.number, // 用户id, comment内部不维护用户id, 调用组件时传递过来, 目前用于判断是否显示删除按钮
620
   userId: _propTypes2.default.number, // 用户id, comment内部不维护用户id, 调用组件时传递过来, 目前用于判断是否显示删除按钮
568
   pageType: _propTypes2.default.string, // 分页类型
621
   pageType: _propTypes2.default.string, // 分页类型
569
   page: _propTypes2.default.number, // 页码
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
 App.defaultProps = {
628
 App.defaultProps = {
579
   showAlertFavor: false,
634
   showAlertFavor: false,
580
   showError: true,
635
   showError: true,
581
   pageType: "more",
636
   pageType: "more",
582
-  onPageChange: function onPageChange(page) {}
637
+  onPageChange: function onPageChange(page) {},
638
+  onDelete: function onDelete() {}
583
 };
639
 };
584
 
640
 
585
 exports.Editor = _Editor2.default;
641
 exports.Editor = _Editor2.default;

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


+ 7
- 2
lib/components/CommentBox/index.js View File

20
 
20
 
21
 var _propTypes2 = _interopRequireDefault(_propTypes);
21
 var _propTypes2 = _interopRequireDefault(_propTypes);
22
 
22
 
23
+var _reactIntlUniversal = require("react-intl-universal");
24
+
25
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
26
+
23
 var _Comment = require("../../Comment");
27
 var _Comment = require("../../Comment");
24
 
28
 
25
 var _Comment2 = _interopRequireDefault(_Comment);
29
 var _Comment2 = _interopRequireDefault(_Comment);
122
                       return _this2.handleGetMoreReply(commentId);
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
                 _react2.default.createElement(
131
                 _react2.default.createElement(
128
                   "a",
132
                   "a",
131
                     onClick: _this2.handleToggleReply
135
                     onClick: _this2.handleToggleReply
132
                   },
136
                   },
133
                   _react2.default.createElement(_icon2.default, { type: "up" }),
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
File diff suppressed because it is too large
View File


+ 6
- 4
lib/components/CommentList/index.js View File

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

+ 1
- 1
lib/components/CommentList/index.js.map View File

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 View File

48
 
48
 
49
 var _relativeTime2 = _interopRequireDefault(_relativeTime);
49
 var _relativeTime2 = _interopRequireDefault(_relativeTime);
50
 
50
 
51
+var _reactIntlUniversal = require("react-intl-universal");
52
+
53
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
54
+
51
 var _Comment = require("../../Comment");
55
 var _Comment = require("../../Comment");
52
 
56
 
53
 var _Comment2 = _interopRequireDefault(_Comment);
57
 var _Comment2 = _interopRequireDefault(_Comment);
79
 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; }
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
 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; }
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
 _dayjs2.default.extend(_relativeTime2.default);
90
 _dayjs2.default.extend(_relativeTime2.default);
85
 
91
 
92
+var LOCALES = {
93
+  "zh-CN": "zh-cn"
94
+};
95
+
86
 var CommentItem = function (_Component) {
96
 var CommentItem = function (_Component) {
87
   _inherits(CommentItem, _Component);
97
   _inherits(CommentItem, _Component);
88
 
98
 
159
           showReply = _props.showReply,
169
           showReply = _props.showReply,
160
           onShowReply = _props.onShowReply,
170
           onShowReply = _props.onShowReply,
161
           app = _props.app;
171
           app = _props.app;
172
+      var locale = this.props.app.locale;
162
       var showInput = this.state.showInput;
173
       var showInput = this.state.showInput;
163
 
174
 
164
 
175
 
201
             _react2.default.createElement(
212
             _react2.default.createElement(
202
               "strong",
213
               "strong",
203
               null,
214
               null,
204
-              content.user_name || "游客"
215
+              content.user_name || _reactIntlUniversal2.default.get("comment.tourist")
205
             ),
216
             ),
206
             _react2.default.createElement(
217
             _react2.default.createElement(
207
               "span",
218
               "span",
212
                   placement: "top",
223
                   placement: "top",
213
                   title: (0, _dayjs2.default)(content.created * 1000).format("YYYY-MM-DD HH:mm:ss")
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
               _react2.default.createElement(
285
               _react2.default.createElement(
275
                 "a",
286
                 "a",
276
                 { className: "comment-item-bottom-left", onClick: onShowReply },
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
                 showReply ? _react2.default.createElement(_icon2.default, { type: "up" }) : _react2.default.createElement(_icon2.default, { type: "down" })
289
                 showReply ? _react2.default.createElement(_icon2.default, { type: "up" }) : _react2.default.createElement(_icon2.default, { type: "down" })
280
               )
290
               )
281
             ) : null,
291
             ) : null,
282
             app.userId === content.user_id && _react2.default.createElement(
292
             app.userId === content.user_id && _react2.default.createElement(
283
               _popconfirm2.default,
293
               _popconfirm2.default,
284
               {
294
               {
285
-                title: "\u786E\u5B9A\u8981\u5220\u9664\u5417?",
295
+                // title="确定要删除吗?"
296
+                title: _reactIntlUniversal2.default.get("popConfirm.title"),
286
                 onConfirm: function onConfirm() {
297
                 onConfirm: function onConfirm() {
287
                   if (replyId) {
298
                   if (replyId) {
288
                     app.sDeleteReply(content.id, commentId);
299
                     app.sDeleteReply(content.id, commentId);
290
                   }
301
                   }
291
                   app.sDeleteComment(content.id);
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
               _react2.default.createElement(
307
               _react2.default.createElement(
297
                 "a",
308
                 "a",
298
                 { className: "comment-item-bottom-right" },
309
                 { className: "comment-item-bottom-right" },
299
-                "\xA0 \u5220\u9664"
310
+                "\xA0 ",
311
+                _reactIntlUniversal2.default.get("popConfirm.delete")
300
               )
312
               )
301
             ),
313
             ),
302
             _react2.default.createElement(
314
             _react2.default.createElement(
305
                 onClick: this.handleToggleInput,
317
                 onClick: this.handleToggleInput,
306
                 className: "comment-item-bottom-right"
318
                 className: "comment-item-bottom-right"
307
               },
319
               },
308
-              "\xA0 \u56DE\u590D"
320
+              "\xA0 ",
321
+              _reactIntlUniversal2.default.get("comment.reply")
309
             ),
322
             ),
310
             _react2.default.createElement(
323
             _react2.default.createElement(
311
               "div",
324
               "div",

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


+ 5
- 1
lib/components/Editor/Upload.js View File

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

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


+ 20
- 26
lib/components/Editor/index.js View File

48
 
48
 
49
 var _classnames2 = _interopRequireDefault(_classnames);
49
 var _classnames2 = _interopRequireDefault(_classnames);
50
 
50
 
51
+var _reactIntlUniversal = require("react-intl-universal");
52
+
53
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
54
+
51
 var _constant = require("../../constant");
55
 var _constant = require("../../constant");
52
 
56
 
53
 var _helper = require("../../helper");
57
 var _helper = require("../../helper");
218
           fileList = _state.fileList;
222
           fileList = _state.fileList;
219
 
223
 
220
       if (value.length > maxLength) {
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
         return;
227
         return;
223
       }
228
       }
224
       var files = [];
229
       var files = [];
267
 
272
 
268
       var _props = this.props,
273
       var _props = this.props,
269
           value = _props.value,
274
           value = _props.value,
270
-          placeholder = _props.placeholder,
271
           rows = _props.rows,
275
           rows = _props.rows,
272
           showEmoji = _props.showEmoji,
276
           showEmoji = _props.showEmoji,
273
           showUpload = _props.showUpload,
277
           showUpload = _props.showUpload,
274
           closeUploadWhenBlur = _props.closeUploadWhenBlur,
278
           closeUploadWhenBlur = _props.closeUploadWhenBlur,
275
           maxUpload = _props.maxUpload,
279
           maxUpload = _props.maxUpload,
276
-          btnSubmitText = _props.btnSubmitText,
277
           btnLoading = _props.btnLoading,
280
           btnLoading = _props.btnLoading,
278
           btnDisabled = _props.btnDisabled,
281
           btnDisabled = _props.btnDisabled,
279
           button = _props.button,
282
           button = _props.button,
282
           maxLength = _props.maxLength,
285
           maxLength = _props.maxLength,
283
           autoFocus = _props.autoFocus;
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
       var handleSubmit = this.handleSubmit;
290
       var handleSubmit = this.handleSubmit;
286
       var disabledSubmit = btnDisabled || !this.props.value && !this.state.value && !this.state.fileList.length;
291
       var disabledSubmit = btnDisabled || !this.props.value && !this.state.value && !this.state.fileList.length;
287
       var inputValue = value || this.state.value;
292
       var inputValue = value || this.state.value;
296
               "comment-editor-toolbar-error": inputValue.length > maxLength
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
         _react2.default.createElement(
309
         _react2.default.createElement(
306
           "div",
310
           "div",
346
               showUpload ? _react2.default.createElement(
350
               showUpload ? _react2.default.createElement(
347
                 _popover2.default,
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
                   onVisibleChange: closeUploadWhenBlur ? function (visible) {
357
                   onVisibleChange: closeUploadWhenBlur ? function (visible) {
353
                     _this3.handleShowUpload(visible);
358
                     _this3.handleShowUpload(visible);
354
                   } : null,
359
                   } : null,
378
                     _react2.default.createElement(
383
                     _react2.default.createElement(
379
                       "span",
384
                       "span",
380
                       null,
385
                       null,
381
-                      "\u4E0A\u4F20\u56FE\u7247",
386
+                      _reactIntlUniversal2.default.get("editor.uploadTip"),
382
                       maxUpload >= 2 ? _react2.default.createElement(
387
                       maxUpload >= 2 ? _react2.default.createElement(
383
                         "span",
388
                         "span",
384
                         { style: { color: "#666", fontWeight: 400 } },
389
                         { style: { color: "#666", fontWeight: 400 } },
386
                         maxUpload - this.state.fileList.length,
391
                         maxUpload - this.state.fileList.length,
387
                         "\u5F20\u56FE\u7247)"
392
                         "\u5F20\u56FE\u7247)"
388
                       ) : null
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
                 imageToolIcon ? _react2.default.cloneElement(imageToolIcon, {
397
                 imageToolIcon ? _react2.default.cloneElement(imageToolIcon, {
465
 
459
 
466
 Editor.defaultProps = {
460
 Editor.defaultProps = {
467
   rows: 5,
461
   rows: 5,
468
-  placeholder: "说点什么吧...",
462
+  // placeholder: "说点什么吧",
469
   showEmoji: true,
463
   showEmoji: true,
470
   showUpload: true,
464
   showUpload: true,
471
   closeUploadWhenBlur: false,
465
   closeUploadWhenBlur: false,
472
   maxUpload: 1,
466
   maxUpload: 1,
473
-  btnSubmitText: "发表",
467
+  // btnSubmitText: "发表",
474
   btnLoading: false,
468
   btnLoading: false,
475
   btnDisabled: false,
469
   btnDisabled: false,
476
   showError: true,
470
   showError: true,

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


+ 7
- 2
lib/components/ImagePreviewer/ImagePreviewer.js View File

26
 
26
 
27
 var _classnames2 = _interopRequireDefault(_classnames);
27
 var _classnames2 = _interopRequireDefault(_classnames);
28
 
28
 
29
+var _reactIntlUniversal = require("react-intl-universal");
30
+
31
+var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);
32
+
29
 require("./ImagePreviewer.less");
33
 require("./ImagePreviewer.less");
30
 
34
 
31
 var _helper = require("../../helper");
35
 var _helper = require("../../helper");
161
             "span",
165
             "span",
162
             { className: "button", onClick: onFold },
166
             { className: "button", onClick: onFold },
163
             _react2.default.createElement(_icon2.default, { type: "to-top" }),
167
             _react2.default.createElement(_icon2.default, { type: "to-top" }),
164
-            "\u6536\u8D77"
168
+            _reactIntlUniversal2.default.get("picture.collapse")
165
           ),
169
           ),
166
           _react2.default.createElement(
170
           _react2.default.createElement(
167
             "span",
171
             "span",
168
             { className: "button", onClick: this.onOrigin },
172
             { className: "button", onClick: this.onOrigin },
169
             _react2.default.createElement(_icon2.default, { type: "search" }),
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
         _react2.default.createElement(
178
         _react2.default.createElement(

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


+ 5
- 0
lib/constant.js View File

26
 var IMAGE_PROCESS = exports.IMAGE_PROCESS = "?x-oss-process=image/resize,h_350";
26
 var IMAGE_PROCESS = exports.IMAGE_PROCESS = "?x-oss-process=image/resize,h_350";
27
 var IMAGE_PROCESS_SMALL = exports.IMAGE_PROCESS_SMALL = "?x-oss-process=image/resize,h_100";
27
 var IMAGE_PROCESS_SMALL = exports.IMAGE_PROCESS_SMALL = "?x-oss-process=image/resize,h_100";
28
 var IMAGE_PROCESS_LARGE = exports.IMAGE_PROCESS_LARGE = "?x-oss-process=image/resize,h_500";
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
 //# sourceMappingURL=constant.js.map
34
 //# sourceMappingURL=constant.js.map

+ 1
- 1
lib/constant.js.map View File

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 View File

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

+ 1
- 1
lib/index.js.map View File

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 View File

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 View File

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 View File

3
 Object.defineProperty(exports, "__esModule", {
3
 Object.defineProperty(exports, "__esModule", {
4
   value: true
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
 //# sourceMappingURL=index.js.map
44
 //# sourceMappingURL=index.js.map

+ 1
- 1
lib/lang/index.js.map View File

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 View File

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 View File

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 View File

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

+ 6
- 2
src/App.js View File

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

+ 8
- 6
src/components/Editor/index.js View File

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

+ 5
- 0
src/constant.js View File

21
 export const IMAGE_PROCESS = "?x-oss-process=image/resize,h_350";
21
 export const IMAGE_PROCESS = "?x-oss-process=image/resize,h_350";
22
 export const IMAGE_PROCESS_SMALL = "?x-oss-process=image/resize,h_100";
22
 export const IMAGE_PROCESS_SMALL = "?x-oss-process=image/resize,h_100";
23
 export const IMAGE_PROCESS_LARGE = "?x-oss-process=image/resize,h_500";
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 View File

15
  *  - {string} id 渲染评论的DOM的 ID
15
  *  - {string} id 渲染评论的DOM的 ID
16
  *  - {number} type 评论的 type
16
  *  - {number} type 评论的 type
17
  *  - {string} businessId 评论的 businessId
17
  *  - {string} businessId 评论的 businessId
18
+ *  - {string} API, API 前缀, 默认 http://api.links123.net/comment/v1
18
  */
19
  */
19
 function renderComment(config) {
20
 function renderComment(config) {
20
   if (!config.id) {
21
   if (!config.id) {
21
     throw new Error("id is required");
22
     throw new Error("id is required");
22
   }
23
   }
23
-  if (!config.id) {
24
+  if (!config.type) {
24
     throw new Error("type is required");
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
   ReactDOM.render(
45
   ReactDOM.render(
32
-    <Index type={type} businessId={businessId} />,
46
+    <Index type={type} businessId={businessId} API={API} userId={userId} />,
33
     document.getElementById(id)
47
     document.getElementById(id)
34
   );
48
   );
35
   // registerServiceWorker();
49
   // registerServiceWorker();
42
   type: 1,
56
   type: 1,
43
   businessId: "test"
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
+// });