完成80%

This commit is contained in:
2026-07-27 06:50:07 +08:00
parent 8475bbd19a
commit 1eae3bbef4
63 changed files with 13664 additions and 280 deletions
+38 -2
View File
@@ -633,6 +633,34 @@ const assertResultSourceContext = (targetRoute, targetParams, sourcePage) => {
}
};
const isImplicitRootOptionalContext = (
routeKey,
route,
existingParams,
targetParams,
name,
sourcePage,
) => {
if (
!ROOT_ROUTE_KEYS.includes(routeKey) ||
!route.optionalParams.includes(name) ||
hasOwn(existingParams, name) ||
!hasOwn(targetParams, name)
) {
return false;
}
const sourceRouteKey = getPageRouteKey(sourcePage);
const sourceRoute = getRoute(sourceRouteKey);
if (!sourceRoute) return false;
const sourceParams = validateRouteParams(
sourceRouteKey,
getPageParams(sourcePage, sourceRoute),
true,
).params;
return hasOwn(sourceParams, name) && sourceParams[name] === targetParams[name];
};
const returnToValidated = (routeKey, targetParams, result) => {
const validatedTarget = validateRouteParams(
routeKey,
@@ -656,8 +684,16 @@ const returnToValidated = (routeKey, targetParams, result) => {
targetIdentity = validatedExisting.params;
for (const [name, value] of Object.entries(normalizedTargetParams)) {
if (
!hasOwn(validatedExisting.params, name) ||
validatedExisting.params[name] !== value
(!hasOwn(validatedExisting.params, name) ||
validatedExisting.params[name] !== value) &&
!isImplicitRootOptionalContext(
routeKey,
route,
validatedExisting.params,
normalizedTargetParams,
name,
sourcePage,
)
) {
throw new Error(`${routeKey} 显式目标参数 ${name} 与最近实例不一致`);
}