Skip to content

Commit b9356cf

Browse files
committed
feat: support chatinput's minrows in settings
1 parent 84c83e2 commit b9356cf

6 files changed

Lines changed: 35 additions & 5 deletions

File tree

src/renderer/src/components/pages/chat/ChatInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ const ChatInput = React.memo(
518518
onCompositionStart={handleCompositionStart}
519519
onCompositionEnd={handleCompositionEnd}
520520
onPaste={handlePaste}
521-
autoSize={{ minRows: 1, maxRows: 10 }}
521+
autoSize={{ minRows: settings.inputMinRows ?? 1, maxRows: 10 }}
522522
disabled={hasNoModels}
523523
/>
524524
<Flex align="center" gap={8} justify="space-between" style={{ width: '100%' }}>
Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,46 @@
11
import React from 'react'
2-
import { Form, Select, Card } from 'antd'
2+
import { Form, Select, Card, InputNumber } from 'antd'
33
import { FormInstance } from 'antd/lib/form'
44
import { useSettingsStore } from '../../stores/settingsStore'
55

66
const { Option } = Select
77

8+
const INPUT_WIDTH = 200
9+
810
interface AppearanceSettingsProps {
911
form: FormInstance
1012
}
1113

1214
export default function AppearanceSettings({ form }: AppearanceSettingsProps) {
13-
const { setFontSize } = useSettingsStore()
15+
const { setFontSize, setInputMinRows } = useSettingsStore()
1416

1517
const handleFontSizeChange = (value: 'small' | 'medium' | 'large') => {
1618
setFontSize(value)
1719
}
1820

21+
const handleInputMinRowsChange = (value: number | null) => {
22+
if (value !== null) {
23+
setInputMinRows(value)
24+
}
25+
}
26+
1927
return (
2028
<Card title="外观设置">
2129
<Form.Item name="fontSize" label="字体大小">
22-
<Select onChange={handleFontSizeChange}>
30+
<Select onChange={handleFontSizeChange} style={{ width: INPUT_WIDTH }}>
2331
<Option value="small"></Option>
2432
<Option value="medium"></Option>
2533
<Option value="large"></Option>
2634
</Select>
2735
</Form.Item>
36+
<Form.Item name="inputMinRows" label="输入框初始行高">
37+
<InputNumber
38+
min={1}
39+
max={10}
40+
onChange={handleInputMinRowsChange}
41+
style={{ width: INPUT_WIDTH }}
42+
/>
43+
</Form.Item>
2844
</Card>
2945
)
3046
}

src/renderer/src/components/settings/Settings.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ export default function Settings({
7777
form={form}
7878
layout="vertical"
7979
initialValues={{
80-
fontSize: settings.fontSize
80+
fontSize: settings.fontSize,
81+
inputMinRows: settings.inputMinRows
8182
}}
8283
style={{
8384
height: '100%',

src/renderer/src/stores/helpers/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,5 +166,6 @@ export const INITIAL_SETTINGS = {
166166
modelConfigs: [DEFAULT_MODEL_CONFIG],
167167
defaultModelConfigId: DEFAULT_MODEL_CONFIG.id,
168168
fontSize: 'medium' as const,
169+
inputMinRows: 1,
169170
promptLists: DEFAULT_PROMPT_LISTS
170171
}

src/renderer/src/stores/settingsStore.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface SettingsActions {
3434

3535
// 外观设置
3636
setFontSize: (size: 'small' | 'medium' | 'large') => void
37+
setInputMinRows: (rows: number) => void
3738

3839
// 提示词列表管理
3940
addPromptList: (config: PromptListConfig) => void
@@ -165,6 +166,16 @@ export const useSettingsStore = create<SettingsState & SettingsActions>()(
165166
}
166167
},
167168

169+
setInputMinRows: (rows) => {
170+
try {
171+
set((state) => {
172+
state.settings.inputMinRows = Math.max(1, Math.min(10, rows))
173+
})
174+
} catch (error) {
175+
handleStoreError('settingsStore', 'setInputMinRows', error)
176+
}
177+
},
178+
168179
// 提示词列表管理
169180
addPromptList: (config) => {
170181
try {

src/renderer/src/types/type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ export interface Settings {
321321
modelConfigs: ModelConfig[]
322322
defaultModelConfigId?: string
323323
fontSize: 'small' | 'medium' | 'large'
324+
inputMinRows: number // 输入框初始行高 (1-10)
324325
promptLists: PromptListConfig[]
325326
}
326327

0 commit comments

Comments
 (0)