|
|
@@ -3,7 +3,9 @@ import PropTypes from "prop-types";
|
|
3
|
3
|
import { Avatar, Icon, Tooltip, Popconfirm } from "antd";
|
|
4
|
4
|
import dayjs from "dayjs";
|
|
5
|
5
|
import "dayjs/locale/zh-cn";
|
|
|
6
|
+// import 'dayjs/locale/es';
|
|
6
|
7
|
import relativeTime from "dayjs/plugin/relativeTime";
|
|
|
8
|
+import intl from "react-intl-universal";
|
|
7
|
9
|
import Comment from "../../Comment";
|
|
8
|
10
|
import CommentInput from "../CommentInput";
|
|
9
|
11
|
import avatar from "../../avatar";
|
|
|
@@ -12,7 +14,7 @@ import { IMAGE_SPLIT } from "../../constant";
|
|
12
|
14
|
import "./index.css";
|
|
13
|
15
|
import ImagePreviewer from "../ImagePreviewer/ImagePreviewer";
|
|
14
|
16
|
|
|
15
|
|
-dayjs.locale("zh-cn");
|
|
|
17
|
+// dayjs.locale("zh-cn");
|
|
16
|
18
|
dayjs.extend(relativeTime);
|
|
17
|
19
|
|
|
18
|
20
|
class CommentItem extends Component {
|
|
|
@@ -115,7 +117,7 @@ class CommentItem extends Component {
|
|
115
|
117
|
{/* <a href={`/${content.user_id}`}>
|
|
116
|
118
|
{content.user_name || "暂无昵称"}
|
|
117
|
119
|
</a> */}
|
|
118
|
|
- <strong>{content.user_name || "游客"}</strong>
|
|
|
120
|
+ <strong>{content.user_name || intl.get("comment.tourist")}</strong>
|
|
119
|
121
|
<span style={{ marginLeft: 10 }}>
|
|
120
|
122
|
<Tooltip
|
|
121
|
123
|
placement="top"
|
|
|
@@ -124,6 +126,7 @@ class CommentItem extends Component {
|
|
124
|
126
|
)}
|
|
125
|
127
|
>
|
|
126
|
128
|
{dayjs(content.created * 1000).fromNow()}
|
|
|
129
|
+ {/* {dayjs(content.created * 1000).locale('zh-cn').fromNow()} */}
|
|
127
|
130
|
</Tooltip>
|
|
128
|
131
|
</span>
|
|
129
|
132
|
</div>
|
|
|
@@ -136,66 +139,67 @@ class CommentItem extends Component {
|
|
136
|
139
|
}}
|
|
137
|
140
|
/>
|
|
138
|
141
|
{// image为空时不渲染comment-item-image
|
|
139
|
|
- imageList.length > 0 &&
|
|
140
|
|
- imageList[0] !== "" && (
|
|
141
|
|
- <div className="comment-item-image">
|
|
142
|
|
- {!this.state.showPreviewer &&
|
|
143
|
|
- imgs.map((item, index) => {
|
|
144
|
|
- if (item.type === "divider") {
|
|
145
|
|
- return (
|
|
146
|
|
- <div className="comment-item-image-wrapper" key={index}>
|
|
147
|
|
- <div className="comment-img-divider" />
|
|
148
|
|
- {/* <img src={item} alt={item} className="comment-img" /> */}
|
|
149
|
|
- </div>
|
|
150
|
|
- );
|
|
151
|
|
- }
|
|
|
142
|
+ imageList.length > 0 && imageList[0] !== "" && (
|
|
|
143
|
+ <div className="comment-item-image">
|
|
|
144
|
+ {!this.state.showPreviewer &&
|
|
|
145
|
+ imgs.map((item, index) => {
|
|
|
146
|
+ if (item.type === "divider") {
|
|
152
|
147
|
return (
|
|
153
|
|
- <div
|
|
154
|
|
- className="comment-item-image-wrapper"
|
|
155
|
|
- key={index}
|
|
156
|
|
- onClick={() => {
|
|
157
|
|
- let i = index;
|
|
158
|
|
- if (needClear) {
|
|
159
|
|
- if (index > 3) {
|
|
160
|
|
- i -= 1;
|
|
161
|
|
- }
|
|
162
|
|
- if (index > 7) {
|
|
163
|
|
- i -= 1;
|
|
164
|
|
- }
|
|
165
|
|
- }
|
|
166
|
|
- this.showPreviewer(i);
|
|
167
|
|
- }}
|
|
168
|
|
- >
|
|
169
|
|
- <div
|
|
170
|
|
- style={{ backgroundImage: `url(${item})` }}
|
|
171
|
|
- className="comment-img-thumbnail"
|
|
172
|
|
- />
|
|
|
148
|
+ <div className="comment-item-image-wrapper" key={index}>
|
|
|
149
|
+ <div className="comment-img-divider" />
|
|
173
|
150
|
{/* <img src={item} alt={item} className="comment-img" /> */}
|
|
174
|
151
|
</div>
|
|
175
|
152
|
);
|
|
176
|
|
- })}
|
|
177
|
|
- {this.state.showPreviewer && (
|
|
178
|
|
- <ImagePreviewer
|
|
179
|
|
- list={imageList}
|
|
180
|
|
- index={this.state.previewerIndex}
|
|
181
|
|
- onFold={this.hidePreviewer}
|
|
182
|
|
- />
|
|
183
|
|
- )}
|
|
184
|
|
- <div className="clearfix" />
|
|
185
|
|
- </div>
|
|
186
|
|
- )}
|
|
|
153
|
+ }
|
|
|
154
|
+ return (
|
|
|
155
|
+ <div
|
|
|
156
|
+ className="comment-item-image-wrapper"
|
|
|
157
|
+ key={index}
|
|
|
158
|
+ onClick={() => {
|
|
|
159
|
+ let i = index;
|
|
|
160
|
+ if (needClear) {
|
|
|
161
|
+ if (index > 3) {
|
|
|
162
|
+ i -= 1;
|
|
|
163
|
+ }
|
|
|
164
|
+ if (index > 7) {
|
|
|
165
|
+ i -= 1;
|
|
|
166
|
+ }
|
|
|
167
|
+ }
|
|
|
168
|
+ this.showPreviewer(i);
|
|
|
169
|
+ }}
|
|
|
170
|
+ >
|
|
|
171
|
+ <div
|
|
|
172
|
+ style={{ backgroundImage: `url(${item})` }}
|
|
|
173
|
+ className="comment-img-thumbnail"
|
|
|
174
|
+ />
|
|
|
175
|
+ {/* <img src={item} alt={item} className="comment-img" /> */}
|
|
|
176
|
+ </div>
|
|
|
177
|
+ );
|
|
|
178
|
+ })}
|
|
|
179
|
+ {this.state.showPreviewer && (
|
|
|
180
|
+ <ImagePreviewer
|
|
|
181
|
+ list={imageList}
|
|
|
182
|
+ index={this.state.previewerIndex}
|
|
|
183
|
+ onFold={this.hidePreviewer}
|
|
|
184
|
+ />
|
|
|
185
|
+ )}
|
|
|
186
|
+ <div className="clearfix" />
|
|
|
187
|
+ </div>
|
|
|
188
|
+ )}
|
|
187
|
189
|
<div className="comment-item-bottom">
|
|
188
|
190
|
{content.reply_count ? (
|
|
189
|
191
|
<div>
|
|
190
|
192
|
<a className="comment-item-bottom-left" onClick={onShowReply}>
|
|
191
|
|
- {content.reply_count} 条回复
|
|
|
193
|
+ {/* {content.reply_count} 条回复 */}
|
|
|
194
|
+ {intl.get("reply.totalReply", { total: content.reply_count })}
|
|
192
|
195
|
{showReply ? <Icon type="up" /> : <Icon type="down" />}
|
|
193
|
196
|
</a>
|
|
194
|
197
|
</div>
|
|
195
|
198
|
) : null}
|
|
196
|
199
|
{app.userId === content.user_id && (
|
|
197
|
200
|
<Popconfirm
|
|
198
|
|
- title="确定要删除吗?"
|
|
|
201
|
+ // title="确定要删除吗?"
|
|
|
202
|
+ title={intl.get("popConfirm.title")}
|
|
199
|
203
|
onConfirm={() => {
|
|
200
|
204
|
if (replyId) {
|
|
201
|
205
|
app.sDeleteReply(content.id, commentId);
|
|
|
@@ -203,17 +207,19 @@ class CommentItem extends Component {
|
|
203
|
207
|
}
|
|
204
|
208
|
app.sDeleteComment(content.id);
|
|
205
|
209
|
}}
|
|
206
|
|
- okText="确定"
|
|
207
|
|
- cancelText="取消"
|
|
|
210
|
+ okText={intl.get("popConfirm.ok")}
|
|
|
211
|
+ cancelText={intl.get("popConfirm.cancel")}
|
|
208
|
212
|
>
|
|
209
|
|
- <a className="comment-item-bottom-right"> 删除</a>
|
|
|
213
|
+ <a className="comment-item-bottom-right">
|
|
|
214
|
+ {intl.get("popConfirm.delete")}
|
|
|
215
|
+ </a>
|
|
210
|
216
|
</Popconfirm>
|
|
211
|
217
|
)}
|
|
212
|
218
|
<a
|
|
213
|
219
|
onClick={this.handleToggleInput}
|
|
214
|
220
|
className="comment-item-bottom-right"
|
|
215
|
221
|
>
|
|
216
|
|
- 回复
|
|
|
222
|
+ {intl.get("comment.reply")}
|
|
217
|
223
|
</a>
|
|
218
|
224
|
<div
|
|
219
|
225
|
className="comment-item-bottom-right"
|