update:新增匹配跳转幂等

This commit is contained in:
2026-07-20 16:46:04 +08:00
parent b15c37cb4a
commit 886faa0007
2 changed files with 25 additions and 11 deletions
+18 -6
View File
@@ -227,15 +227,27 @@ function normalizeRoute(route) {
return String(route || "").replace(/^\//, "");
}
function isCurrentBattlePage(matchId) {
function getRouteFromUrl(url) {
return normalizeRoute(String(url || "").split("?")[0]);
}
function isCurrentBattlePage(url, matchId) {
const page = getCurrentPageInfo();
const route = normalizeRoute(page?.route);
if (route !== "pages/team-battle/index" && route !== "pages/melee-battle") {
return false;
}
const targetRoute = getRouteFromUrl(url);
if (!targetRoute || route !== targetRoute) return false;
const options = page?.options || page?.$page?.options || {};
return !matchId || normalizeId(options.battleId) === normalizeId(matchId);
const expectedMatchId = normalizeId(matchId);
if (!expectedMatchId) return true;
const routeMatchId = normalizeId(options.battleId);
if (routeMatchId) return routeMatchId === expectedMatchId;
return Boolean(
options.fromReturn &&
normalizeId(currentContext?.matchId) === expectedMatchId
);
}
function scheduleReadyRouteFallback(message) {
@@ -246,7 +258,7 @@ function scheduleReadyRouteFallback(message) {
lastReadyRouteKey = routeKey;
setTimeout(() => {
if (isCurrentBattlePage(matchId)) return;
if (isCurrentBattlePage(url, matchId)) return;
const currentRoute = normalizeRoute(getCurrentPageInfo()?.route);
// battle-room 和 match-page 本身会消费 AboutToStart;这里不绕过页面内状态,避免好友房误触退房逻辑。