Skip to content

Commit fe26ad0

Browse files
评论列表中的图片支持点击查看大图
1 parent 6db7995 commit fe26ad0

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

site/src/components/comment/List.vue

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
usePrettyDate(comment.createTime)
2424
}}</time>
2525
<span v-if="comment.ipLocation" class="comment-ip-area"
26-
>{{ t('component.comment.list.ipLocation') }}{{ comment.ipLocation }}</span
26+
>{{ t("component.comment.list.ipLocation")
27+
}}{{ comment.ipLocation }}</span
2728
>
2829
</div>
2930
</div>
@@ -44,10 +45,14 @@
4445
v-if="comment.imageList && comment.imageList.length"
4546
class="comment-image-list"
4647
>
47-
<img
48+
<el-image
4849
v-for="(image, imageIndex) in comment.imageList"
4950
:key="imageIndex"
5051
:src="image.url"
52+
:preview-src-list="comment.imageList.map((image) => image.url)"
53+
:initial-index="imageIndex"
54+
fit="cover"
55+
style="width: 82px; height: 82px"
5156
/>
5257
</div>
5358
</div>
@@ -58,7 +63,11 @@
5863
@click="like(comment)"
5964
>
6065
<i class="iconfont icon-like" />
61-
<span>{{ comment.liked ? t('component.comment.list.liked') : t('component.comment.list.like') }}</span>
66+
<span>{{
67+
comment.liked
68+
? t("component.comment.list.liked")
69+
: t("component.comment.list.like")
70+
}}</span>
6271
<span v-if="comment.likeCount > 0">{{ comment.likeCount }}</span>
6372
</div>
6473
<div
@@ -67,7 +76,11 @@
6776
@click="switchShowReply(comment)"
6877
>
6978
<i class="iconfont icon-comment" />
70-
<span>{{ reply.commentId === comment.id ? t('component.comment.list.cancelReply') : t('component.comment.list.reply') }}</span>
79+
<span>{{
80+
reply.commentId === comment.id
81+
? t("component.comment.list.cancelReply")
82+
: t("component.comment.list.reply")
83+
}}</span>
7184
</div>
7285
</div>
7386
<div v-if="reply.commentId === comment.id" class="comment-reply-form">
@@ -208,7 +221,7 @@ const submitReply = async (parent) => {
208221
);
209222
hideReply();
210223
appendReply(parent, ret);
211-
useMsgSuccess(t('component.comment.list.publishSuccess'));
224+
useMsgSuccess(t("component.comment.list.publishSuccess"));
212225
} catch (e) {
213226
useCatchError(e);
214227
}
@@ -283,24 +296,9 @@ defineExpose({
283296
}
284297
.comment-image-list {
285298
margin-top: 10px;
286-
287-
img {
288-
width: 72px;
289-
height: 72px;
290-
line-height: 72px;
291-
cursor: pointer;
292-
&:not(:last-child) {
293-
margin-right: 8px;
294-
}
295-
296-
object-fit: cover;
297-
transition: all 0.5s ease-out 0.1s;
298-
299-
&:hover {
300-
transform: matrix(1.04, 0, 0, 1.04, 0, 0);
301-
backface-visibility: hidden;
302-
}
303-
}
299+
display: flex;
300+
flex-wrap: wrap;
301+
gap: 8px;
304302
}
305303
}
306304
@@ -340,7 +338,6 @@ defineExpose({
340338
341339
.comment-replies {
342340
margin-top: 10px;
343-
// padding: 10px;
344341
background-color: var(--bg-color2);
345342
}
346343
}

0 commit comments

Comments
 (0)