添加游戏异常结束处理

This commit is contained in:
kron
2025-07-16 16:09:10 +08:00
parent c0dd20cb3f
commit dc53653398
3 changed files with 30 additions and 9 deletions

View File

@@ -421,11 +421,18 @@ async function onReceiveMessage(messages = []) {
} }
if (msg.constructor === MESSAGETYPES.MatchOver) { if (msg.constructor === MESSAGETYPES.MatchOver) {
uni.setStorageSync("last-battle", msg.endStatus); uni.setStorageSync("last-battle", msg.endStatus);
if (msg.endStatus.nosaved) {
uni.showToast({
title: "游戏结束",
icon: "none",
});
} else {
uni.redirectTo({ uni.redirectTo({
url: `/pages/battle-result?battleId=${msg.id}`, url: `/pages/battle-result?battleId=${msg.id}`,
}); });
} }
} }
}
}); });
} }

View File

@@ -148,10 +148,17 @@ async function onReceiveMessage(messages = []) {
} }
if (msg.constructor === MESSAGETYPES.MatchOver) { if (msg.constructor === MESSAGETYPES.MatchOver) {
uni.setStorageSync("last-battle", msg.endStatus); uni.setStorageSync("last-battle", msg.endStatus);
if (msg.endStatus.nosaved) {
uni.showToast({
title: "游戏结束",
icon: "none",
});
} else {
uni.redirectTo({ uni.redirectTo({
url: `/pages/battle-result?battleId=${msg.id}`, url: `/pages/battle-result?battleId=${msg.id}`,
}); });
} }
}
}); });
} }
const onBack = () => { const onBack = () => {

View File

@@ -214,10 +214,17 @@ async function onReceiveMessage(messages = []) {
} }
if (msg.constructor === MESSAGETYPES.MatchOver) { if (msg.constructor === MESSAGETYPES.MatchOver) {
uni.setStorageSync("last-battle", msg.endStatus); uni.setStorageSync("last-battle", msg.endStatus);
if (msg.endStatus.nosaved) {
uni.showToast({
title: "游戏结束",
icon: "none",
});
} else {
uni.redirectTo({ uni.redirectTo({
url: `/pages/battle-result?battleId=${msg.id}`, url: `/pages/battle-result?battleId=${msg.id}`,
}); });
} }
}
}); });
} }
const onBack = () => { const onBack = () => {