From a57d29ceed8e701d0b9864434e1d802c180d3e71 Mon Sep 17 00:00:00 2001 From: lezi-fun <177434121+lezi-fun@users.noreply.github.com> Date: Tue, 11 Aug 2026 22:03:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20collapse=20replies=20(show=20last=205,?= =?UTF-8?q?=20=E7=BB=A7=E7=BB=AD=E6=AD=A4=E6=B6=88=E6=81=AF=E4=B8=B2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When >5 replies, show the latest 5 and a '继续此消息串 (还有N条回复)' button. Click to expand all. Discourse-style folding. --- app/globals.css | 22 ++++++++++++++++++++++ components/Icons.js | 5 +++++ components/ReplyList.js | 13 ++++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/app/globals.css b/app/globals.css index ebbe058..5f2505b 100644 --- a/app/globals.css +++ b/app/globals.css @@ -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); +} diff --git a/components/Icons.js b/components/Icons.js index c3950a1..ae34f83 100644 --- a/components/Icons.js +++ b/components/Icons.js @@ -22,6 +22,11 @@ const PATHS = { ), + chevronDown: ( + <> + + + ), settings: ( <> diff --git a/components/ReplyList.js b/components/ReplyList.js index 2071ad9..501e819 100644 --- a/components/ReplyList.js +++ b/components/ReplyList.js @@ -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 ( <>
@@ -103,7 +109,7 @@ export default function ReplyList({ postId, onRefresh }) { {replies.length === 0 ? (
还没有回复,快来发表第一条回复吧
) : ( - 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 && ( + + )}