import ReactMarkdown from 'react-markdown' import remarkGfm from 'remark-gfm' import rehypeHighlight from 'rehype-highlight' import { cn } from '@/lib/utils' /** Markdown 渲染组件:支持 GFM(表格/列表/删除线)+ 代码高亮。 * 用于 AI 回复的富文本展示,替代纯 whitespace-pre-wrap。 * 流式输出时传入 streaming=true 显示光标。 */ export function Markdown({ content, streaming, className, }: { content: string streaming?: boolean className?: string }) { return (
{children}
),
// 行内代码:浅灰背景
code: ({ children, className, ...props }) => {
const isInline = !className?.includes('language-')
if (isInline) {
return (
{children}
)
}
return (
{children}
)
},
// 表格:外层包裹 overflow-x-auto 防止小屏溢出
table: ({ children, ...props }) => (