悄悄话留言标题后小头像:最新留言真人头像排前,补位随机且每 5 秒换一个,60 秒拉新留言 (v26110637)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1059,7 +1059,7 @@ html.night .gtg button.on{background:#F2725B;border-color:#F2725B;color:#fff}
|
||||
var CMD = null, CMERR = false;
|
||||
/* 头像编码:数字 = av/NNNN.webp(旧代码头像);'av:c012' = av/c012.webp(卡通/可爱卡通);'/…' = 站内绝对路径(内置头像库 /_bridge/avatars/);其余 = assets/img/mom/xxx.jpg */
|
||||
var avP = function (a) { return typeof a === 'number' ? 'av/' + ('000' + a).slice(-4) + '.webp' : a.indexOf('av:') === 0 ? 'av/' + a.slice(3) + '.webp' : a.charAt(0) === '/' ? a : '../assets/img/mom/' + a + '.jpg'; };
|
||||
fetch('cm.json?v=26110636').then(function (r) { return r.json(); }).then(function (j) {
|
||||
fetch('cm.json?v=26110637').then(function (r) { return r.json(); }).then(function (j) {
|
||||
CMD = j; if (openId && NBY[openId]) { renderComments(NBY[openId]); syncBar(NBY[openId]); }
|
||||
}).catch(function () { CMERR = true; if (openId && NBY[openId]) renderComments(NBY[openId]); });
|
||||
function commentsOf(n) {
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
<title>兜爸心选 · 孕育陪伴</title>
|
||||
<!-- 11-04 UGC 总开关(孕妈广场 + 测一测,后台 /box_bm/plaza 顶部切换),见 js/ugc.js -->
|
||||
<script src="js/ugc.js?v=26110487"></script>
|
||||
<!-- V:26110636 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 -->
|
||||
<!-- V:26110637 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 -->
|
||||
<link rel="stylesheet" href="mama-box.css">
|
||||
<link rel="stylesheet" href="night.css?v=26110608">
|
||||
<link rel="stylesheet" href="js/wh-cm.css?v=26110636">
|
||||
<link rel="stylesheet" href="js/wh-cm.css?v=26110637">
|
||||
<!-- 11-04 用户:「顶部图片上的倒计时先删除掉」→ 不加载 hero-cd.css / hero-cd.js(文件留着,加回这两行即恢复),头图回到原样式 -->
|
||||
<!-- 夜晚模式:首屏绘制前就按上次的选择加 class,避免先白后黑闪一下(开关在首页右上角 #nightBtn,逻辑见 app.js) -->
|
||||
<script>try{if(localStorage.getItem('mmbox.night.v1')==='1'){document.documentElement.classList.add('night');document.querySelector('meta[name=theme-color]').content='#2A2340'}}catch(e){}</script>
|
||||
@@ -2680,7 +2680,7 @@ html.night .rs-pan .rp-card{background:rgba(255,255,255,.06);border-color:rgba(2
|
||||
<script src="guangchang/topics.js?v=26110487"></script>
|
||||
<script src="js/ava-pool.js?v=26110487"></script> <!-- 11-05 装饰头像分配表(各模块互不重复) -->
|
||||
<script src="js/wh-themes.js?v=26110609"></script>
|
||||
<script src="js/wh-cm.js?v=26110636" defer></script>
|
||||
<script src="js/wh-cm.js?v=26110637" defer></script>
|
||||
<script src="js/app.js"></script>
|
||||
<script src="js/kit.js?v=26110605"></script>
|
||||
<!-- 11-05 用户:孕期百问加上跟趣味小测试一样的底部 Tab(孕期百问 / 记一下 / 返回首页)。挂在 #detailQA 里,面板关着时跟着滑出屏外;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
|
||||
var VER = '26110636';
|
||||
var VER = '26110637';
|
||||
const $ = (s, c) => (c || document).querySelector(s);
|
||||
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
|
||||
|
||||
|
||||
@@ -168,3 +168,5 @@ p.wcm-mf{display:block;color:#FFC07A}
|
||||
.wcs-avs:empty{display:none}
|
||||
.wcs-avs img{width:18px;height:18px;border-radius:50%;object-fit:cover;border:1.5px solid #3A2C57;background:#4A3A6A}
|
||||
.wcs-avs img+img{margin-left:-7px}
|
||||
.wcs-avs img{transition:transform .26s ease,opacity .26s ease}.wcs-avs img.out{transform:scale(.4);opacity:0}.wcs-avs img.nw{animation:wavIn .45s cubic-bezier(.3,1.6,.5,1)}
|
||||
@keyframes wavIn{from{transform:scale(.3);opacity:0}}
|
||||
|
||||
46
js/wh-cm.js
46
js/wh-cm.js
@@ -69,7 +69,7 @@
|
||||
function repOf(c, me) { return { p: c.parent, n: me ? '我' : (c.nickname || '孕妈'), me: me, to: c.parentName, t: c.text, ts: c.at, st: me ? c.status : '' }; }
|
||||
function load() {
|
||||
if (loading || SIM) return; loading = true;
|
||||
fetch('guangchang/cm.json?v=26110636').then(function (r) { return r.json(); }).then(function (j) {
|
||||
fetch('guangchang/cm.json?v=26110637').then(function (r) { return r.json(); }).then(function (j) {
|
||||
var PP = j.p;
|
||||
SIM = (j.c[PID] || []).map(function (c, k) {
|
||||
var p = PP[c[0]];
|
||||
@@ -87,6 +87,7 @@
|
||||
if (R.starLikes) STAR_N = R.starLikes;
|
||||
/* 11-07 用户改:别人的只出审核通过的;自己发的审核中也显示(标「审核中」,只有自己看得到),没通过的不出 */
|
||||
var mine = (R.mine || []).filter(function (c) { return c.status !== 'rejected'; });
|
||||
avRealFrom((R.list || []).filter(top).concat(mine.filter(function (c) { return top(c) && c.status === 'approved'; })));
|
||||
REAL = (R.list || []).filter(top).map(realOf).concat(mine.filter(top).map(function (c) { var o = realOf(c); o.n = '我'; o.me = 1; o.st = c.status; return o; }));
|
||||
RREP = (R.list || []).filter(function (c) { return !top(c); }).map(function (c) { return repOf(c, 0); })
|
||||
.concat(mine.filter(function (c) { return !top(c); }).map(function (c) { return repOf(c, 1); }));
|
||||
@@ -179,12 +180,47 @@
|
||||
function total() { return (REAL ? REAL.length : 0) + (SIM ? SIM.length : 0); }
|
||||
function paintGo() {
|
||||
document.getElementById('wcmN').textContent = total() ? total() + ' 条' : '';
|
||||
/* 11-07 用户:「妈妈们的留言」后面加 6~8 个小头像 —— 取最热的 8 位 */
|
||||
var av = document.getElementById('wcmAv');
|
||||
if (av && SIM && SIM.length && !av.firstChild) av.innerHTML = SIM.slice().sort(function (a, b) { return b.likes - a.likes; }).slice(0, 8)
|
||||
.map(function (c) { return '<img src="' + esc(c.av) + '" alt="" onerror="this.remove()">'; }).join('');
|
||||
avPaint();
|
||||
document.getElementById('wcmRuleN').textContent = STAR_N;
|
||||
}
|
||||
/* ---------- 「妈妈们的留言」后面的 8 个小头像(11-07 用户:随时换一些,有人新留言就变) ----------
|
||||
最前面 = 最新留言(已通过)的真人头像,按时间倒序;不够 8 个用模拟留言的头像补(每次打开随机洗一遍);
|
||||
补位的每 5 秒换掉一个;页面开着时每 60 秒悄悄拉一次留言,只更新头像,不动正在看的列表。 */
|
||||
var AVN = 8, AVPOOL = null, AVREAL = [], avPi = 0;
|
||||
function avUniq(arr) { var seen = {}; return arr.filter(function (u) { if (!u || seen[u]) return false; seen[u] = 1; return true; }); }
|
||||
function avPaint() {
|
||||
var box = document.getElementById('wcmAv'); if (!box || !SIM || !SIM.length) return;
|
||||
if (!AVPOOL) {
|
||||
AVPOOL = avUniq(SIM.map(function (c) { return c.av; }));
|
||||
for (var i = AVPOOL.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)), t = AVPOOL[i]; AVPOOL[i] = AVPOOL[j]; AVPOOL[j] = t; }
|
||||
}
|
||||
var real = avUniq(AVREAL).slice(0, AVN), fill = [];
|
||||
while (real.length + fill.length < AVN && avPi < AVPOOL.length * 2) { var u = AVPOOL[avPi++ % AVPOOL.length]; if (real.indexOf(u) < 0 && fill.indexOf(u) < 0) fill.push(u); }
|
||||
var old = [].map.call(box.children, function (x) { return x.getAttribute('src'); });
|
||||
box.innerHTML = real.concat(fill).map(function (u, k) {
|
||||
return '<img src="' + esc(u) + '" alt=""' + (k < real.length ? ' data-r="1"' : '') + (old.indexOf(u) < 0 && old.length ? ' class="nw"' : '') + ' onerror="this.remove()">';
|
||||
}).join('');
|
||||
}
|
||||
function avRealFrom(list) {
|
||||
AVREAL = list.filter(function (c) { return c.status ? c.status === 'approved' : true; })
|
||||
.sort(function (a, b) { return (b.at || 0) - (a.at || 0); }).map(function (c) { return c.avatar; });
|
||||
}
|
||||
setInterval(function () { /* 补位的轮换 */
|
||||
var box = document.getElementById('wcmAv'); if (!box || document.hidden || !AVPOOL || !page.classList.contains('show')) return;
|
||||
var slots = [].filter.call(box.children, function (x) { return !x.dataset.r; }); if (!slots.length) return;
|
||||
var have = [].map.call(box.children, function (x) { return x.getAttribute('src'); }), u, n = 0;
|
||||
do { u = AVPOOL[avPi++ % AVPOOL.length]; } while (have.indexOf(u) >= 0 && ++n < AVPOOL.length);
|
||||
var el = slots[Math.floor(Math.random() * slots.length)];
|
||||
el.classList.add('out');
|
||||
setTimeout(function () { el.src = u; el.classList.remove('out'); el.classList.add('nw'); setTimeout(function () { el.classList.remove('nw'); }, 500); }, 260);
|
||||
}, 5000);
|
||||
setInterval(function () { /* 新留言 → 头像跟着变 */
|
||||
if (document.hidden || !page.classList.contains('show') || !SIM) return;
|
||||
fetch('/api/mp/public/mama-box/plaza/comments?kind=post&target=' + encodeURIComponent(PID)).then(function (r) { return r.json(); }).then(function (j) {
|
||||
var R = j && j.code === 200 && j.result; if (!R) return;
|
||||
var k0 = AVREAL.join('|'); avRealFrom((R.list || []).filter(top)); if (AVREAL.join('|') !== k0) avPaint();
|
||||
}).catch(function () {});
|
||||
}, 60000);
|
||||
function build() {
|
||||
if (!SIM || !REAL) return;
|
||||
SIM.forEach(simStar);
|
||||
|
||||
Reference in New Issue
Block a user