host-nav:复制链接直接打开的页面不回首页旧位置(清 mmbox.homepos.v1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
deploy
2026-11-09 15:00:09 +00:00
parent 0866be311b
commit 2edbd6625c
18 changed files with 20 additions and 18 deletions

View File

@@ -27,7 +27,7 @@
function mp() { return g.wx && g.wx.miniProgram; }
function inMp() { return g.__wxjs_environment === 'miniprogram' || /miniProgram/i.test(navigator.userAgent); }
function inView() { return /[?&]_hv=1(&|$)/.test(location.search); }
var OK = 'mbhost.open', CK = 'mbhost.child';
var OK = 'mbhost.open', CK = 'mbhost.child', POS = 'mmbox.homepos.v1'; /* POS:首页跳走前记的滚动位置(mama-box app.js saveHomePos) */
function key(href) { /* 比对用:去掉容器注入的身份 / 时间戳参数 */
var u = new URL(href, location.href);
['openid', 'unionid', 't', '_v', '__no_identity'].forEach(function (k) { u.searchParams.delete(k); });
@@ -40,6 +40,8 @@
try {
var m = JSON.parse(localStorage.getItem(OK) || 'null');
if (m && Date.now() - m.at < 30000 && key(m.u) === key(location.href)) { sessionStorage.setItem(CK, '1'); localStorage.removeItem(OK); }
/* 11-09 用户:复制链接 / 分享直接打开的页面,返回首页就停在顶部,不要回到「自己上次点进笔记时」的首页位置 */
if (!isChild()) localStorage.removeItem(POS);
} catch (e) {}
})();
function toHome(fallback) {