Skip to content

Commit

Permalink
feat: support inputAreaProps
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Nov 24, 2023
1 parent 0c4f2a5 commit b523c8a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/ProChat/components/InputArea/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -84,8 +85,10 @@ export const InputArea = ({}) => {
<Flexbox horizontal gap={8} align={'center'} className={styles.boxShadow}>
<AutoCompleteTextArea
size={'large'}
value={message}
className={styles.input}
placeholder={placeholder || '请输入内容...'}
{...inputAreaProps}
value={message}
onChange={(e) => {
setMessage(e.target.value);
}}
Expand All @@ -96,7 +99,6 @@ export const InputArea = ({}) => {
onCompositionEnd={() => {
isChineseInput.current = false;
}}
className={styles.input}
onPressEnter={(e) => {
if (!isLoading && !e.shiftKey && !isChineseInput.current) {
e.preventDefault();
Expand Down
6 changes: 6 additions & 0 deletions src/ProChat/store/initialState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Response>;

Expand Down Expand Up @@ -47,6 +48,11 @@ export interface ChatPropsState {
*/
placeholder?: string;

/**
* 输入框的 props,优先级最高
*/
inputAreaProps?: TextAreaProps;

/**
* 信息框额外渲染
*/
Expand Down

0 comments on commit b523c8a

Please sign in to comment.