feat(宿主恢复): 支持 #norestore=1 —— 小程序首页壳已决策时不再自行恢复 (v26092202)
档 3:首页壳自己读 last_app 并直接进容器页(不加载 mama-box、无首页闪屏)。 此时 mama-box 只是它留在身后的「返回落点」,必须禁止再自行恢复 —— 否则 mama-box 会在容器页底下把落点也换成目标应用,back 回不到首页。 - 收到 #norestore=1:既不跳,也先用 sessionStorage 闸门占住, 免得后续宿主 ?t= 重载(不带该标记)时又跳一次 - 无该标记时行为不变:浏览器直访 / 首页壳取数失败回落加载时仍是兜底恢复 - 版本 v26092201 → v26092202
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
<meta name="mobile-web-app-capable" content="yes">
|
<meta name="mobile-web-app-capable" content="yes">
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
<title>兜爸心选 · 孕育陪伴</title>
|
<title>兜爸心选 · 孕育陪伴</title>
|
||||||
<!-- V:26092201 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 -->
|
<!-- V:26092202 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 -->
|
||||||
<link rel="stylesheet" href="mama-box.css">
|
<link rel="stylesheet" href="mama-box.css">
|
||||||
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
|
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
|
||||||
<!-- 共享助手:授权/跳商城/位置上报(分享卡片同步,见 docs/h5-auth-standard.md 第四节) -->
|
<!-- 共享助手:授权/跳商城/位置上报(分享卡片同步,见 docs/h5-auth-standard.md 第四节) -->
|
||||||
|
|||||||
10
js/app.js
10
js/app.js
@@ -3,7 +3,7 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||||
var VER = '26092201';
|
var VER = '26092202';
|
||||||
const $ = (s, c) => (c || document).querySelector(s);
|
const $ = (s, c) => (c || document).querySelector(s);
|
||||||
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
||||||
|
|
||||||
@@ -191,9 +191,13 @@
|
|||||||
if (sessionStorage.getItem(RESUME_DONE_KEY)) return; // 同一 web-view 会话只尝试一次
|
if (sessionStorage.getItem(RESUME_DONE_KEY)) return; // 同一 web-view 会话只尝试一次
|
||||||
const oid = hashParam('openid');
|
const oid = hashParam('openid');
|
||||||
if (!oid) return; // 无身份不跳(宿主拿不到 openid 时也不会加载本页)
|
if (!oid) return; // 无身份不跳(宿主拿不到 openid 时也不会加载本页)
|
||||||
/* 先置闸门再请求:GET 失败/超时也不在本次会话里重试 ——
|
/* 先置闸门再请求/再判 norestore:
|
||||||
宁可少恢复一次,也不要「用户切回首页 tab 时被突然跳走」。 */
|
· #norestore=1 = 小程序首页壳**已经自己决策过**了(它直接把用户送进了目标应用,
|
||||||
|
本页只是它留在身后的「返回落点」)—— 这里既不跳,也要用闸门占住,
|
||||||
|
免得后续宿主 ?t= 重载(不带该标记)时又跳一次,把返回落点也换成目标应用。
|
||||||
|
· 浏览器直访 / 首页壳取数失败后回落加载本页时,没有该标记 → 照旧自行恢复(兜底)。 */
|
||||||
sessionStorage.setItem(RESUME_DONE_KEY, '1');
|
sessionStorage.setItem(RESUME_DONE_KEY, '1');
|
||||||
|
if (hashParam('norestore')) return;
|
||||||
fetch(LAST_APP_API + '?openid=' + encodeURIComponent(oid))
|
fetch(LAST_APP_API + '?openid=' + encodeURIComponent(oid))
|
||||||
.then(r => (r.ok ? r.json() : null))
|
.then(r => (r.ok ? r.json() : null))
|
||||||
.then(d => {
|
.then(d => {
|
||||||
|
|||||||
Reference in New Issue
Block a user