mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 21:30:24 +08:00
Improve answer text
This commit is contained in:
@ -74,6 +74,16 @@ class ChatBox extends React.Component {
|
||||
this.setState({inputValue: ""});
|
||||
};
|
||||
|
||||
renderText(text) {
|
||||
const lines = text.split("\n").map((line, index) => (
|
||||
<React.Fragment key={index}>
|
||||
{line}
|
||||
<br />
|
||||
</React.Fragment>
|
||||
));
|
||||
return <div>{lines}</div>;
|
||||
}
|
||||
|
||||
renderList() {
|
||||
if (this.props.messages === undefined || this.props.messages === null) {
|
||||
return (
|
||||
@ -110,7 +120,7 @@ class ChatBox extends React.Component {
|
||||
title={
|
||||
<div style={{fontSize: "16px", fontWeight: "normal", lineHeight: "24px", marginTop: "-15px", marginLeft: "5px", marginRight: "80px"}}>
|
||||
{
|
||||
!item.text.includes("#ERROR#") ? item.text : (
|
||||
!item.text.includes("#ERROR#") ? this.renderText(item.text) : (
|
||||
<Alert message={item.text.slice("#ERROR#: ".length)} type="error" showIcon />
|
||||
)
|
||||
}
|
||||
|
@ -89,6 +89,10 @@ class ChatPage extends BaseListPage {
|
||||
if (lastMessage.author === "AI" && lastMessage.replyTo !== "" && lastMessage.text === "") {
|
||||
let text = "";
|
||||
MessageBackend.getMessageAnswer(lastMessage.owner, lastMessage.name, (data) => {
|
||||
if (data === "") {
|
||||
data = "\n";
|
||||
}
|
||||
|
||||
const lastMessage2 = Setting.deepCopy(lastMessage);
|
||||
text += data;
|
||||
lastMessage2.text = text;
|
||||
|
Reference in New Issue
Block a user