Files
remoteconn-gitea/apps/miniprogram/utils/navigationPolicy.js
2026-03-21 18:57:10 +08:00

21 lines
691 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 小程序页面导航策略:
* 1. 底部导航在“页面之间横跳”时优先使用 redirectTo避免长期堆积页面实例
* 2. 同一路径返回 noop避免重复触发无意义导航
* 3. 仅当目标不是标准页面路由时,才退回 navigateTo。
*/
function resolvePageNavigationMethod(currentPath, targetPath) {
const current = String(currentPath || "").trim();
const target = String(targetPath || "").trim();
if (!target) return "noop";
if (current && current === target) return "noop";
if (/^\/pages\/.+\/index$/.test(target)) {
return "redirectTo";
}
return "navigateTo";
}
module.exports = {
resolvePageNavigationMethod
};