v26110903 广场/专题/计算器/测一测在小程序里也开容器页,复制链接直达;容器页返回走 navigateBack

新增 js/host-nav.js(MBHost.open/back/home + 页内同站 <a> 拦截):
- 首页进广场、专题问题、百宝箱测一测/计算器 → 容器页;广场点笔记 → 容器页 ?n=
- 容器页(_hv=1)里笔记关闭、广场/专题/计算器返回 → navigateBack;广场「返回」tab → switchTab 首页
- 失败或不在小程序照旧本页跳转

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
deploy
2026-11-09 14:06:03 +00:00
parent 17a845621a
commit 7cc154d9b3
9 changed files with 117 additions and 14 deletions

View File

@@ -3,7 +3,7 @@
(function () {
'use strict';
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
var VER = '26110901';
var VER = '26110903';
const $ = (s, c) => (c || document).querySelector(s);
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
@@ -181,6 +181,7 @@
return u.href;
}
function openInHost(target) {
if (window.MBHost) return window.MBHost.open(target); // js/host-nav.js(加 _hv=1,子页面返回走 navigateBack)
const mp = window.wx && window.wx.miniProgram;
if (!inMiniProgram() || !mp || typeof mp.navigateTo !== 'function') return false;
if (Date.now() - hostNavAt < 1000) return true; // 连点:上一次 navigateTo 还在路上
@@ -194,6 +195,7 @@
return true;
}
/* ================= H5 宿主恢复:冷启动回到上次进入的 H5 应用(2026-09-22) =================
需求:在小程序里进入某个 H5 应用后退出小程序,再次进入要恢复那个应用。
数据源:box_app GET /api/mp/public/last-app?openid=(Redis,per-openid,7 天 TTL)
@@ -4466,6 +4468,7 @@
haptic();
const url = 'guangchang/' + (id ? '?t=' + encodeURIComponent(id) : '') + location.hash;
reportHostLocation(new URL(url, location.href).href);
if (openInHost(url)) return;
location.href = url;
}
/* 「全部」:只放热门,四块(家庭/婚姻/职场/母婴)轮流排,别一排全是同一块;选了某块:该块热门在前、其余在后 */
@@ -4544,6 +4547,7 @@
haptic();
const url = 'guangchang/?mine=1' + location.hash;
reportHostLocation(new URL(url, location.href).href);
if (openInHost(url)) return;
location.href = url;
});
$('.gch-who', sec).before(b);
@@ -6048,7 +6052,7 @@
const a = document.createElement('div'); a.className = 'qa-a';
a.textContent = x.a || '';
/* 有专题页的条目(首页那 6 个)点了直接进专题页 */
h.addEventListener('click', () => { if (x.href) { haptic(); location.href = qaHref(x.href); return; } it.classList.toggle('open'); haptic(); });
h.addEventListener('click', () => { if (x.href) { haptic(); const u = qaHref(x.href); if (!openInHost(u)) location.href = u; return; } it.classList.toggle('open'); haptic(); });
it.appendChild(h); it.appendChild(a);
L.appendChild(it);
});
@@ -6913,6 +6917,7 @@
haptic();
const url = 'guangchang/?fav=1' + location.hash;
reportHostLocation(new URL(url, location.href).href);
if (openInHost(url)) return;
location.href = url;
});
})();