专题页点回复时底部出「回复 XX:原文」提示条(可取消);广场评论孕周挪到名字右边小胶囊,同专题页(v26110244)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -39,6 +39,8 @@
|
||||
'.tr-tx span{font-size:12px;color:#86909C;display:flex;gap:6px;align-items:center}.tr-tx em{font-style:normal;font-size:11px;font-weight:600;color:var(--tt-c,#18A058)}.tr-tx em::after{content:"·";margin-left:6px;color:#C9CDD4;font-weight:400}.tr-go{color:#C9CDD4;font-size:18px}' +
|
||||
/* 11-03 用户:评论输入框别放在评论区最上面,浮在页面底部 */
|
||||
'.tc-in{position:fixed;left:0;right:0;bottom:0;z-index:30;display:flex;gap:8px;align-items:flex-end;padding:8px 12px calc(8px + env(safe-area-inset-bottom));background:rgba(255,255,255,.97);border-top:1px solid #F0F1F3;box-shadow:0 -6px 18px -14px rgba(31,35,41,.3)}' +
|
||||
/* 11-03 用户:点回复时底部要明显显示在回复谁(同孕妈广场) */
|
||||
'.tc-rto{position:absolute;left:0;right:0;bottom:100%;display:flex;align-items:center;gap:8px;padding:8px 14px;background:#F7F8FA;border-top:1px solid #EEF0F3;font-size:12.5px;color:#86909C}.tc-rto[hidden]{display:none}.tc-rto span{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tc-rto b{color:#1F2329;font-weight:600}.tc-in .tc-rto button{flex:none;width:22px;height:22px;padding:0;border:0;border-radius:50%;background:#E5E6EB;color:#86909C;font-size:14px;line-height:22px}' +
|
||||
'.tc-in label{flex:1;min-width:0;display:flex;padding:6px 14px;border-radius:20px;background:#F2F3F5}' +
|
||||
'.tc-in textarea{flex:1;min-width:0;border:0;background:transparent;resize:none;font-size:14px;line-height:1.6;font-family:inherit;color:#1F2329;height:24px;max-height:96px;outline:0;padding:0}' +
|
||||
'.tc-in button{flex:0 0 auto;height:36px;padding:0 16px;border:0;border-radius:99px;background:var(--tt-c,#18A058);color:#fff;font-size:13.5px;font-weight:700}.tc-in button:disabled{opacity:.35}' +
|
||||
@@ -66,7 +68,7 @@
|
||||
function getJSON(u) { return fetch(u, { cache: 'no-cache' }).then(function (r) { if (!r.ok) throw r.status; return r.json(); }); }
|
||||
|
||||
function related(box) {
|
||||
getJSON('../_shared/idx.json?v=26110243').then(function (idx) {
|
||||
getJSON('../_shared/idx.json?v=26110244').then(function (idx) {
|
||||
var me = null; idx.forEach(function (x) { if (x[0] === SLUG) me = x; });
|
||||
var tag = me ? me[2] : '', h = 0; for (var i = 0; i < SLUG.length; i++) h = (h * 31 + SLUG.charCodeAt(i)) >>> 0;
|
||||
var rest = idx.filter(function (x) { return x[0] !== SLUG; });
|
||||
@@ -123,7 +125,8 @@
|
||||
[].forEach.call(box.querySelectorAll('[data-rk]'), function (el) {
|
||||
el.addEventListener('click', function (e) {
|
||||
if (e.target.closest('.tc-lk') || (el.classList.contains('tc-b') && e.target.closest('.tc-r'))) return;
|
||||
REPLY = { k: el.dataset.rk, n: el.dataset.rn }; ta.placeholder = '回复 ' + REPLY.n + ':'; ta.focus();
|
||||
var tx = el.classList.contains('tc-b') ? (el.querySelector('.tc-t') || {}).textContent : el.textContent.replace(/^[^:]*:/, '');
|
||||
setReply({ k: el.dataset.rk, n: el.dataset.rn }, tx); ta.focus();
|
||||
});
|
||||
});
|
||||
var mo = box.querySelector('.tc-more'); if (mo) mo.addEventListener('click', function () { open = true; paint(); });
|
||||
@@ -133,13 +136,19 @@
|
||||
}
|
||||
/* 底部浮条:整页常驻,发完滚到评论区看到自己那条 */
|
||||
var bar = document.createElement('div'); bar.className = 'tc-in';
|
||||
bar.innerHTML = '<label><textarea rows="1" maxlength="200" placeholder="说说你的情况,和其他妈妈聊聊…"></textarea></label><button type="button" disabled>发布</button>';
|
||||
bar.innerHTML = '<div class="tc-rto" hidden><span></span><button type="button" aria-label="取消回复">×</button></div><label><textarea rows="1" maxlength="200" placeholder="说说你的情况,和其他妈妈聊聊…"></textarea></label><button type="button" disabled>发布</button>';
|
||||
bar.style.setProperty('--tt-c', box.style.getPropertyValue('--tt-c'));
|
||||
document.body.appendChild(bar);
|
||||
var sc = box.parentNode; while (sc && sc !== document.body && !/(auto|scroll)/.test(getComputedStyle(sc).overflowY)) sc = sc.parentNode;
|
||||
sc = sc || document.body; sc.style.paddingBottom = (parseFloat(getComputedStyle(sc).paddingBottom) || 0) + 64 + 'px';
|
||||
var ta = bar.querySelector('textarea'), bt = bar.querySelector('button'), PH = ta.placeholder;
|
||||
ta.addEventListener('blur', function () { setTimeout(function () { if (!ta.value.trim()) { REPLY = null; ta.placeholder = PH; } }, 150); });
|
||||
var ta = bar.querySelector('textarea'), bt = bar.querySelector('label + button'), PH = ta.placeholder, rto = bar.querySelector('.tc-rto');
|
||||
function setReply(r, tx) {
|
||||
REPLY = r; ta.placeholder = r ? '回复 ' + r.n + ':' : PH; rto.hidden = !r;
|
||||
if (r) rto.querySelector('span').innerHTML = '回复 <b>' + esc(r.n) + '</b>' + (tx ? ':' + esc(String(tx).trim().slice(0, 40)) : '');
|
||||
}
|
||||
rto.querySelector('button').addEventListener('mousedown', function (e) { e.preventDefault(); });
|
||||
rto.querySelector('button').addEventListener('click', function () { setReply(null); });
|
||||
ta.addEventListener('blur', function () { setTimeout(function () { if (!ta.value.trim()) setReply(null); }, 150); });
|
||||
ta.addEventListener('input', function () { bt.disabled = !ta.value.trim(); ta.style.height = '24px'; ta.style.height = Math.min(96, ta.scrollHeight) + 'px'; });
|
||||
bt.addEventListener('click', function () {
|
||||
var v = ta.value.trim(); if (!v || bt.busy) return;
|
||||
@@ -153,7 +162,7 @@
|
||||
bt.busy = false;
|
||||
if (!j || j.code !== 200) { bt.disabled = !ta.value.trim(); toast((j && j.message) || '没发出去,稍后再试'); return; }
|
||||
RC.mine.unshift(j.result);
|
||||
var wasReply = !!REPLY; REPLY = null; ta.placeholder = PH;
|
||||
var wasReply = !!REPLY; setReply(null);
|
||||
ta.value = ''; ta.style.height = '24px'; bt.disabled = true; ta.blur(); paint();
|
||||
if (!wasReply) box.scrollIntoView({ block: 'start', behavior: 'smooth' });
|
||||
toast(wasReply ? '回复已提交,审核通过后大家就能看到' : '已提交,审核通过后大家就能看到');
|
||||
@@ -166,7 +175,7 @@
|
||||
}
|
||||
fetch(API + '/comments?kind=topic&target=' + encodeURIComponent(SLUG) + (OID ? '&openid=' + encodeURIComponent(OID) : ''))
|
||||
.then(function (r) { return r.json(); }).then(function (j) { if (j && j.code === 200) { RC = j.result; paint(); } }).catch(function () {});
|
||||
getJSON('../_shared/cm/' + SLUG + '.json?v=26110243').then(function (d) { L = d.c || []; paint(); }).catch(function () { paint(); });
|
||||
getJSON('../_shared/cm/' + SLUG + '.json?v=26110244').then(function (d) { L = d.c || []; paint(); }).catch(function () { paint(); });
|
||||
}
|
||||
|
||||
function extras(el) {
|
||||
|
||||
Reference in New Issue
Block a user