Browse Source

页面新增每周EPIC免费游戏

hsj 1 tháng trước cách đây
mục cha
commit
bb4e0b9c1d
1 tập tin đã thay đổi với 25 bổ sung1 xóa
  1. 25 1
      pages/index.vue

+ 25 - 1
pages/index.vue

@@ -19,7 +19,31 @@
 </template>
 
 <script setup>
-const { data: articles } = await useFetch('/api/articles')
+// 获取原有文章数据
+const { data: originalArticles } = await useFetch('/api/articles')
+
+// 调用 Epic 免费游戏 API
+const { data: epicData } = await useFetch('https://uapis.cn/api/v1/game/epic-free')
+
+// 将 Epic 游戏数据转换为文章格式
+const epicArticles = computed(() => {
+  if (!epicData.value || !epicData.value.data) return []
+  return epicData.value.data
+    .filter(game => !game.title.includes('神秘游戏'))
+    .map(game => ({
+      id: game.id,
+      title: game.title,
+      briefContent: `${game.free_start}到${game.free_end}的EPIC免费游戏为${game.title}`,
+      coverImage: game.cover
+    }))
+})
+
+// 合并文章数据
+const articles = computed(() => {
+  const original = originalArticles.value || []
+  const epic = epicArticles.value || []
+  return [...epic, ...original]
+})
 </script>
 
 <style lang="stylus">