2023-09-14 15:03:37 +08:00
|
|
|
import { Container, createStyles } from "@mantine/core";
|
2023-07-24 09:11:59 +08:00
|
|
|
import React from "react";
|
2023-08-22 14:22:23 +08:00
|
|
|
import { observer } from "mobx-react-lite";
|
2023-08-22 16:14:43 +08:00
|
|
|
import MessageMarkdown from "@/views/components/MessageMarkdown";
|
2023-09-14 15:03:37 +08:00
|
|
|
import { useMst } from "@/views/stores/RootStore";
|
2023-06-05 19:24:08 +08:00
|
|
|
|
2023-08-22 14:22:23 +08:00
|
|
|
interface IProps {
|
|
|
|
messageText: string,
|
|
|
|
messageType: string
|
|
|
|
}
|
|
|
|
|
2023-09-14 15:03:37 +08:00
|
|
|
|
|
|
|
const useStyles = createStyles((theme, options:any) => ({
|
|
|
|
bodyWidth:{
|
|
|
|
width: options.chatPanelWidth - 20,
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
2023-08-22 14:22:23 +08:00
|
|
|
const MessageBody = observer((props: IProps) => {
|
2023-06-28 17:09:27 +08:00
|
|
|
const { messageText, messageType } = props;
|
2023-09-14 15:03:37 +08:00
|
|
|
const { chat } = useMst();
|
|
|
|
const {classes} = useStyles({
|
|
|
|
chatPanelWidth:chat.chatPanelWidth
|
|
|
|
});
|
2023-06-05 19:24:08 +08:00
|
|
|
return (
|
2023-06-28 17:09:27 +08:00
|
|
|
messageType === 'bot'
|
2023-09-14 15:03:37 +08:00
|
|
|
? <MessageMarkdown className={classes.bodyWidth}>{messageText}</MessageMarkdown>
|
2023-07-06 06:12:55 +08:00
|
|
|
: <Container
|
|
|
|
sx={{
|
|
|
|
margin: 0,
|
|
|
|
padding: 0,
|
|
|
|
pre: {
|
|
|
|
whiteSpace: 'pre-wrap',
|
|
|
|
wordBreak: 'break-word',
|
|
|
|
},
|
|
|
|
}}>
|
|
|
|
<pre>{messageText}</pre>
|
|
|
|
</Container>
|
2023-06-05 19:24:08 +08:00
|
|
|
);
|
2023-08-22 14:22:23 +08:00
|
|
|
});
|
2023-06-05 19:24:08 +08:00
|
|
|
|
2023-08-21 14:07:11 +08:00
|
|
|
export default MessageBody;
|