mirror of
https://gitee.com/JavaLionLi/plus-ui.git
synced 2026-09-15 00:25:07 +08:00
fix 修复 ai聊天 第一句话不展示问题
This commit is contained in:
parent
682b931931
commit
889eb0e9ed
@ -210,14 +210,6 @@ export default function AiChatPage() {
|
|||||||
}
|
}
|
||||||
}, [agents, currentAgentId]);
|
}, [agents, currentAgentId]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
abortRef.current?.abort();
|
|
||||||
finishSending();
|
|
||||||
if (!currentConversationId) {
|
|
||||||
setMessages([]);
|
|
||||||
}
|
|
||||||
}, [currentConversationId, finishSending]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentConversationId && conversationMessagesQuery.data && !sending) {
|
if (currentConversationId && conversationMessagesQuery.data && !sending) {
|
||||||
setMessages(conversationMessagesQuery.data);
|
setMessages(conversationMessagesQuery.data);
|
||||||
@ -242,15 +234,41 @@ export default function AiChatPage() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const selectAgent = (agentId: string | number) => {
|
const selectAgent = (agentId: string | number) => {
|
||||||
setCurrentAgentId(Number(agentId));
|
const nextAgentId = Number(agentId);
|
||||||
|
if (currentAgentId === nextAgentId) return;
|
||||||
|
abortRef.current?.abort();
|
||||||
|
finishSending();
|
||||||
|
setCurrentAgentId(nextAgentId);
|
||||||
setCurrentConversationId('');
|
setCurrentConversationId('');
|
||||||
|
setMessages([]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const startNewConversation = () => {
|
||||||
|
abortRef.current?.abort();
|
||||||
|
finishSending();
|
||||||
|
setCurrentConversationId('');
|
||||||
|
setMessages([]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const selectConversation = (conversationId: string | number) => {
|
||||||
|
const nextConversationId = String(conversationId);
|
||||||
|
if (currentConversationId === nextConversationId) return;
|
||||||
|
abortRef.current?.abort();
|
||||||
|
finishSending();
|
||||||
|
setCurrentConversationId(nextConversationId);
|
||||||
|
setMessages([]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeConversation = async (conversationId: string) => {
|
const removeConversation = async (conversationId: string) => {
|
||||||
if (!currentAgent) return;
|
if (!currentAgent) return;
|
||||||
await deleteConversation(currentAgent.id, conversationId);
|
await deleteConversation(currentAgent.id, conversationId);
|
||||||
message.success('删除成功');
|
message.success('删除成功');
|
||||||
if (currentConversationId === conversationId) setCurrentConversationId('');
|
if (currentConversationId === conversationId) {
|
||||||
|
abortRef.current?.abort();
|
||||||
|
finishSending();
|
||||||
|
setCurrentConversationId('');
|
||||||
|
setMessages([]);
|
||||||
|
}
|
||||||
await refreshConversationData(currentAgent.id);
|
await refreshConversationData(currentAgent.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -390,7 +408,7 @@ export default function AiChatPage() {
|
|||||||
block
|
block
|
||||||
icon={<PlusOutlined />}
|
icon={<PlusOutlined />}
|
||||||
disabled={!agents.length}
|
disabled={!agents.length}
|
||||||
onClick={() => setCurrentConversationId('')}
|
onClick={startNewConversation}
|
||||||
>
|
>
|
||||||
新对话
|
新对话
|
||||||
</Button>
|
</Button>
|
||||||
@ -416,7 +434,7 @@ export default function AiChatPage() {
|
|||||||
className="ai-chat-conversations"
|
className="ai-chat-conversations"
|
||||||
items={conversationItems}
|
items={conversationItems}
|
||||||
activeKey={currentConversationId}
|
activeKey={currentConversationId}
|
||||||
onActiveChange={key => setCurrentConversationId(String(key))}
|
onActiveChange={selectConversation}
|
||||||
menu={item => ({
|
menu={item => ({
|
||||||
items: [{ key: 'delete', label: '删除', icon: <DeleteOutlined />, danger: true }],
|
items: [{ key: 'delete', label: '删除', icon: <DeleteOutlined />, danger: true }],
|
||||||
onClick: ({ domEvent }) => {
|
onClick: ({ domEvent }) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user