fix: main data

This commit is contained in:
zzc
2026-06-22 18:07:44 +08:00
parent d1d4481ff5
commit d14084c2a1
3 changed files with 19 additions and 20 deletions

View File

@@ -20,7 +20,7 @@
v-for="(item, index) in topics"
:key="item.id || index"
:topic="item"
@card-click="goToTopicDetail(item.id)"
@item-click="goToTopicDetail(item.id)"
/>
</view>
@@ -83,15 +83,15 @@ const loadData = async (page = 1) => {
}
// 构造适合 TopicCard 渲染的数据格式
const formattedList = list.map(item => ({
id: item.topicId || item.id,
title: item.topicName || item.title || '未知话题',
image: item.image || item.coverUrl || 'https://api.dicebear.com/7.x/shapes/svg?seed=' + (item.topicId || item.id), // 给个默认图防止报错
views: item.participantCount || item.views || 0,
items: item.items || item.ratingItems || []
}));
// const formattedList = list.map(item => ({
// id: item.topicId || item.id,
// title: item.topicName || item.title || '未知话题',
// image: item.image || item.coverUrl || 'https://api.dicebear.com/7.x/shapes/svg?seed=' + (item.topicId || item.id), // 给个默认图防止报错
// views: item.participantCount || item.views || 0,
// items: item.items || item.ratingItems || []
// }));
topics.value = [...topics.value, ...formattedList];
topics.value = [...topics.value, ...list];
// 判断是否有下一页
hasMore.value = list.length >= pageSize;