feat: 优化playground样式

This commit is contained in:
1808837298@qq.com 2024-09-27 20:48:55 +08:00
parent f9ba10f180
commit 04a68a85dd

View File

@ -144,7 +144,7 @@ const Playground = () => {
source.addEventListener("error", (e) => {
generateMockResponse(e.data)
completeMessage();
completeMessage('error')
});
source.addEventListener("readystatechange", (e) => {
@ -206,12 +206,17 @@ const Playground = () => {
});
}, [getSystemMessage]);
const completeMessage = useCallback(() => {
const completeMessage = useCallback((status = 'complete') => {
// console.log("Complete Message: ", status)
setMessage((prevMessage) => {
const lastMessage = prevMessage[prevMessage.length - 1];
// only change the status if the last message is not complete and not error
if (lastMessage.status === 'complete' || lastMessage.status === 'error') {
return prevMessage;
}
return [
...prevMessage.slice(0, -1),
{ ...lastMessage, status: 'complete' }
{ ...lastMessage, status: status }
];
});
}, [])