feat: update api

This commit is contained in:
KUN1007 2023-08-02 18:42:49 +08:00
parent cd6a657d40
commit 3f542eb5bb
5 changed files with 43 additions and 9 deletions

View file

@ -25,6 +25,7 @@
"signin",
"sina",
"tencent",
"upid",
"Upvotes",
"VARCHAR",
"VNDB",

View 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`)
}

View file

@ -0,0 +1,11 @@
// 更新日志的数据接口
export interface KUNGalgameUpdateLog {
// 更新描述
description: string
// 更新发布时间
time: string
// 更新排序 ID
upid: number
// 更新版本
version: String
}

View file

@ -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: titlelikeviewcommenttext
const fetchedTopics = await getTopicRangeApi(start, count)
topics.value = fetchedTopics
topics.value = await getTopicRangeApi(start, count)
} catch (error) {
console.error('Error fetching topics:', error)
}

View file

@ -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">