Skip to content

Commit

Permalink
修复页面加载
Browse files Browse the repository at this point in the history
  • Loading branch information
cunoe committed May 14, 2024
1 parent 3e61ffb commit 9aa8dd7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion components/player/PlayerHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ onMounted(async () => {
}),
}
fetchBattleData(params).then((resp) => {
screenInfo.value = '正在请求数据,请稍后'
await fetchBattleData(params).then((resp) => {
battleDataResp.value = resp
const playerDMGDataset = playersInfo.map(item => {
return {
Expand Down
15 changes: 10 additions & 5 deletions components/player/Players.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {BattleDataResponse, BattleDataRequest} from "~/composables/requests
const toast = useToast()
const screenInfo = ref('还没有数据哦~请这位窝批,启动!')
const battleHistory = ref<BattleHistory>(null as unknown as BattleHistory)
const gameInfo = ref<GameData>(null as unknown as GameData)
const teammates = ref<Vehicle[]>([])
Expand All @@ -34,6 +35,9 @@ useIntervalFn(async () => {
if (result.timestamp === timestamp.value && result.teammate_server === teammateServer.value && result.enemy_server === enemyServer.value) {
return
}
screenInfo.value = '正在解析数据,请稍后'
isReady.value = false
let gameData: GameData = JSON.parse(result.raw_data)
let playersInfo: Vehicle[] = [];
for (let i = 0; i < gameData.vehicles.length; i++) {
Expand Down Expand Up @@ -77,20 +81,21 @@ useIntervalFn(async () => {
}
}),
}
fetchBattleData(params).then((resp) => {
battleDataResp.value = resp
screenInfo.value = '正在请求数据,请稍后'
await fetchBattleData(params).then((resp) => {
battleDataResp.value = resp
isReady.value = true
}).catch((err) => {
toast.add({
title: "获取数据失败:" + err.message,
})
screenInfo.value = '获取数据失败' + err.message
console.log(err)
})
timestamp.value = result.timestamp
teammateServer.value = result.teammate_server
enemyServer.value = result.enemy_server
isReady.value = true
}
}, 5000)
useIntervalFn(async () => {
Expand All @@ -111,7 +116,7 @@ useIntervalFn(async () => {
class="w-3/5 rounded-lg shadow-sm p-5 border-dashed border border-blue-500 flex flex-col sm:flex-row justify-center items-center gap-2 sm:gap-0 text-center">
<div class="flex flex-col sm:flex-row justify-center items-center gap-4">
<div class="text-center">
<div class="stat-value text-3xl">还没有数据哦~请这位窝批,启动!</div>
<div class="stat-value text-3xl">{{ screenInfo }}</div>
<span class="loading loading-infinity loading-lg"></span>
</div>
</div>
Expand Down

0 comments on commit 9aa8dd7

Please sign in to comment.