update:优化比赛

This commit is contained in:
2026-07-09 11:43:06 +08:00
parent af07d09ab6
commit f8efe4c4a4
9 changed files with 130 additions and 86 deletions
+11 -9
View File
@@ -7,6 +7,7 @@ import ScreenHint from "@/components/ScreenHint.vue";
import BackToGame from "@/components/BackToGame.vue";
import {laserAimAPI, getBattleAPI, matchGameAPI} from "@/apis";
import { capsuleHeight, debounce } from "@/util";
import { returnToBattle } from "@/utils/matchReturn";
import AudioManager from "@/audioManager";
const props = defineProps({
title: {
@@ -110,6 +111,15 @@ onShow(() => {
showHint.value = false;
});
const navigateTo = (url) =>
new Promise((resolve, reject) => {
uni.navigateTo({
url,
success: resolve,
fail: reject,
});
});
const backToGame = debounce(async () => {
if (isLoading.value) return; // 防止重复点击
@@ -118,15 +128,7 @@ const backToGame = debounce(async () => {
const result = await getBattleAPI();
if (result && result.matchId) {
await checkAudioProgress();
if (result.mode <= 3) {
uni.navigateTo({
url: `/pages/team-battle/index?battleId=${result.matchId}`,
});
} else {
uni.navigateTo({
url: `/pages/melee-battle?battleId=${result.matchId}`,
});
}
await returnToBattle(result, navigateTo);
}
} catch (error) {
console.error("获取当前游戏失败:", error);