import React, { useState, useRef } from 'react'; import { TextField, IconButton, Box, Tooltip, CircularProgress, useTheme } from '@mui/material'; import { SendRounded } from '@mui/icons-material'; interface MessageInputProps { value: string; onChange: (value: string) => void; onSend: () => void; onKeyDown: (e: React.KeyboardEvent) => void; disabled: boolean; } export const MessageInput: React.FC = ({ value, onChange, onSend, onKeyDown, disabled }) => { const theme = useTheme(); const textareaRef = useRef(null); const [isFocused, setIsFocused] = useState(false); const handleFocus = () => setIsFocused(true); const handleBlur = () => setIsFocused(false); // 自动调整文本框高度 const handleChange = (e: React.ChangeEvent) => { onChange(e.target.value); // 找到实际的textarea元素 const textarea = e.target as HTMLTextAreaElement; textarea.style.height = 'auto'; textarea.style.height = Math.min(textarea.scrollHeight, 120) + 'px'; }; return ( {disabled ? ( ) : ( )} ); };