diff --git a/docs/playground/independent.tsx b/docs/playground/independent.tsx index 2c374e1e..611dd129 100644 --- a/docs/playground/independent.tsx +++ b/docs/playground/independent.tsx @@ -17,13 +17,20 @@ import { EllipsisOutlined, FireOutlined, HeartOutlined, - LinkOutlined, + PaperClipOutlined, PlusOutlined, ReadOutlined, ShareAltOutlined, SmileOutlined, } from '@ant-design/icons'; -import { Button, type GetProp, Space } from 'antd'; +import { Badge, Button, type GetProp, Space } from 'antd'; +import { UploadChangeParam } from 'antd/es/upload'; + +interface AttachedFile { + uid: string; + name: string; + size: number; +} const renderTitle = (icon: React.ReactElement, title: string) => ( @@ -194,12 +201,14 @@ const Independent: React.FC = () => { const { styles } = useStyle(); // ==================== State ==================== - const [content, setContent] = React.useState(''); + const [headerOpen, setHeaderOpen] = React.useState(false); const [conversationsItems, setConversationsItems] = React.useState(defaultConversationsItems); const [activeKey, setActiveKey] = React.useState(defaultConversationsItems[0].key); + const [attachedFiles, setAttachedFiles] = React.useState([]); + // ==================== Runtime ==================== const [agent] = useXAgent({ request: async ({ message }, { onSuccess }) => { @@ -221,11 +230,6 @@ const Independent: React.FC = () => { const onSubmit = (nextContent: string) => { if (!nextContent) return; onRequest(nextContent); - setContent(''); - }; - - const onChange = (nextContent: string) => { - setContent(nextContent); }; const onPromptsItemClick: GetProp = (info) => { @@ -286,17 +290,58 @@ const Independent: React.FC = () => { ); + const handleFileChange = (info: UploadChangeParam) => { + const { file } = info; + if (file && !file.status) { + setAttachedFiles((prevFiles) => [ + ...prevFiles, + { + uid: file.uid, + name: file.name, + size: file.size ?? 0, + }, + ]); + } + }; + const attachmentsNode = ( - false} - placeholder={{ - icon: , - title: 'Drag & Drop files here', - description: 'Support file type: image, video, audio, document, etc.', +
+ 0 && !headerOpen}> +
+ ); + + const senderHeader = ( + -