Commit a5b770c0 authored by 陈冲's avatar 陈冲

feat: 修复game3排行榜

parent a55524f5
......@@ -153,6 +153,18 @@ function startGameCountdown(seconds = 60) {
gameCountdownTimer = window.setTimeout(tickCountdown, 1000)
}
function syncGameCountdown(seconds: number) {
const syncedSeconds = Math.max(0, Math.floor(seconds))
if (countdownInterval.value - syncedSeconds <= 1) return
if (syncedSeconds === 0) {
countdownInterval.value = 0
return
}
startGameCountdown(syncedSeconds)
}
function resetToLoadingView() {
stopGameCountdown()
if (guFrameTimer) {
......@@ -232,10 +244,18 @@ if (wechat) {
},
onScoreSubmitted: (is_save, data) => {
if (!is_save) {//非保存状态下
const nextScore = Number(typeof data === 'object' ? data?.score : NaN)
const nextRank = Number(typeof data === 'object' ? data?.rank : data)
const remainingSeconds = Number(typeof data === 'object' ? data?.remainingSeconds : NaN)
if (Number.isFinite(nextScore) && nextScore >= 0) {
score.value = nextScore
}
if (Number.isFinite(nextRank) && nextRank > 0) {
rank.value = nextRank
}
if (Number.isFinite(remainingSeconds) && remainingSeconds >= 0) {
syncGameCountdown(remainingSeconds)
}
} else if (typeof data === 'object' && data) {
if (Array.isArray(data.list)) {
rankList.value = data.list.map((item: any, index: number) => ({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment