添加分享房间链接和对战结束返回房间

This commit is contained in:
kron
2026-01-09 11:50:21 +08:00
parent 4aa14c6a4c
commit 71b25144a4
14 changed files with 204 additions and 209 deletions

View File

@@ -112,21 +112,8 @@ const backToGame = debounce(async () => {
try {
isLoading.value = true;
// 设置请求超时
const timeoutPromise = new Promise((_, reject) => {
setTimeout(() => reject(new Error("请求超时")), 10000); // 10秒超时
});
const result = await Promise.race([getCurrentGameAPI(), timeoutPromise]);
// 处理返回结果
if (result && result.gameId) {
// 跳转到游戏页面
uni.navigateTo({
url: `/pages/battle-room?gameId=${result.gameId}`,
});
} else {
const game = await getCurrentGameAPI();
if (!game || !game.gameId) {
uni.showToast({
title: "没有进行中的对局",
icon: "none",
@@ -136,10 +123,6 @@ const backToGame = debounce(async () => {
showHint.value = false;
} catch (error) {
console.error("获取当前游戏失败:", error);
uni.showToast({
title: error.message || "网络请求失败,请重试",
icon: "none",
});
} finally {
isLoading.value = false;
}