Files
Alfred/src/web/features/chat/parts/TextPart.tsx
lanyuanxiaoyao eb93de52d8 fix: 修正 markdown-to-jsx 导入方式 + 新增 formatDateLabel 日期工具函数
- TextPart: default import → named import
- MaterialCard: 使用 formatDateLabel 显示今天/昨天/日期
- 清理旧测试文件,新增 ResourceTable 测试
2026-06-03 21:08:00 +08:00

37 lines
938 B
TypeScript

import { Typography } from "antd";
import { Markdown } from "markdown-to-jsx/react";
import type { PartProps } from "./types";
import { CodeBlock } from "./CodeBlock";
import { MarkdownTable } from "./MarkdownTable";
interface TextPartProps extends PartProps {
isStreaming: boolean;
role: string;
}
export function TextPart({ isStreaming, part, role }: TextPartProps) {
const text = typeof part["text"] === "string" ? part["text"] : "";
return (
<div className="part-body">
{role === "user" ? (
<Typography.Paragraph className="message-body-text">{text}</Typography.Paragraph>
) : (
<Markdown
options={{
optimizeForStreaming: isStreaming,
overrides: {
pre: { component: CodeBlock, props: { isStreaming } },
table: MarkdownTable,
},
}}
>
{text}
</Markdown>
)}
</div>
);
}