|
|
@@ -275,14 +275,15 @@ onMounted(async () => {
|
|
|
|
|
|
// 获取模板列表
|
|
|
await templateStore.fetchTemplates()
|
|
|
- // 取前3个模板作为推荐
|
|
|
- recommendTemplates.value = templateStore.templates.slice(0, 3).map((t, i) => ({
|
|
|
+ // 取前3个模板作为推荐(按使用次数排序)
|
|
|
+ const sortedTemplates = [...templateStore.templates].sort((a, b) => (b.useCount || 0) - (a.useCount || 0))
|
|
|
+ recommendTemplates.value = sortedTemplates.slice(0, 3).map((t, i) => ({
|
|
|
...t,
|
|
|
icon: templateIcons[i % templateIcons.length],
|
|
|
- useCount: t.useCount || Math.floor(Math.random() * 200),
|
|
|
- rating: 4.5 + Math.random() * 0.5,
|
|
|
+ useCount: t.useCount || 0,
|
|
|
+ rating: t.rating || 0,
|
|
|
isOfficial: t.isPublic,
|
|
|
- isHot: i < 2
|
|
|
+ isHot: (t.useCount || 0) >= 100 // 使用次数>=100标记为热门
|
|
|
}))
|
|
|
} catch (error) {
|
|
|
console.error('获取数据失败:', error)
|