fix: rating

This commit is contained in:
zzc
2026-05-26 10:48:05 +08:00
parent 6d42ebb513
commit f295b53f72

View File

@@ -86,7 +86,7 @@
<text class="filter-icon"></text> <text class="filter-icon"></text>
</view> </view>
<view class="comment-list"> <view class="comment-list" style="min-height: 400rpx;">
<CommentItem <CommentItem
v-for="(comment, index) in comments" v-for="(comment, index) in comments"
:key="comment.id" :key="comment.id"
@@ -211,11 +211,11 @@ const switchTab = (tab) => {
currentTab.value = tab; currentTab.value = tab;
currentPage.value = 1; currentPage.value = 1;
hasMore.value = true; hasMore.value = true;
comments.value = []; // comments.value = []; // 移除这行,避免数据清空导致高度塌陷
getCommentsData(); getCommentsData(true); // 传入标识表示是切换榜单
}; };
const getCommentsData = async () => { const getCommentsData = async (isSwitchTab = false) => {
if (!detailData.value.topicId || !itemId.value || loading.value) return; if (!detailData.value.topicId || !itemId.value || loading.value) return;
try { try {
@@ -227,7 +227,7 @@ const getCommentsData = async () => {
const formattedList = list.map(item => ({ const formattedList = list.map(item => ({
id: item.id, id: item.id,
name: item.user?.nickname || '匿名用户', name: item.user?.nickname || '匿名用户',
avatar: item.user?.avatar ? item.user.avatar : 'https://api.dicebear.com/7.x/avataaars/svg?seed=fallback', avatar: item.user?.avatar ? `${FILE_BASE_URL}${item.user.avatar}` : 'https://api.dicebear.com/7.x/avataaars/svg?seed=fallback',
time: formatDate(item.createdAt) || '刚刚', // 如果后端返回了时间字段可以替换 time: formatDate(item.createdAt) || '刚刚', // 如果后端返回了时间字段可以替换
content: item.content, content: item.content,
likes: item.likeCount || 0, likes: item.likeCount || 0,
@@ -237,7 +237,7 @@ const getCommentsData = async () => {
userAction: item.userAction || "" // 夯/顶级/人上人/NPC/拉 userAction: item.userAction || "" // 夯/顶级/人上人/NPC/拉
})); }));
if (currentPage.value === 1) { if (currentPage.value === 1 || isSwitchTab) {
comments.value = formattedList; comments.value = formattedList;
} else { } else {
comments.value = [...comments.value, ...formattedList]; comments.value = [...comments.value, ...formattedList];