feat: collapse replies (show last 5, 继续此消息串)

When >5 replies, show the latest 5 and a '继续此消息串 (还有N条回复)' button. Click to expand all. Discourse-style folding.
This commit is contained in:
lezi-fun committed 2026-08-11 22:03:12 +08:00
1 parent b18cd05455
commit a57d29ceed
3 files changed
+39 -1

No files matched your search

+22
View File
@@ -3179,3 +3179,25 @@ a.btn-secondary {
flex-wrap: wrap;
}
}
/* ===== 继续此消息串(Discourse 风格折叠) ===== */
.reply-show-more {
display: flex;
align-items: center;
gap: 6px;
margin: 12px 0 4px;
padding: 8px 16px;
background: var(--glass-bg);
border: 1px solid var(--glass-border);
border-radius: var(--radius-sm);
color: var(--primary);
font-size: 13px;
font-weight: 500;
cursor: pointer;
transition: all 0.15s;
}
.reply-show-more:hover {
background: var(--primary);
color: #fff;
border-color: var(--primary);
}
+5
View File
@@ -22,6 +22,11 @@ const PATHS = {
<path d="M9 14l-4-4 4-4"/><path d="M5 10h11a4 4 0 0 1 4 4v0"/>
</>
),
chevronDown: (
<>
<path d="M6 9l6 6 6-6"/>
</>
),
settings: (
<>
<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>
+12 -1
View File
@@ -94,6 +94,12 @@ export default function ReplyList({ postId, onRefresh }) {
// 正在回复的目标回复对象(用于显示 @用户名)
const replyToObj = replyTo ? replies.find((x) => x.id === replyTo) : null;
// 回复折叠:默认只显示最近 5 条,更多则显示"继续此消息串"
const SHOW_N = 5;
const [showAllReplies, setShowAllReplies] = useState(false);
const visibleReplies = showAllReplies ? replies : replies.slice(-SHOW_N);
const hiddenCount = replies.length - visibleReplies.length;
return (
<>
<div className="post-reply-count" style={{ marginTop: 20, fontSize: 14, color: '#64748b' }}>
@@ -103,7 +109,7 @@ export default function ReplyList({ postId, onRefresh }) {
{replies.length === 0 ? (
<div style={{ color: '#94a3b8', padding: '20px 0', textAlign: 'center' }}><Icon name="message" size={16} /> 还没有回复,快来发表第一条回复吧</div>
) : (
replies.map((r) => {
visibleReplies.map((r) => {
const rTime = r.created_at ? new Date(r.created_at).toLocaleString('zh-CN') : '';
const nestDepth = Math.min(replyDepths[r.id] || 0, 5);
return (
@@ -143,6 +149,11 @@ export default function ReplyList({ postId, onRefresh }) {
);
})
)}
{hiddenCount > 0 && (
<button className="reply-show-more" onClick={() => setShowAllReplies(true)}>
<Icon name="chevronDown" size={13} /> 继续此消息串(还有 {hiddenCount} 条回复)
</button>
)}
</div>
<div id="replyArea" ref={replyAreaRef} style={{ marginTop: 24, borderTop: '1px solid var(--border)', paddingTop: 20 }}>