|
@@ -75,6 +75,7 @@ class CommentItem extends Component {
|
75
|
75
|
action,
|
76
|
76
|
showReply,
|
77
|
77
|
onShowReply,
|
|
78
|
+ isMobile,
|
78
|
79
|
app
|
79
|
80
|
} = this.props;
|
80
|
81
|
|
|
@@ -105,39 +106,26 @@ class CommentItem extends Component {
|
105
|
106
|
}
|
106
|
107
|
}
|
107
|
108
|
|
108
|
|
- return (
|
109
|
|
- <div className="comment-item-box">
|
110
|
|
- <div className="comment-item-left">
|
111
|
|
- <Avatar src={content.user_avatar || avatar} size="large" />
|
112
|
|
- </div>
|
113
|
|
- <div className="comment-item-right">
|
114
|
|
- <div>
|
115
|
|
- {/* <a href={`/${content.user_id}`}>
|
116
|
|
- {content.user_name || "暂无昵称"}
|
117
|
|
- </a> */}
|
118
|
|
- <strong>{content.user_name || "游客"}</strong>
|
119
|
|
- <span style={{ marginLeft: 10 }}>
|
120
|
|
- <Tooltip
|
121
|
|
- placement="top"
|
122
|
|
- title={dayjs(content.created * 1000).format(
|
123
|
|
- "YYYY-MM-DD HH:mm:ss"
|
124
|
|
- )}
|
125
|
|
- >
|
126
|
|
- {dayjs(content.created * 1000).fromNow()}
|
127
|
|
- </Tooltip>
|
128
|
|
- </span>
|
|
109
|
+ if (isMobile) {
|
|
110
|
+ return (
|
|
111
|
+ <div className="comment-item-box">
|
|
112
|
+ <div className="comment-item-left">
|
|
113
|
+ <Avatar src={content.user_avatar || avatar} size="large" />
|
129
|
114
|
</div>
|
130
|
|
- <div
|
131
|
|
- className="comment-item-content"
|
132
|
|
- dangerouslySetInnerHTML={{
|
133
|
|
- __html: renderContent(
|
134
|
|
- this.renderTextWithReply(newContent, content)
|
135
|
|
- )
|
136
|
|
- }}
|
137
|
|
- />
|
138
|
|
- {// image为空时不渲染comment-item-image
|
139
|
|
- imageList.length > 0 &&
|
140
|
|
- imageList[0] !== "" && (
|
|
115
|
+ <div className="comment-item-middle">
|
|
116
|
+ <div>
|
|
117
|
+ <strong>{content.user_name || "游客"}</strong>
|
|
118
|
+ </div>
|
|
119
|
+ <div
|
|
120
|
+ className="comment-item-content"
|
|
121
|
+ dangerouslySetInnerHTML={{
|
|
122
|
+ __html: renderContent(
|
|
123
|
+ this.renderTextWithReply(newContent, content)
|
|
124
|
+ )
|
|
125
|
+ }}
|
|
126
|
+ />
|
|
127
|
+ {// image为空时不渲染comment-item-image
|
|
128
|
+ imageList.length > 0 && imageList[0] !== "" && (
|
141
|
129
|
<div className="comment-item-image">
|
142
|
130
|
{!this.state.showPreviewer &&
|
143
|
131
|
imgs.map((item, index) => {
|
|
@@ -184,6 +172,160 @@ class CommentItem extends Component {
|
184
|
172
|
<div className="clearfix" />
|
185
|
173
|
</div>
|
186
|
174
|
)}
|
|
175
|
+ <div>
|
|
176
|
+ <Tooltip
|
|
177
|
+ placement="top"
|
|
178
|
+ title={dayjs(content.created * 1000).format(
|
|
179
|
+ "YYYY-MM-DD HH:mm:ss"
|
|
180
|
+ )}
|
|
181
|
+ >
|
|
182
|
+ {dayjs(content.created * 1000).fromNow()}
|
|
183
|
+ </Tooltip>
|
|
184
|
+ </div>
|
|
185
|
+ <div className="comment-item-bottom">
|
|
186
|
+ {content.reply_count ? (
|
|
187
|
+ <div>
|
|
188
|
+ <a className="comment-item-bottom-left" onClick={onShowReply}>
|
|
189
|
+ {content.reply_count} 条回复
|
|
190
|
+ {showReply ? <Icon type="up" /> : <Icon type="down" />}
|
|
191
|
+ </a>
|
|
192
|
+ </div>
|
|
193
|
+ ) : null}
|
|
194
|
+ {app.userId === content.user_id && (
|
|
195
|
+ <Popconfirm
|
|
196
|
+ title="确定要删除吗?"
|
|
197
|
+ onConfirm={() => {
|
|
198
|
+ if (replyId) {
|
|
199
|
+ app.sDeleteReply(content.id, commentId);
|
|
200
|
+ return;
|
|
201
|
+ }
|
|
202
|
+ app.sDeleteComment(content.id);
|
|
203
|
+ }}
|
|
204
|
+ okText="确定"
|
|
205
|
+ cancelText="取消"
|
|
206
|
+ >
|
|
207
|
+ <a className="comment-item-bottom-right"> 删除</a>
|
|
208
|
+ </Popconfirm>
|
|
209
|
+ )}
|
|
210
|
+ </div>
|
|
211
|
+ </div>
|
|
212
|
+
|
|
213
|
+ <div className="comment-item-right">
|
|
214
|
+ <div
|
|
215
|
+ className="comment-item-top-right"
|
|
216
|
+ onClick={() => {
|
|
217
|
+ if (replyId) {
|
|
218
|
+ // 如果有 replyId,则说明是评论的回复
|
|
219
|
+ app.sReplyFavor(content.id, commentId, content.favored);
|
|
220
|
+ return;
|
|
221
|
+ }
|
|
222
|
+ app.sCommentFavor(content.id, content.favored);
|
|
223
|
+ }}
|
|
224
|
+ >
|
|
225
|
+ <div className="text-center">
|
|
226
|
+ <Icon
|
|
227
|
+ type="heart"
|
|
228
|
+ className={
|
|
229
|
+ content.favored
|
|
230
|
+ ? "comment-favor comment-favored"
|
|
231
|
+ : "comment-favor"
|
|
232
|
+ }
|
|
233
|
+ />
|
|
234
|
+ </div>
|
|
235
|
+ <div className="text-center">{content.favor_count}</div>
|
|
236
|
+ </div>
|
|
237
|
+ </div>
|
|
238
|
+ {showInput && (
|
|
239
|
+ <CommentInput
|
|
240
|
+ content={app.children}
|
|
241
|
+ action={action}
|
|
242
|
+ replyId={replyId}
|
|
243
|
+ commentId={commentId}
|
|
244
|
+ callback={this.handleToggleInput}
|
|
245
|
+ />
|
|
246
|
+ )}
|
|
247
|
+ </div>
|
|
248
|
+ );
|
|
249
|
+ }
|
|
250
|
+
|
|
251
|
+ return (
|
|
252
|
+ <div className="comment-item-box">
|
|
253
|
+ <div className="comment-item-left">
|
|
254
|
+ <Avatar src={content.user_avatar || avatar} size="large" />
|
|
255
|
+ </div>
|
|
256
|
+ <div className="comment-item-right">
|
|
257
|
+ <div>
|
|
258
|
+ {/* <a href={`/${content.user_id}`}>
|
|
259
|
+ {content.user_name || "暂无昵称"}
|
|
260
|
+ </a> */}
|
|
261
|
+ <strong>{content.user_name || "游客"}</strong>
|
|
262
|
+ <span style={{ marginLeft: 10 }}>
|
|
263
|
+ <Tooltip
|
|
264
|
+ placement="top"
|
|
265
|
+ title={dayjs(content.created * 1000).format(
|
|
266
|
+ "YYYY-MM-DD HH:mm:ss"
|
|
267
|
+ )}
|
|
268
|
+ >
|
|
269
|
+ {dayjs(content.created * 1000).fromNow()}
|
|
270
|
+ </Tooltip>
|
|
271
|
+ </span>
|
|
272
|
+ </div>
|
|
273
|
+ <div
|
|
274
|
+ className="comment-item-content"
|
|
275
|
+ dangerouslySetInnerHTML={{
|
|
276
|
+ __html: renderContent(
|
|
277
|
+ this.renderTextWithReply(newContent, content)
|
|
278
|
+ )
|
|
279
|
+ }}
|
|
280
|
+ />
|
|
281
|
+ {// image为空时不渲染comment-item-image
|
|
282
|
+ imageList.length > 0 && imageList[0] !== "" && (
|
|
283
|
+ <div className="comment-item-image">
|
|
284
|
+ {!this.state.showPreviewer &&
|
|
285
|
+ imgs.map((item, index) => {
|
|
286
|
+ if (item.type === "divider") {
|
|
287
|
+ return (
|
|
288
|
+ <div className="comment-item-image-wrapper" key={index}>
|
|
289
|
+ <div className="comment-img-divider" />
|
|
290
|
+ {/* <img src={item} alt={item} className="comment-img" /> */}
|
|
291
|
+ </div>
|
|
292
|
+ );
|
|
293
|
+ }
|
|
294
|
+ return (
|
|
295
|
+ <div
|
|
296
|
+ className="comment-item-image-wrapper"
|
|
297
|
+ key={index}
|
|
298
|
+ onClick={() => {
|
|
299
|
+ let i = index;
|
|
300
|
+ if (needClear) {
|
|
301
|
+ if (index > 3) {
|
|
302
|
+ i -= 1;
|
|
303
|
+ }
|
|
304
|
+ if (index > 7) {
|
|
305
|
+ i -= 1;
|
|
306
|
+ }
|
|
307
|
+ }
|
|
308
|
+ this.showPreviewer(i);
|
|
309
|
+ }}
|
|
310
|
+ >
|
|
311
|
+ <div
|
|
312
|
+ style={{ backgroundImage: `url(${item})` }}
|
|
313
|
+ className="comment-img-thumbnail"
|
|
314
|
+ />
|
|
315
|
+ {/* <img src={item} alt={item} className="comment-img" /> */}
|
|
316
|
+ </div>
|
|
317
|
+ );
|
|
318
|
+ })}
|
|
319
|
+ {this.state.showPreviewer && (
|
|
320
|
+ <ImagePreviewer
|
|
321
|
+ list={imageList}
|
|
322
|
+ index={this.state.previewerIndex}
|
|
323
|
+ onFold={this.hidePreviewer}
|
|
324
|
+ />
|
|
325
|
+ )}
|
|
326
|
+ <div className="clearfix" />
|
|
327
|
+ </div>
|
|
328
|
+ )}
|
187
|
329
|
<div className="comment-item-bottom">
|
188
|
330
|
{content.reply_count ? (
|
189
|
331
|
<div>
|