Commit ede6825f by 1808837298@qq.com

feat: 优化playground样式

parent 9962d036
...@@ -144,7 +144,7 @@ const Playground = () => { ...@@ -144,7 +144,7 @@ const Playground = () => {
source.addEventListener("error", (e) => { source.addEventListener("error", (e) => {
generateMockResponse(e.data) generateMockResponse(e.data)
completeMessage(); completeMessage('error')
}); });
source.addEventListener("readystatechange", (e) => { source.addEventListener("readystatechange", (e) => {
...@@ -206,12 +206,17 @@ const Playground = () => { ...@@ -206,12 +206,17 @@ const Playground = () => {
}); });
}, [getSystemMessage]); }, [getSystemMessage]);
const completeMessage = useCallback(() => { const completeMessage = useCallback((status = 'complete') => {
// console.log("Complete Message: ", status)
setMessage((prevMessage) => { setMessage((prevMessage) => {
const lastMessage = prevMessage[prevMessage.length - 1]; 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 [ return [
...prevMessage.slice(0, -1), ...prevMessage.slice(0, -1),
{ ...lastMessage, status: 'complete' } { ...lastMessage, status: status }
]; ];
}); });
}, []) }, [])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment