update:新增匹配跳转幂等
This commit is contained in:
+18
-6
@@ -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;这里不绕过页面内状态,避免好友房误触退房逻辑。
|
||||
|
||||
Reference in New Issue
Block a user