This commit is contained in:
qiuyuan 2025-08-08 19:00:22 +08:00
parent 01ca2c7e01
commit b75b710702

View File

@ -33,7 +33,8 @@
:class="{'is-reply': comment.toUserName}">
<view class="comment-header">
<image class="avatar"
:src="comment.pusherPortrait === '/static/imgs/index/nav.png' ? comment.pusherPortrait : `${IMAGE_BASE_URL}${comment.pusherPortrait}`" mode="aspectFill"></image>
:src="getAvatarSrc(comment.pusherPortrait)"
mode="aspectFill"></image>
<view class="comment-user-info">
<text class="username">{{ comment.pusherName }}</text>
<view class="meta-info">
@ -114,8 +115,27 @@
this.error = '缺少内容ID';
this.loading = false;
}
},
computed: {
},
methods: {
getAvatarSrc(portrait) {
const defaultAvatar = '/static/imgs/index/nav.png';
if (!portrait) {
return defaultAvatar;
}
const defaultUrls = ['/static/imgs/index/nav.png', 'https://jinshan.nantong.info'];
if (defaultUrls.includes(portrait) || portrait.startsWith('http')) {
return portrait;
}
return `${this.IMAGE_BASE_URL}${portrait}`;
},
//
updateFlatComments() {
const flattenComments = (comments, parentUser = '') => {