diff --git a/packages/desktop/package.json b/packages/desktop/package.json index c670c13..9e94beb 100644 --- a/packages/desktop/package.json +++ b/packages/desktop/package.json @@ -13,6 +13,7 @@ "tauri": "tauri" }, "dependencies": { + "@ai-assistant/ui": "workspace:*", "@tauri-apps/api": "^2.1.1", "@tauri-apps/plugin-dialog": "^2.2.0", "@tauri-apps/plugin-fs": "^2.2.0", diff --git a/packages/desktop/src/App.tsx b/packages/desktop/src/App.tsx index 6530e4c..28d659b 100644 --- a/packages/desktop/src/App.tsx +++ b/packages/desktop/src/App.tsx @@ -3,11 +3,15 @@ */ import { useState, useEffect } from 'react'; -import { Sidebar } from './components/Sidebar'; +import { + Sidebar, + FileBrowser, + ConfigPanel, + listSessions, + createSession, + type Session, +} from '@ai-assistant/ui'; import { ChatPage } from './pages/Chat'; -import { FileBrowser } from './components/FileBrowser'; -import { ConfigPanel } from './components/ConfigPanel'; -import { listSessions, createSession, type Session } from './api/client'; export function App() { const [currentSessionId, setCurrentSessionId] = useState(null); diff --git a/packages/desktop/src/components/ChatInput.tsx b/packages/desktop/src/components/ChatInput.tsx deleted file mode 100644 index af2bf1e..0000000 --- a/packages/desktop/src/components/ChatInput.tsx +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Chat Input Component - */ - -import { useState, useRef, useEffect } from 'react'; -import { Send, Square } from 'lucide-react'; -import clsx from 'clsx'; - -interface ChatInputProps { - onSend: (content: string) => void; - onCancel: () => void; - isLoading: boolean; - disabled?: boolean; -} - -export function ChatInput({ onSend, onCancel, isLoading, disabled }: ChatInputProps) { - const [input, setInput] = useState(''); - const textareaRef = useRef(null); - - // 自动调整高度 - useEffect(() => { - const textarea = textareaRef.current; - if (textarea) { - textarea.style.height = 'auto'; - textarea.style.height = `${Math.min(textarea.scrollHeight, 200)}px`; - } - }, [input]); - - const handleSubmit = () => { - const trimmed = input.trim(); - if (!trimmed || isLoading || disabled) return; - - onSend(trimmed); - setInput(''); - - // 重置高度 - if (textareaRef.current) { - textareaRef.current.style.height = 'auto'; - } - }; - - const handleKeyDown = (e: React.KeyboardEvent) => { - if (e.key === 'Enter' && !e.shiftKey) { - e.preventDefault(); - handleSubmit(); - } - }; - - return ( -
-
-
-