feat: update api
This commit is contained in:
parent
cd6a657d40
commit
3f542eb5bb
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
@ -25,6 +25,7 @@
|
|||
"signin",
|
||||
"sina",
|
||||
"tencent",
|
||||
"upid",
|
||||
"Upvotes",
|
||||
"VARCHAR",
|
||||
"VNDB",
|
||||
|
|
7
src/api/update-log/index.ts
Normal file
7
src/api/update-log/index.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { fetchGet } from '@/utils/request'
|
||||
|
||||
import { KUNGalgameUpdateLog } from './types/updateLog'
|
||||
|
||||
export async function getUpdateLogApi(): Promise<KUNGalgameUpdateLog[]> {
|
||||
return await fetchGet<KUNGalgameUpdateLog[]>(`/update/logs`)
|
||||
}
|
11
src/api/update-log/types/updateLog.ts
Normal file
11
src/api/update-log/types/updateLog.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
// 更新日志的数据接口
|
||||
export interface KUNGalgameUpdateLog {
|
||||
// 更新描述
|
||||
description: string
|
||||
// 更新发布时间
|
||||
time: string
|
||||
// 更新排序 ID
|
||||
upid: number
|
||||
// 更新版本
|
||||
version: String
|
||||
}
|
|
@ -3,7 +3,7 @@ import SingleTopic from './components/SingleTopic.vue'
|
|||
import Pagination from './components/Pagination.vue'
|
||||
import Aside from './components/Aside.vue'
|
||||
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ref, onBeforeMount } from 'vue'
|
||||
import { getTopicRangeApi } from '@/api/topic/index'
|
||||
import { KUNGalgameTopic } from '@/api/topic/types/topic'
|
||||
|
||||
|
@ -11,15 +11,13 @@ import { KUNGalgameTopic } from '@/api/topic/types/topic'
|
|||
const topics = ref<KUNGalgameTopic[]>([])
|
||||
|
||||
// 在组件挂载时调用 fetchTopics 获取帖子数据
|
||||
onMounted(async () => {
|
||||
onBeforeMount(async () => {
|
||||
try {
|
||||
const start = 0 // 起始位置
|
||||
const count = 17 // 获取的帖子数量
|
||||
|
||||
// TODO: 这里接口获取到的数据太多了,其实获取 title,like,view,comment,text 这几个字段就足够了
|
||||
const fetchedTopics = await getTopicRangeApi(start, count)
|
||||
|
||||
topics.value = fetchedTopics
|
||||
topics.value = await getTopicRangeApi(start, count)
|
||||
} catch (error) {
|
||||
console.error('Error fetching topics:', error)
|
||||
}
|
||||
|
|
|
@ -1,13 +1,30 @@
|
|||
<script setup lang="ts">
|
||||
import { historyVersion } from '@/types/update-log/history'
|
||||
import { getUpdateLogApi } from '@/api/update-log/index'
|
||||
import { KUNGalgameUpdateLog } from '@/api/update-log/types/updateLog'
|
||||
import { ref, onBeforeMount } from 'vue'
|
||||
|
||||
// 在组件中定义响应式的帖子数据
|
||||
const topics = ref<KUNGalgameUpdateLog[]>([])
|
||||
|
||||
// 在组件挂载时调用 fetchTopics 获取帖子数据
|
||||
onBeforeMount(async () => {
|
||||
try {
|
||||
topics.value = await getUpdateLogApi()
|
||||
} catch (error) {
|
||||
console.log('Error fetching updateLogs:', error)
|
||||
}
|
||||
})
|
||||
|
||||
console.log(topics)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 单个项目 -->
|
||||
<li v-for="kun in historyVersion" :key="kun.index">
|
||||
<li v-for="kun in topics" :key="kun.upid">
|
||||
<!-- 更新内容 -->
|
||||
<div v-for="yuyu in kun.describe" :key="yuyu.index">
|
||||
<p>{{ yuyu.text }}</p>
|
||||
<!-- <div v-for="yuyu in kun.describe" :key="yuyu.index"> -->
|
||||
<div>
|
||||
<p>{{ kun.description }}</p>
|
||||
</div>
|
||||
<!-- 更新时间和版本 -->
|
||||
<div class="time">
|
||||
|
|
Loading…
Reference in a new issue