11import React , { useRef , forwardRef , useImperativeHandle , useState } from 'react'
2- import { Input , Button , Alert , Switch , Tooltip , Space , Select , Dropdown } from 'antd'
3- import { SendOutlined , StopOutlined , SettingOutlined , QuestionCircleOutlined , BulbOutlined , DownOutlined } from '@ant-design/icons'
2+ import { Input , Button , Alert , Switch , Tooltip , Space , Select , Dropdown , Flex } from 'antd'
3+ import {
4+ SendOutlined ,
5+ StopOutlined ,
6+ SettingOutlined ,
7+ QuestionCircleOutlined ,
8+ BulbOutlined ,
9+ DownOutlined
10+ } from '@ant-design/icons'
411import { LLMConfig } from '../../../types/type'
512import { useSettingsStore } from '../../../stores/settingsStore'
613import ModelSelector from './ModelSelector'
@@ -43,15 +50,19 @@ function AutoQuestionControls({
4350 }
4451
4552 const handleModeChange = ( newMode : 'ai' | 'preset' ) => {
46- onChange ?.( enabled , newMode , newMode === 'preset' ? ( selectedListId || promptLists [ 0 ] ?. id ) : undefined )
53+ onChange ?.(
54+ enabled ,
55+ newMode ,
56+ newMode === 'preset' ? selectedListId || promptLists [ 0 ] ?. id : undefined
57+ )
4758 }
4859
4960 const handleListChange = ( listId : string ) => {
5061 onChange ?.( enabled , mode , listId )
5162 }
5263
5364 const getCurrentPromptList = ( ) => {
54- return promptLists . find ( list => list . id === selectedListId )
65+ return promptLists . find ( ( list ) => list . id === selectedListId )
5566 }
5667
5768 const modeOptions = [
@@ -76,7 +87,7 @@ function AutoQuestionControls({
7687 ]
7788
7889 const dropdownMenu = {
79- items : modeOptions . map ( option => ( {
90+ items : modeOptions . map ( ( option ) => ( {
8091 key : option . key ,
8192 label : option . label ,
8293 onClick : ( ) => handleModeChange ( option . key as 'ai' | 'preset' )
@@ -96,7 +107,7 @@ function AutoQuestionControls({
96107 < span style = { { fontSize : '12px' } } > 自动提问</ span >
97108 </ Space >
98109 </ Tooltip >
99-
110+
100111 { enabled && (
101112 < >
102113 < Dropdown menu = { dropdownMenu } trigger = { [ 'click' ] } disabled = { disabled } >
@@ -115,7 +126,7 @@ function AutoQuestionControls({
115126 < DownOutlined />
116127 </ Button >
117128 </ Dropdown >
118-
129+
119130 { mode === 'preset' && (
120131 < Select
121132 size = "small"
@@ -238,25 +249,16 @@ const ChatInput = forwardRef<ChatInputRef, ChatInputProps>(
238249 />
239250 ) }
240251
241- < div className = "chat-input-container" >
242- < div style = { { display : 'flex' , alignItems : 'center' , gap : 8 , marginBottom : 8 } } >
243- < ModelSelector
244- llmConfigs = { llmConfigs }
245- selectedModel = { selectedModel }
246- defaultLLMId = { defaultModelId }
247- onChange = { onModelChange }
248- disabled = { disabled || loading }
249- size = "small"
250- />
251- < AutoQuestionControls
252- enabled = { autoQuestionEnabled }
253- mode = { autoQuestionMode }
254- selectedListId = { autoQuestionListId }
255- promptLists = { settings . promptLists || [ ] }
256- disabled = { disabled || loading }
257- onChange = { onAutoQuestionChange }
258- />
259- </ div >
252+ < div
253+ className = "chat-input-container"
254+ style = { {
255+ display : 'flex' ,
256+ flexDirection : 'column' ,
257+ alignItems : 'flex-start' ,
258+ gap : 8 ,
259+ flexWrap : 'wrap'
260+ } }
261+ >
260262 < TextArea
261263 ref = { textAreaRef }
262264 placeholder = {
@@ -272,20 +274,51 @@ const ChatInput = forwardRef<ChatInputRef, ChatInputProps>(
272274 autoSize = { { minRows : 1 , maxRows : 10 } }
273275 disabled = { disabled || hasNoModels }
274276 />
275- { loading ? (
276- < Button type = "primary" danger icon = { < StopOutlined /> } onClick = { onStop } >
277- 停止
278- </ Button >
279- ) : (
280- < Button
281- type = "primary"
282- icon = { < SendOutlined /> }
283- onClick = { onSend }
284- disabled = { ! value . trim ( ) || disabled || ! selectedModel || hasNoModels }
285- >
286- 发送
287- </ Button >
288- ) }
277+ < Flex align = "center" gap = { 8 } justify = "space-between" style = { { width : '100%' } } >
278+ < Space >
279+ { /* 模型选择器 */ }
280+ < div >
281+ < ModelSelector
282+ llmConfigs = { llmConfigs }
283+ selectedModel = { selectedModel }
284+ defaultLLMId = { defaultModelId }
285+ onChange = { onModelChange }
286+ disabled = { disabled }
287+ size = "small"
288+ />
289+ </ div >
290+
291+ { /* 自动提问控件 */ }
292+ < div >
293+ < AutoQuestionControls
294+ enabled = { autoQuestionEnabled }
295+ mode = { autoQuestionMode }
296+ selectedListId = { autoQuestionListId }
297+ promptLists = { settings . promptLists || [ ] }
298+ disabled = { disabled }
299+ onChange = { onAutoQuestionChange }
300+ />
301+ </ div >
302+ </ Space >
303+
304+ { /* 发送/停止按钮 */ }
305+ < div style = { { justifySelf : 'flex-end' } } >
306+ { loading ? (
307+ < Button type = "primary" danger icon = { < StopOutlined /> } onClick = { onStop } >
308+ 停止
309+ </ Button >
310+ ) : (
311+ < Button
312+ type = "primary"
313+ icon = { < SendOutlined /> }
314+ onClick = { onSend }
315+ disabled = { ! value . trim ( ) || disabled || ! selectedModel || hasNoModels }
316+ >
317+ 发送
318+ </ Button >
319+ ) }
320+ </ div >
321+ </ Flex >
289322 </ div >
290323 </ div >
291324 )
0 commit comments