返回 oh-my-ppt
AdvancedSettingsTab.tsx
根目录 / src / renderer / src / components / settings / AdvancedSettingsTab.tsx
1 import type { ConfigurableModelTimeoutProfile } from '@shared/model-timeout.js'
2 import { Button } from '../ui/Button'
3 import { Card, CardContent, CardHeader, CardTitle } from '../ui/Card'
4 import { Input } from '../ui/Input'
5 import type { SettingsTranslate, TimeoutField } from './types'
6
7 interface AdvancedSettingsTabProps {
8 proxyUrl: string
9 savingTimeouts: boolean
10 timeoutFields: TimeoutField[]
11 timeoutSeconds: Record<ConfigurableModelTimeoutProfile, string>
12 t: SettingsTranslate
13 onProxyUrlChange: (value: string) => void
14 onSaveAdvanced: () => void
15 onTimeoutChange: (profile: ConfigurableModelTimeoutProfile, value: string) => void
16 }
17
18 export function AdvancedSettingsTab({
19 proxyUrl,
20 savingTimeouts,
21 timeoutFields,
22 timeoutSeconds,
23 t,
24 onProxyUrlChange,
25 onSaveAdvanced,
26 onTimeoutChange
27 }: AdvancedSettingsTabProps): React.JSX.Element {
28 return (
29 <>
30 <Card className="mb-4">
31 <CardHeader className="p-5 pb-3">
32 <CardTitle className="text-base">{t('settings.timeoutSection')}</CardTitle>
33 </CardHeader>
34 <CardContent className="space-y-3 p-5 pt-0">
35 <p className="text-xs text-muted-foreground">{t('settings.timeoutHint')}</p>
36 <div className="grid gap-2.5 sm:grid-cols-2">
37 {timeoutFields.map((field) => (
38 <div key={field.profile}>
39 <label className="mb-1 block text-xs font-medium text-muted-foreground">
40 {field.label}
41 </label>
42 <Input
43 inputMode="numeric"
44 pattern="[0-9]*"
45 placeholder={t('settings.timeoutPlaceholder')}
46 value={timeoutSeconds[field.profile]}
47 onChange={(e) => onTimeoutChange(field.profile, e.target.value)}
48 className="h-10"
49 />
50 <p className="mt-1 text-[11px] leading-snug text-muted-foreground">
51 {field.hint}
52 </p>
53 </div>
54 ))}
55 </div>
56 </CardContent>
57 </Card>
58
59 <Card className="mb-4">
60 <CardHeader className="p-5 pb-3">
61 <CardTitle className="text-base">{t('settings.proxySection')}</CardTitle>
62 </CardHeader>
63 <CardContent className="space-y-3 p-5 pt-0">
64 <div>
65 <label className="mb-1.5 block text-sm font-medium">{t('settings.proxyLabel')}</label>
66 <Input
67 value={proxyUrl}
68 onChange={(e) => onProxyUrlChange(e.target.value)}
69 placeholder={t('settings.proxyPlaceholder')}
70 className="h-10"
71 />
72 <p className="mt-2 text-xs text-muted-foreground">{t('settings.proxyHint')}</p>
73 </div>
74 </CardContent>
75 </Card>
76
77 <div className="flex justify-end">
78 <Button onClick={onSaveAdvanced} disabled={savingTimeouts}>
79 {savingTimeouts ? t('common.saving') : t('settings.saveTimeouts')}
80 </Button>
81 </div>
82 </>
83 )
84 }
85
85 lines Plain Text