From 891f09aa0d99233d9af1c402b7176795a35e79bd Mon Sep 17 00:00:00 2001 From: alboped Date: Fri, 24 Apr 2026 04:39:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(chat):=20=E6=B6=88=E6=81=AF=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=9B=9E=E5=88=B0=E5=BA=95=E9=83=A8=E4=B8=8E=E8=B4=B4?= =?UTF-8?q?=E5=BA=95=E6=BB=9A=E5=8A=A8=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 非底部时显示悬浮回到底部按钮,点击平滑滚底并隐藏 - 仅在已处于底部附近时随新消息自动贴底,避免打断上翻阅读 - 按钮使用原生圆钮并相对输入区 max-w-4xl 定位,避免 AntD 按钮宽条问题 - 同步 lucide-react 依赖及流式代码块、全局样式等小改动 Made-with: Cursor --- package.json | 1 + src/components/StreamMessage.tsx | 4 +- src/index.css | 6 + src/pages/index.tsx | 542 +++++++++++++++++-------------- yarn.lock | 5 + 5 files changed, 312 insertions(+), 246 deletions(-) diff --git a/package.json b/package.json index e59f1aa..1a58105 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "axios": "^1.15.0", "highlight.js": "^11.11.1", "katex": "^0.16.45", + "lucide-react": "^1.9.0", "react": "^19.2.4", "react-dom": "^19.2.4", "react-markdown": "^10.1.0", diff --git a/src/components/StreamMessage.tsx b/src/components/StreamMessage.tsx index f3dcea8..3868e84 100644 --- a/src/components/StreamMessage.tsx +++ b/src/components/StreamMessage.tsx @@ -1,6 +1,6 @@ import { useState } from "react"; -import { CheckOutlined, CopyOutlined } from "@ant-design/icons"; import { Button, message } from "antd"; +import { Check, Copy } from "lucide-react"; import ReactMarkdown from "react-markdown"; import remarkGfm from "remark-gfm"; import remarkMath from "remark-math"; @@ -47,7 +47,7 @@ function MarkdownPreBlock(props: { children: ReactNode }) { {(!collapsed || isMobile) && ( - - @@ -696,10 +730,10 @@ export default function HomePage() { width={260} collapsedWidth={72} theme="light" - className="!min-h-0 !h-full !overflow-hidden !bg-[var(--ds-bg-sider)] !border-r !border-[var(--ds-border)]" + className="!min-h-0 !h-full !overflow-hidden !bg-[var(--ds-bg-sider)]" >
-
+
@@ -733,11 +767,11 @@ export default function HomePage() { className="text-neutral-500 hover:bg-black/5!" icon={ isMobile ? ( - + ) : collapsed ? ( - + ) : ( - + ) } onClick={() => { @@ -770,203 +804,223 @@ export default function HomePage() {
-
+
- {messages.map((item) => ( -
+ {!activeSessionId && messages.length === 0 ? ( +

你好,我是 ChatOne

+ ) : ( + messages.map((item) => (
- {item.role === "user" && ( -
- {item.content} -
- )} - {item.role === "assistant" && item.thinking && ( - - - 已思考(用时约 2 秒) - - ), - children: ( - - {item.thinking} - - ), - }, - ]} - /> - )} - {item.role === "assistant" && - (item.content ? ( - - ) : ( -
- - - - - +
+ {item.role === "user" && ( +
+ {item.content}
- ))} - {item.role === "assistant" && item.content && ( - <> -

- 本回答由 AI 生成,内容仅供参考,请仔细甄别。 -

-
- -
+ + )} + {item.role === "user" && ( +
+
- - )} - {item.role === "user" && ( -
-
- )} + )} +
-
- ))} + )) + )}
-
- setInputValue(e.target.value)} - onPressEnter={(e) => { - if (e.shiftKey) return; - e.preventDefault(); - void sendMessage(); - }} - placeholder="给 ChatOne 发送消息" - variant="borderless" - autoSize={{ minRows: 2, maxRows: 8 }} - className="!px-1 !text-[15px] placeholder:text-neutral-400" - /> -
-
- - -
-
- + )} +
+ setInputValue(e.target.value)} + onPressEnter={(e) => { + if (e.shiftKey) return; + e.preventDefault(); + void sendMessage(); + }} + placeholder="给 ChatOne 发送消息" + variant="borderless" + autoSize={{ minRows: 2, maxRows: 8 }} + className="!px-1 !text-[15px] placeholder:text-neutral-400" + /> +
+
+ + +
+
+
diff --git a/yarn.lock b/yarn.lock index 61b3ba1..401548e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2932,6 +2932,11 @@ lru-cache@^5.1.1: dependencies: yallist "^3.0.2" +lucide-react@^1.9.0: + version "1.9.0" + resolved "https://registry.npmmirror.com/lucide-react/-/lucide-react-1.9.0.tgz#3c8324e6b574131624c1869cbd38829d9c659627" + integrity sha512-6qVAmbgCjcJz7sAGSPSSJ++RAwjlK2XCbRrZKv63Ciko1KT8jX0//CXxgI3jg2HlJu8tADqdYlNDebmYjeoruA== + magic-string@^0.30.21: version "0.30.21" resolved "https://registry.npmmirror.com/magic-string/-/magic-string-0.30.21.tgz#56763ec09a0fa8091df27879fd94d19078c00d91"