From e3997c661e9434f7b30c06e2294f603d718d5bc1 Mon Sep 17 00:00:00 2001 From: sp mac bookpro 2605 Date: Fri, 29 May 2026 21:48:07 +0800 Subject: [PATCH] style(chat): compact markdown and scroll to latest on refresh --- src/pages/ChatPage.tsx | 13 ++++++++++++- src/styles.css | 22 +++++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/pages/ChatPage.tsx b/src/pages/ChatPage.tsx index 20af8af..e42fbb9 100644 --- a/src/pages/ChatPage.tsx +++ b/src/pages/ChatPage.tsx @@ -73,6 +73,7 @@ export default function ChatPage() { const bodyRef = useRef(null); const abortRef = useRef(null); const autoScrollRef = useRef(true); + const initialScrollDoneRef = useRef(false); // URL 参数 ?session=xxx&msg=yyy useEffect(() => { @@ -145,7 +146,13 @@ export default function ChatPage() { return; } } - scrollBottom(); + if (!initialScrollDoneRef.current) { + autoScrollRef.current = true; + scrollBottom(true); + initialScrollDoneRef.current = true; + } else { + scrollBottom(); + } }); }; @@ -167,6 +174,10 @@ export default function ChatPage() { // eslint-disable-next-line react-hooks/exhaustive-deps }, [id]); + useEffect(() => { + initialScrollDoneRef.current = false; + }, [id]); + useEffect(() => { if (!id) return; loadMessages(); diff --git a/src/styles.css b/src/styles.css index 2acf301..93ed966 100644 --- a/src/styles.css +++ b/src/styles.css @@ -545,24 +545,40 @@ body { .bubble.assistant h4, .bubble.assistant h5, .bubble.assistant h6 { - margin: 0.25em 0 0.125em; + margin: 0.2em 0 0.1em; line-height: 1.3; } .bubble.assistant ol, .bubble.assistant ul { - margin: 0.2em 0; + margin: 0.15em 0; padding-left: 1.25em; } .bubble.assistant li { - margin: 0.08em 0; + margin: 0.05em 0; } .bubble.assistant hr { margin: 0.4em 0; } +.bubble.assistant li > p { + margin: 0.15em 0; +} + +.bubble.assistant blockquote { + margin: 0.2em 0; + padding: 0.2em 0.6em; + border-left: 3px solid var(--color-border); + background: rgba(15, 23, 42, 0.03); + border-radius: 8px; +} + +.bubble.assistant blockquote p { + margin: 0.2em 0; +} + .chat-input-wrapper { width: 100%; max-width: 820px;