From bd82944f187f18f0722e7bff32e6ee32c0badbd5 Mon Sep 17 00:00:00 2001 From: Karlcarlo Date: Tue, 8 Sep 2026 11:49:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E6=B3=A8=E5=85=A5=E6=94=AF?= =?UTF-8?q?=E6=8C=81=20hash=20=E5=BC=80=E5=85=B3:=20=E5=BA=94=E7=94=A8=20i?= =?UTF-8?q?dentityHash=3Dfalse=20=E6=97=B6=E8=B7=B3=E8=BD=AC=E5=8F=AA?= =?UTF-8?q?=E5=B8=A6=20query=20=E4=B8=8D=E8=BF=BD=E5=8A=A0#(=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dbaobao-yingji=20hash=E8=B7=AF=E7=94=B1=E8=A2=AB?= =?UTF-8?q?=E7=A0=B4=E5=9D=8F)=20(v26090815)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 6 +++--- js/app.js | 16 ++++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index 63dfafd..511a103 100644 --- a/index.html +++ b/index.html @@ -7,8 +7,8 @@ 兜爸心选 · 孕育陪伴 - - + + @@ -1774,7 +1774,7 @@ 加载失败/离线时 window.wx 为 undefined,goMall() 会降级为 toast 提示, 不影响应用其余功能。 --> - + diff --git a/js/app.js b/js/app.js index 1bd5798..5ad4825 100644 --- a/js/app.js +++ b/js/app.js @@ -3,7 +3,7 @@ (function () { 'use strict'; /* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */ - var VER = '26090814'; + var VER = '26090815'; const $ = (s, c) => (c || document).querySelector(s); const $$ = (s, c) => Array.from((c || document).querySelectorAll(s)); @@ -182,7 +182,7 @@ for (let i = 0; i < (name || '').length; i++) h = (h * 31 + name.charCodeAt(i)) >>> 0; return PALETTE[h % PALETTE.length]; } - function jumpApp(url) { + function jumpApp(url, app) { haptic(); const oid = hashParam('openid'); const uid = hashParam('unionid'); @@ -190,7 +190,11 @@ if (oid) q.push('openid=' + encodeURIComponent(oid)); if (uid) q.push('unionid=' + encodeURIComponent(uid)); if (q.length) url += (url.indexOf('?') >= 0 ? '&' : '?') + q.join('&'); - if (oid) url += '#openid=' + encodeURIComponent(oid); + /* ⚠️ 部分应用自身用 location.hash 做路由/页面跳转(如 /baobao-yingji):追加 #openid + 会被当成非法路由 → 页面未找到。这类应用在 box_app 应用管理里 identityHash=false, + 跳转时只走 query 身份、不再追加 hash。默认允许(大部分应用无 hash 路由)。 */ + const canHash = !app || app.identityHash !== false; + if (oid && canHash) url += '#openid=' + encodeURIComponent(oid); location.href = url; } function renderAppGrid(apps) { @@ -203,12 +207,12 @@ ⚠️ colorTheme 目前全是 'blue' 颜色名 —— 有图时别拿它当底色,否则清一色蓝。 */ const bg = ico ? 'background:#fff' : 'background:' + (a.colorTheme || appTileColor(name)); const img = ico ? '' : '' + name.slice(0, 1) + ''; - return ''; + return ''; }).join(''); /* 磁贴点击(事件委托,innerHTML 重建后不用重绑) */ grid.onclick = function (e) { const t = e.target.closest('.app'); - if (t && t.dataset.url) jumpApp(decodeURIComponent(t.dataset.url)); + if (t && t.dataset.url) jumpApp(decodeURIComponent(t.dataset.url), APP_BY_ID[t.dataset.id]); }; /* 角标「共 N 个」同步真实数量 */ const cnt = $('.apps-head.for-all .sec-more'); @@ -499,7 +503,7 @@ $$('[data-mini]').forEach(b => b.addEventListener('click', () => { const map = { kick: '数胎动', weight: '孕期体重', cal: '孕检日历', curve: '生长曲线', fweight: '胎儿估重' }; const app = APP_BY_ID[MINI_APP_MAP[b.dataset.mini]]; - if (app && app.url) { jumpApp(app.url); return; } + if (app && app.url) { jumpApp(app.url, app); return; } toast('「' + map[b.dataset.mini] + '」即将上线'); }));