悄悄话:广场置顶笔记直接进星空页,留言挂在星空页「说一句悄悄话」下面(深色星空样式);投稿轮播去掉礼物图标和「我也投稿」
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
35
js/wh-cm.css
Normal file
35
js/wh-cm.css
Normal file
@@ -0,0 +1,35 @@
|
||||
/* 星空页 · 妈妈们的留言(2026-11-07,js/wh-cm.js):深靛紫玻璃,跟星空一个色系,不用白底 */
|
||||
.wcm{position:absolute;inset:0;z-index:4;overflow-y:auto;overscroll-behavior:contain;pointer-events:none;scrollbar-width:none;-webkit-overflow-scrolling:touch}
|
||||
.wcm::-webkit-scrollbar{display:none}
|
||||
.wcm-sp{height:calc(100% - 158px - env(safe-area-inset-bottom));pointer-events:none}
|
||||
.wcm-in{position:relative;pointer-events:auto;min-height:calc(100% - 60px);padding-bottom:calc(24px + env(safe-area-inset-bottom));
|
||||
background:linear-gradient(180deg,rgba(28,22,52,0) 0,rgba(28,22,52,.9) 56px,rgba(26,20,48,.97) 150px,#1E1838 100%)}
|
||||
.wcm .whp-bar{position:relative;left:auto;right:auto;bottom:auto;padding:22px 24px 4px;background:none}
|
||||
.wcm-hd{display:flex;align-items:baseline;gap:8px;margin:14px 18px 6px;color:#F4ECFF}
|
||||
.wcm-hd b{font-size:15px;font-weight:800;letter-spacing:1px}
|
||||
.wcm-hd span{font-size:12px;color:rgba(232,222,255,.5)}
|
||||
.wcm-up{margin-left:auto;font-style:normal;font-size:11.5px;color:rgba(255,214,170,.75);transition:opacity .3s}
|
||||
.wcm-up::after{content:"";display:inline-block;width:6px;height:6px;margin-left:5px;border:solid currentColor;border-width:1.5px 0 0 1.5px;transform:translateY(1px) rotate(45deg)}
|
||||
.wcm.up .wcm-up{opacity:0}
|
||||
.wcm-ls{padding:0 12px}
|
||||
.wcm-e{margin:18px 0;text-align:center;font-size:12.5px;color:rgba(232,222,255,.45)}
|
||||
.wcm-it{display:flex;gap:10px;margin-top:8px;padding:12px 10px 12px 12px;border-radius:16px;
|
||||
background:linear-gradient(140deg,rgba(255,255,255,.075),rgba(255,255,255,.03));box-shadow:inset 0 0 0 1px rgba(255,255,255,.07)}
|
||||
.wcm-av{flex:none;width:32px;height:32px;border-radius:50%;object-fit:cover;background:#3A2F5E;box-shadow:0 0 0 1.5px rgba(255,220,180,.35)}
|
||||
.wcm-bd{flex:1;min-width:0}
|
||||
.wcm-nm{display:flex;align-items:baseline;gap:6px;margin:0;font-size:12px;color:rgba(232,222,255,.45)}
|
||||
.wcm-nm b{font-size:12.5px;font-weight:700;color:#FFD9B8;max-width:9em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.wcm-tx{margin:4px 0 0;font-size:14px;line-height:1.6;color:#F2ECFA;word-break:break-word}
|
||||
.wcm-st{margin:4px 0 0;font-size:11.5px;color:#FFC07A}
|
||||
.wcm-rp{margin-top:8px;padding:7px 10px;border-radius:10px;background:rgba(255,255,255,.05)}
|
||||
.wcm-rp p{margin:0;font-size:12.5px;line-height:1.55;color:rgba(242,236,250,.78)}
|
||||
.wcm-rp p+p{margin-top:4px}
|
||||
.wcm-rp b{font-weight:700;color:#C9B8FF}
|
||||
.wcm-lk{flex:none;align-self:flex-start;display:flex;flex-direction:column;align-items:center;gap:1px;min-width:32px;padding:2px 0;border:0;background:none;font:inherit;color:rgba(232,222,255,.5)}
|
||||
.wcm-lk svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.8;transition:transform .2s}
|
||||
.wcm-lk span{font-size:11px}
|
||||
.wcm-lk.on{color:#FF8FA6}.wcm-lk.on svg{fill:currentColor;transform:scale(1.12)}
|
||||
.wcm-more{display:block;margin:14px auto 0;height:34px;padding:0 22px;border-radius:99px;border:1px solid rgba(255,220,180,.35);background:rgba(255,255,255,.05);color:#FFD9B8;font:inherit;font-size:13px}
|
||||
.wcm-more[hidden]{display:none}
|
||||
/* 内容卡 / 落完提示往上让一让,别被留言面板顶住 */
|
||||
.wh-page .wsc{bottom:calc(172px + env(safe-area-inset-bottom))}
|
||||
91
js/wh-cm.js
Normal file
91
js/wh-cm.js
Normal file
@@ -0,0 +1,91 @@
|
||||
/* 星空页 · 妈妈们的留言(2026-11-07 用户:广场点「孕妈悄悄话」直接进星空页,留言自带在「说一句悄悄话」下面,
|
||||
样式跟星空搭,不要白底)。
|
||||
· 版式:#wcm 盖满星空页、自己滚动、本身不接点击;上面一段透明垫高(点得到星星),下面是留言面板,
|
||||
把原来的 .whp-bar(说一句悄悄话)挪进面板顶上,往上滑留言就盖上来。
|
||||
· 数据:广场置顶笔记 wh-<话题 from> 的评论 = cm.json 模拟(AGENTS.md 12c,不得挂星)+ /plaza/comments 已审核通过的真实评论
|
||||
+ 我自己发的(含审核中)。进星空页才拉 cm.json(600K+,gzip 后小很多;版本号跟广场 index.html 引的一致,共用缓存)。
|
||||
· 赞只记本机 mmbox.whcm.v1(服务端计数是悄悄话第 2 步)。 */
|
||||
(function () {
|
||||
var page = document.getElementById('whPage'), bar = page && page.querySelector('.whp-bar');
|
||||
if (!page || !bar || !window.MB_WH_THEME) return;
|
||||
var TH = MB_WH_THEME(), PID = 'wh-' + TH.from.replace(/-/g, '');
|
||||
var esc = function (s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]; }); };
|
||||
var m = ((location.hash || '') + '&').match(/[#&]openid=([^&]*)/), OID = m ? decodeURIComponent(m[1]) : '';
|
||||
|
||||
var box = document.createElement('div');
|
||||
box.className = 'wcm'; box.id = 'wcm';
|
||||
box.innerHTML = '<div class="wcm-sp" aria-hidden="true"></div><div class="wcm-in"><div class="wcm-hd"><b>妈妈们的留言</b><span id="wcmN"></span><i class="wcm-up">上滑看看</i></div>' +
|
||||
'<div class="wcm-ls" id="wcmLs"><p class="wcm-e">留言加载中…</p></div><button type="button" class="wcm-more" id="wcmMore" hidden>再看看</button></div>';
|
||||
box.querySelector('.wcm-in').insertBefore(bar, box.querySelector('.wcm-hd'));
|
||||
page.appendChild(box);
|
||||
var ls = box.querySelector('#wcmLs'), more = box.querySelector('#wcmMore');
|
||||
|
||||
var LK = 'mmbox.whcm.v1', LIKE = {};
|
||||
try { LIKE = JSON.parse(localStorage.getItem(LK) || '{}') || {}; } catch (e) {}
|
||||
var avP = function (a) { return typeof a === 'number' ? 'guangchang/av/' + ('000' + a).slice(-4) + '.webp' : a.indexOf('av:') === 0 ? 'guangchang/av/' + a.slice(3) + '.webp' : a.charAt(0) === '/' ? a : 'assets/img/mom/' + a + '.jpg'; };
|
||||
var fmt = function (n) { return n >= 10000 ? (n / 10000).toFixed(1) + 'w' : String(n); };
|
||||
var ago = function (ts) {
|
||||
var d = (Date.now() - ts) / 1000;
|
||||
if (d < 3600) return Math.max(1, Math.round(d / 60)) + ' 分钟前';
|
||||
if (d < 86400) return Math.round(d / 3600) + ' 小时前';
|
||||
var t = new Date(ts + 8 * 3600e3); return (t.getUTCMonth() + 1) + '-' + t.getUTCDate();
|
||||
};
|
||||
|
||||
var SIM = null, REAL = null, ALL = [], shown = 0, loading = false;
|
||||
function load() {
|
||||
if (loading || SIM) return; loading = true;
|
||||
fetch('guangchang/cm.json?v=26110612').then(function (r) { return r.json(); }).then(function (j) {
|
||||
var P = j.p;
|
||||
SIM = (j.c[PID] || []).map(function (c, k) {
|
||||
var p = P[c[0]];
|
||||
return { key: 's' + k, n: p[0], av: avP(p[1]), s: p[2], t: c[1], likes: c[2],
|
||||
r: c[3].map(function (x) { var q = x[0] < 0 ? null : P[x[0]]; return { n: q ? q[0] : '孕妈悄悄话', t: x[1] }; }) };
|
||||
});
|
||||
build();
|
||||
}).catch(function () { SIM = []; build(); });
|
||||
fetch('/api/mp/public/mama-box/plaza/comments?kind=post&target=' + encodeURIComponent(PID) + (OID ? '&openid=' + encodeURIComponent(OID) : ''))
|
||||
.then(function (r) { return r.json(); }).then(function (j) {
|
||||
var R = j && j.code === 200 && j.result || {}, top = function (c) { return !c.parent; };
|
||||
REAL = (R.list || []).filter(top).map(function (c) { return { key: 'r' + c.id, n: c.nickname || '孕妈', av: c.avatar || 'assets/img/mom/k01.jpg', s: c.stage, t: c.text, likes: 0, ts: c.at, r: [] }; })
|
||||
.concat((R.mine || []).filter(function (c) { return top(c) && c.status !== 'rejected'; }).map(function (c) {
|
||||
return { key: 'r' + c.id, n: '我', me: 1, av: c.avatar || 'assets/img/mom/k01.jpg', s: c.stage, t: c.text, likes: 0, ts: c.at, st: c.status, r: [] }; }))
|
||||
.sort(function (a, b) { return b.ts - a.ts; });
|
||||
build();
|
||||
}).catch(function () { REAL = []; build(); });
|
||||
}
|
||||
function build() {
|
||||
if (!SIM || !REAL) return;
|
||||
ALL = REAL.concat(SIM); shown = 0; ls.innerHTML = '';
|
||||
document.getElementById('wcmN').textContent = ALL.length ? ALL.length + ' 条' : '';
|
||||
if (!ALL.length) { ls.innerHTML = '<p class="wcm-e">还没有留言</p>'; more.hidden = true; return; }
|
||||
add(20);
|
||||
}
|
||||
function item(c) {
|
||||
var on = !!LIKE[c.key];
|
||||
return '<div class="wcm-it"><img class="wcm-av" src="' + esc(c.av) + '" alt="" loading="lazy" onerror="this.style.visibility=\'hidden\'">' +
|
||||
'<div class="wcm-bd"><p class="wcm-nm"><b>' + esc(c.n) + '</b>' + (c.s ? '<span>' + esc(c.s) + '</span>' : '') + (c.ts ? '<span>' + ago(c.ts) + '</span>' : '') + '</p>' +
|
||||
'<p class="wcm-tx">' + esc(c.t) + '</p>' + (c.st === 'pending' ? '<p class="wcm-st">审核中 · 通过后大家才能看到</p>' : '') +
|
||||
(c.r.length ? '<div class="wcm-rp">' + c.r.map(function (x) { return '<p><b>' + esc(x.n) + '</b>:' + esc(x.t) + '</p>'; }).join('') + '</div>' : '') + '</div>' +
|
||||
'<button type="button" class="wcm-lk' + (on ? ' on' : '') + '" data-wcl="' + esc(c.key) + '" aria-label="赞"><svg viewBox="0 0 24 24"><path d="M12 20.5s-7.5-4.6-7.5-10.2A4.3 4.3 0 0112 7.6a4.3 4.3 0 017.5 2.7c0 5.6-7.5 10.2-7.5 10.2z"/></svg><span>' + fmt(c.likes + (on ? 1 : 0)) + '</span></button></div>';
|
||||
}
|
||||
function add(k) {
|
||||
ls.insertAdjacentHTML('beforeend', ALL.slice(shown, shown + k).map(item).join(''));
|
||||
shown = Math.min(ALL.length, shown + k); more.hidden = shown >= ALL.length;
|
||||
}
|
||||
more.addEventListener('click', function () { add(30); });
|
||||
ls.addEventListener('click', function (e) {
|
||||
var b = e.target.closest('[data-wcl]'); if (!b) return;
|
||||
var k = b.dataset.wcl, c = ALL.filter(function (x) { return x.key === k; })[0]; if (!c) return;
|
||||
if (LIKE[k]) delete LIKE[k]; else LIKE[k] = 1;
|
||||
try { localStorage.setItem(LK, JSON.stringify(LIKE)); } catch (e2) {}
|
||||
var on = !!LIKE[k]; b.classList.toggle('on', on); b.querySelector('span').textContent = fmt(c.likes + (on ? 1 : 0));
|
||||
if (on && navigator.vibrate) navigator.vibrate(8);
|
||||
});
|
||||
/* 上滑过半:面板压暗星空的那层渐变加深,「上滑看看」收起 */
|
||||
box.addEventListener('scroll', function () { box.classList.toggle('up', box.scrollTop > 40); }, { passive: true });
|
||||
/* 进星空页才拉数据;关掉回到顶部 */
|
||||
new MutationObserver(function () {
|
||||
if (page.classList.contains('show')) load(); else { box.scrollTop = 0; box.classList.remove('up'); }
|
||||
}).observe(page, { attributes: true, attributeFilter: ['class'] });
|
||||
if (page.classList.contains('show')) load();
|
||||
})();
|
||||
Reference in New Issue
Block a user