perf: image

This commit is contained in:
archer
2023-06-15 20:06:56 +08:00
parent bb36e637e0
commit 4cbe4ebdc3
7 changed files with 54 additions and 21 deletions

View File

@@ -35,13 +35,17 @@ const Markdown = ({
components={{
pre: 'div',
img({ src = '' }) {
return <MdImage src={src} />;
return isChatting ? <Loading text="图片加载中..." /> : <MdImage src={src} />;
},
code({ node, inline, className, children, ...props }) {
const match = /language-(\w+)/.exec(className || '');
if (match?.[1] === 'mermaid') {
return isChatting ? <Loading /> : <MermaidCodeBlock code={String(children)} />;
return isChatting ? (
<Loading text="导图加载中..." />
) : (
<MermaidCodeBlock code={String(children)} />
);
}
return (