diff --git a/src/components/ConversationCard/index.jsx b/src/components/ConversationCard/index.jsx index 17bedec..f0720a7 100644 --- a/src/components/ConversationCard/index.jsx +++ b/src/components/ConversationCard/index.jsx @@ -68,6 +68,14 @@ function ConversationCard(props) { ) const config = useConfig() + document.addEventListener('keydown', function (event) { + if (event.key === 'Escape' || event.keyCode === 27) { + // 关闭窗口代码 + port.disconnect() + if (props.onClose) props.onClose() + } + }) + useEffect(() => { if (props.onUpdate) props.onUpdate(port, session, conversationItemData) }, [session, conversationItemData]) @@ -197,7 +205,10 @@ function ConversationCard(props) { return (