悄悄话留言身份与首页打通:openid 读 hash+query+同源缓存,退出登录算访客;广场/专题页也加缓存兜底 (v26110633)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
deploy
2026-11-07 05:01:16 +00:00
parent 53652c481c
commit 91f29e05c9
5 changed files with 22 additions and 14 deletions

View File

@@ -65,7 +65,7 @@
if (SLUG) (function () { var s = document.createElement('script'); s.src = '../../js/share-card.js?v=26110464'; s.onload = function () { window.mbShare('../../assets/share/t/' + SLUG + '.jpg'); }; document.head.appendChild(s); })();
/* 11-07 退出登录后只看不写(js/login-gate.js):点赞、评论、发图都弹「登录后才能使用」 */
if (!window.mbGate) (function () { var s = document.createElement('script'); s.src = '../../js/login-gate.js?v=26110610'; document.head.appendChild(s); })();
var SK = 'mmbox.tp.v1', UK = (function () { var m = ((location.hash || '') + '&' + (location.search || '')).match(/[#?&]openid=([^&]*)/); return m ? decodeURIComponent(m[1]) : '_guest'; })();
var SK = 'mmbox.tp.v1', UK = (function () { var m = ((location.hash || '') + '&' + (location.search || '')).match(/[#?&]openid=([^&]*)/); return m ? decodeURIComponent(m[1]).split('?')[0] : ((function(){try{var c=JSON.parse(sessionStorage.getItem('mmbox.identity')||'null');return c&&c.openid&&(!c.at||Date.now()-c.at<432e5)?c.openid:'';}catch(e){return '';}})() || '_guest'); })(); /* 11-07 URL 没带身份时用首页存的同源缓存 */
function loadMe() { try { var a = JSON.parse(localStorage.getItem(SK) || '{}') || {}; var m = a[UK] || {}; m.cm = m.cm || {}; m.lk = m.lk || {}; return { a: a, m: m }; } catch (e) { return { a: {}, m: { cm: {}, lk: {} } }; } }
function saveMe(st) { try { st.a[UK] = st.m; localStorage.setItem(SK, JSON.stringify(st.a)); } catch (e) {} }
/* 11-02 用户:自己发的评论带上孕周(首页写进 mmbox.gcwk.v1) */