feat: antd 主题改造 — 启用 cssVar、纯黑白 colorPrimary、统一 sidebar/滚动条/按钮样式

This commit is contained in:
2026-06-05 16:01:54 +08:00
parent db40d04dc5
commit 85abc2a515
10 changed files with 88 additions and 70 deletions

View File

@@ -1,7 +1,7 @@
import type { ReactNode } from "react";
import { CopyOutlined } from "@ant-design/icons";
import { Button, message } from "antd";
import { App, Button } from "antd";
import { useCallback, useEffect, useState } from "react";
import { codeToHtml } from "shiki";
@@ -14,6 +14,7 @@ interface CodeBlockProps {
}
export function CodeBlock({ children, className: _className, isStreaming }: CodeBlockProps) {
const { message } = App.useApp();
const isDark = useIsDark();
const [highlighted, setHighlighted] = useState<null | string>(null);
const { codeText, lang } = extractCode(children);
@@ -23,7 +24,7 @@ export function CodeBlock({ children, className: _className, isStreaming }: Code
() => message.success("已复制"),
() => message.error("复制失败"),
);
}, [codeText]);
}, [codeText, message]);
useEffect(() => {
if (isStreaming || !codeText) return;
@@ -57,7 +58,7 @@ export function CodeBlock({ children, className: _className, isStreaming }: Code
<div className="code-block">
<div className="code-block-header">
<span className="code-block-lang">{lang}</span>
<Button icon={<CopyOutlined />} onClick={handleCopy} size="small" type="text" />
<Button className="btn-dimmed" icon={<CopyOutlined />} onClick={handleCopy} size="small" type="text" />
</div>
{highlighted ? (
<div className="code-block-body" dangerouslySetInnerHTML={{ __html: highlighted }} />