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

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

@@ -1,4 +1,4 @@
import { isGamingAPI, getGameAPI } from "@/apis";
import { getUserGameState, getGameAPI } from "@/apis";
export const formatTimestamp = (timestamp) => {
const date = new Date(timestamp * 1000);
@@ -90,8 +90,8 @@ export const wxShare = async (canvasId = "shareCanvas") => {
};
export const isGameEnded = async (battleId) => {
const isGaming = await isGamingAPI();
if (!isGaming) {
const state = await getUserGameState();
if (!state.gaming) {
const result = await getGameAPI(battleId);
if (result.mode) {
uni.redirectTo({
@@ -107,7 +107,7 @@ export const isGameEnded = async (battleId) => {
}, 1000);
}
}
return !isGaming;
return !state.gaming;
};
// 获取元素尺寸和位置信息