fix: rating
This commit is contained in:
@@ -86,7 +86,7 @@
|
||||
<text class="filter-icon"></text>
|
||||
</view>
|
||||
|
||||
<view class="comment-list">
|
||||
<view class="comment-list" style="min-height: 400rpx;">
|
||||
<CommentItem
|
||||
v-for="(comment, index) in comments"
|
||||
:key="comment.id"
|
||||
@@ -211,11 +211,11 @@ const switchTab = (tab) => {
|
||||
currentTab.value = tab;
|
||||
currentPage.value = 1;
|
||||
hasMore.value = true;
|
||||
comments.value = [];
|
||||
getCommentsData();
|
||||
// comments.value = []; // 移除这行,避免数据清空导致高度塌陷
|
||||
getCommentsData(true); // 传入标识表示是切换榜单
|
||||
};
|
||||
|
||||
const getCommentsData = async () => {
|
||||
const getCommentsData = async (isSwitchTab = false) => {
|
||||
if (!detailData.value.topicId || !itemId.value || loading.value) return;
|
||||
|
||||
try {
|
||||
@@ -227,7 +227,7 @@ const getCommentsData = async () => {
|
||||
const formattedList = list.map(item => ({
|
||||
id: item.id,
|
||||
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) || '刚刚', // 如果后端返回了时间字段可以替换
|
||||
content: item.content,
|
||||
likes: item.likeCount || 0,
|
||||
@@ -237,7 +237,7 @@ const getCommentsData = async () => {
|
||||
userAction: item.userAction || "" // 夯/顶级/人上人/NPC/拉
|
||||
}));
|
||||
|
||||
if (currentPage.value === 1) {
|
||||
if (currentPage.value === 1 || isSwitchTab) {
|
||||
comments.value = formattedList;
|
||||
} else {
|
||||
comments.value = [...comments.value, ...formattedList];
|
||||
|
||||
Reference in New Issue
Block a user