diff --git a/packages/plugins/@nocobase/plugin-ai/src/client/ai-employees/chatbox/ChatBox.tsx b/packages/plugins/@nocobase/plugin-ai/src/client/ai-employees/chatbox/ChatBox.tsx index 00453f60948..428912fcb4e 100644 --- a/packages/plugins/@nocobase/plugin-ai/src/client/ai-employees/chatbox/ChatBox.tsx +++ b/packages/plugins/@nocobase/plugin-ai/src/client/ai-employees/chatbox/ChatBox.tsx @@ -7,8 +7,8 @@ * For more information, please refer to: https://www.nocobase.com/agreement. */ -import React, { useEffect, useRef, useState } from 'react'; -import { Layout, Card, Button, Divider, Tooltip } from 'antd'; +import React, { useEffect, useRef } from 'react'; +import { Layout, Card, Button, Divider, Tooltip, notification, Avatar, Flex, Typography } from 'antd'; import { CloseOutlined, ExpandOutlined, @@ -17,6 +17,7 @@ import { MenuFoldOutlined, ShrinkOutlined, CodeOutlined, + CompressOutlined, } from '@ant-design/icons'; import { useMobileLayout, useToken } from '@nocobase/client'; const { Header, Footer, Sider } = Layout; @@ -28,11 +29,13 @@ import { useT } from '../../locale'; import { UserPrompt } from './UserPrompt'; import { useChatBoxStore } from './stores/chat-box'; import { useChatBoxActions } from './hooks/useChatBoxActions'; -import { aiSelection } from '../stores/ai-selection'; import { observer } from '@formily/react'; import { dialogController } from '../stores/dialog-controller'; import { CodeHistory } from '../ai-coding/CodeHistory'; import { isEngineer } from '../built-in/utils'; +import { avatars } from '../avatars'; + +const { Text } = Typography; export const ChatBox: React.FC = () => { const chatBoxRef = useRef(null); @@ -41,6 +44,7 @@ export const ChatBox: React.FC = () => { const currentEmployee = useChatBoxStore.use.currentEmployee(); const expanded = useChatBoxStore.use.expanded(); const setExpanded = useChatBoxStore.use.setExpanded(); + const setMinimize = useChatBoxStore.use.setMinimize(); const showConversations = useChatBoxStore.use.showConversations(); const setShowConversations = useChatBoxStore.use.setShowConversations(); const setShowCodeHistory = useChatBoxStore.use.setShowCodeHistory(); @@ -140,7 +144,15 @@ export const ChatBox: React.FC = () => { ) : null} - {!isMobileLayout && ( + {isMobileLayout ? ( + + + ), + duration: 0, + placement: 'top', + style: { + width: 200, + }, + onClick() { + setMinimize(false); + }, + }); + } else { + api.destroy(key.current); + } + + return <>{contextHolder}; }; export const ChatBoxWrapper: React.FC = () => { const expanded = useChatBoxStore.use.expanded(); + const minimize = useChatBoxStore.use.minimize(); const showConversations = useChatBoxStore.use.showConversations(); const showCodeHistory = useChatBoxStore.use.showCodeHistory(); const { isMobileLayout } = useMobileLayout(); - return expanded ? ( + return isMobileLayout ? ( + + ) : expanded ? ( - ) : isMobileLayout ? ( - ) : (
void; setExpanded: (expanded: boolean) => void; setShowConversations: (show: boolean) => void; + setMinimize: (minus: boolean) => void; setCurrentEmployee: (aiEmployee?: AIEmployee | ((prev: AIEmployee) => AIEmployee)) => void; setSenderValue: (value: string) => void; @@ -61,6 +63,7 @@ const store = create()((set) => ({ open: false, expanded: false, showConversations: false, + minimize: false, currentEmployee: null, senderValue: '', @@ -82,6 +85,7 @@ const store = create()((set) => ({ setOpen: (open) => set({ open }), setExpanded: (expanded) => set({ expanded }), setShowConversations: (show) => set({ showConversations: show }), + setMinimize: (minus) => set({ minimize: minus }), setCurrentEmployee: (employee: AIEmployee | ((prev: AIEmployee) => AIEmployee)) => set((state) => ({ diff --git a/packages/plugins/@nocobase/plugin-ai/src/locale/en-US.json b/packages/plugins/@nocobase/plugin-ai/src/locale/en-US.json index 2fd36a1bb17..9ea2894e2c4 100644 --- a/packages/plugins/@nocobase/plugin-ai/src/locale/en-US.json +++ b/packages/plugins/@nocobase/plugin-ai/src/locale/en-US.json @@ -181,5 +181,6 @@ "Cite {{count}} pieces of information as references": "Cite {{count}} pieces of information as references", "references {{index}}": "references {{index}}", "Enable search": "Enable search", - "Disable search": "Disable search" + "Disable search": "Disable search", + "Conversation": "Conversation" } diff --git a/packages/plugins/@nocobase/plugin-ai/src/locale/zh-CN.json b/packages/plugins/@nocobase/plugin-ai/src/locale/zh-CN.json index b6a21b09fe6..fe60fe635ac 100644 --- a/packages/plugins/@nocobase/plugin-ai/src/locale/zh-CN.json +++ b/packages/plugins/@nocobase/plugin-ai/src/locale/zh-CN.json @@ -182,5 +182,6 @@ "Cite {{count}} pieces of information as references": "引用 {{count}} 篇资料作为参考", "references {{index}}": "参考资料 {{index}}", "Enable search": "启用搜索", - "Disable search": "禁用搜索" + "Disable search": "禁用搜索", + "Conversation": "当前会话" }