悄悄话转发落地:星空页开着时地址带 ?wh=1,求赞带 &wc=;深链不被恢复上次应用跳走 (v26110632)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
23
js/app.js
23
js/app.js
@@ -3,7 +3,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||
var VER = '26110631';
|
||||
var VER = '26110632';
|
||||
const $ = (s, c) => (c || document).querySelector(s);
|
||||
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
||||
|
||||
@@ -202,6 +202,8 @@
|
||||
/* 预览页(/mama-box-preview/)是直接发链接给人看的,不在小程序里冷启动 —— 不恢复上次应用,
|
||||
否则一打开就被送去上次进过的应用(2026-10-01 用户反馈:打开预览链接直接跳到孕检日历)。 */
|
||||
if (location.pathname.indexOf('/mama-box-preview/') === 0) return;
|
||||
/* 11-07:转发来的悄悄话卡片(?wh=1 / ?wc=<留言id>)是要直接看星空页的,不能被「恢复上次应用」跳走 */
|
||||
if (/[?&](wh|wc)=/.test(location.search)) { sessionStorage.setItem(RESUME_DONE_KEY, '1'); return; }
|
||||
const oid = hashParam('openid');
|
||||
if (!oid) return; // 无身份不跳(宿主拿不到 openid 时也不会加载本页)
|
||||
/* 先置闸门再请求/再判 norestore:
|
||||
@@ -4838,7 +4840,21 @@
|
||||
drawer(false);
|
||||
launch(g.dataset.next ? nextStar() : +g.dataset.go);
|
||||
});
|
||||
/* 11-07 用户:小程序里转发「本周话题」,对方点进来要直接到星空页 —— 宿主转发好友用的是 web-view 当前真实地址
|
||||
(onShareAppMessage 的 webViewUrl),不看上报的 href,所以星空页开着时地址里要一直带 ?wh=1,关掉再去掉。 */
|
||||
function whQs(on) {
|
||||
try {
|
||||
const q = new URLSearchParams(location.search);
|
||||
if (on) q.set('wh', '1'); else { q.delete('wh'); q.delete('wc'); }
|
||||
const u = location.pathname + (q.toString() ? '?' + q : '') + location.hash;
|
||||
if (u === location.pathname + location.search + location.hash) return;
|
||||
history.replaceState(history.state, '', u);
|
||||
const th = window.MB_WH_THEME ? window.MB_WH_THEME() : null;
|
||||
if (window.wxAuth && wxAuth.reportLocation) wxAuth.reportLocation(on ? { title: th ? '本周话题:' + th.name : '孕妈悄悄话' } : {});
|
||||
} catch (e) {}
|
||||
}
|
||||
function openPage() {
|
||||
whQs(true);
|
||||
stopAll();
|
||||
cur = 0;
|
||||
card.classList.remove('show');
|
||||
@@ -4854,6 +4870,7 @@
|
||||
stopAll();
|
||||
drawer(false);
|
||||
if (fromPlaza) { fromPlaza = false; history.back(); return; } /* 从广场置顶笔记来的:回广场 */
|
||||
whQs(false);
|
||||
page.classList.remove('show');
|
||||
page.setAttribute('aria-hidden', 'true');
|
||||
}
|
||||
@@ -4896,10 +4913,6 @@
|
||||
let autoOpen = /[?&]wh=1(?:&|$)/.test(location.search), fromPlaza = false;
|
||||
if (autoOpen) {
|
||||
fromPlaza = /\/guangchang\//.test(document.referrer || '') && history.length > 1;
|
||||
if (history.replaceState) {
|
||||
const q = new URLSearchParams(location.search); q.delete('wh');
|
||||
history.replaceState(history.state, '', location.pathname + (q.toString() ? '?' + q : '') + location.hash);
|
||||
}
|
||||
page.classList.add('show');
|
||||
page.setAttribute('aria-hidden', 'false');
|
||||
let gw = 0;
|
||||
|
||||
Reference in New Issue
Block a user