From b523c8ad1067dbd72df07276b75b9ed8a1c03875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9F=E8=B4=A4?= Date: Fri, 24 Nov 2023 17:58:58 +0800 Subject: [PATCH] feat: support inputAreaProps --- src/ProChat/components/InputArea/index.tsx | 8 +++++--- src/ProChat/store/initialState.ts | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ProChat/components/InputArea/index.tsx b/src/ProChat/components/InputArea/index.tsx index e32c27ed..d7e79cbc 100644 --- a/src/ProChat/components/InputArea/index.tsx +++ b/src/ProChat/components/InputArea/index.tsx @@ -52,10 +52,11 @@ const useStyles = createStyles(({ css, responsive, token }) => ({ })); export const InputArea = ({}) => { - const [sendMessage, isLoading, placeholder] = useStore((s) => [ + const [sendMessage, isLoading, placeholder, inputAreaProps] = useStore((s) => [ s.sendMessage, !!s.chatLoadingId, s.placeholder, + s.inputAreaProps, ]); const [message, setMessage] = useState(''); const isChineseInput = useRef(false); @@ -84,8 +85,10 @@ export const InputArea = ({}) => { { setMessage(e.target.value); }} @@ -96,7 +99,6 @@ export const InputArea = ({}) => { onCompositionEnd={() => { isChineseInput.current = false; }} - className={styles.input} onPressEnter={(e) => { if (!isLoading && !e.shiftKey && !isChineseInput.current) { e.preventDefault(); diff --git a/src/ProChat/store/initialState.ts b/src/ProChat/store/initialState.ts index 684a9299..779872d3 100644 --- a/src/ProChat/store/initialState.ts +++ b/src/ProChat/store/initialState.ts @@ -2,6 +2,7 @@ import { DEFAULT_AVATAR, DEFAULT_USER_AVATAR } from '@/ProChat/const/meta'; import { ModelConfig } from '@/ProChat/types/config'; import { MetaData } from '@/ProChat/types/meta'; import { ChatMessage, ChatMessageMap } from '@/types/message'; +import { TextAreaProps } from 'antd/es/input'; export type ChatRequest = (messages: ChatMessage[], config: ModelConfig) => Promise; @@ -47,6 +48,11 @@ export interface ChatPropsState { */ placeholder?: string; + /** + * 输入框的 props,优先级最高 + */ + inputAreaProps?: TextAreaProps; + /** * 信息框额外渲染 */