完善比赛异常结束逻辑

This commit is contained in:
kron
2025-07-29 11:04:19 +08:00
parent 9d6bcde9ba
commit da2de8685d
2 changed files with 27 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
import websocket from "@/websocket";
import { isGamingAPI } from "@/apis";
import { isGamingAPI, getGameAPI } from "@/apis";
export const formatTimestamp = (timestamp) => {
const date = new Date(timestamp * 1000);
@@ -269,16 +269,20 @@ export const wxShare = async () => {
export const isGameEnded = async (battleId) => {
const isGaming = await isGamingAPI();
if (!isGaming) {
// uni.showToast({
// title: "比赛已结束",
// icon: "none",
// });
// setTimeout(() => {
// uni.navigateBack();
// }, 1000);
uni.redirectTo({
url: `/pages/battle-result?battleId=${battleId}`,
});
const result = await getGameAPI(battleId);
if (result.mode) {
uni.redirectTo({
url: `/pages/battle-result?battleId=${battleId}`,
});
} else {
uni.showToast({
title: "比赛已结束",
icon: "none",
});
setTimeout(() => {
uni.navigateBack();
}, 1000);
}
}
return !isGaming;
};