返回 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 proxyUsername: string
10 proxyPassword: string
11 proxyNoProxy: string
12 savingTimeouts: boolean
13 timeoutFields: TimeoutField[]
14 timeoutSeconds: Record<ConfigurableModelTimeoutProfile, string>
15 t: SettingsTranslate
16 onProxyUrlChange: (value: string) => void
17 onProxyUsernameChange: (value: string) => void
18 onProxyPasswordChange: (value: string) => void
19 onProxyNoProxyChange: (value: string) => void
20 onSaveAdvanced: () => void
21 onTimeoutChange: (profile: ConfigurableModelTimeoutProfile, value: string) => void
22 }
23
24 export function AdvancedSettingsTab({
25 proxyUrl,
26 proxyUsername,
27 proxyPassword,
28 proxyNoProxy,
29 savingTimeouts,
30 timeoutFields,
31 timeoutSeconds,
32 t,
33 onProxyUrlChange,
34 onProxyUsernameChange,
35 onProxyPasswordChange,
36 onProxyNoProxyChange,
37 onSaveAdvanced,
38 onTimeoutChange
39 }: AdvancedSettingsTabProps): React.JSX.Element {
40 return (
41 <>
42 <Card className="mb-4">
43 <CardHeader className="p-5 pb-3">
44 <CardTitle className="text-base">{t('settings.timeoutSection')}</CardTitle>
45 </CardHeader>
46 <CardContent className="space-y-3 p-5 pt-0">
47 <p className="text-xs text-muted-foreground">{t('settings.timeoutHint')}</p>
48 <div className="grid gap-2.5 sm:grid-cols-2">
49 {timeoutFields.map((field) => (
50 <div key={field.profile}>
51 <label className="mb-1 block text-xs font-medium text-muted-foreground">
52 {field.label}
53 </label>
54 <Input
55 inputMode="numeric"
56 pattern="[0-9]*"
57 placeholder={t('settings.timeoutPlaceholder')}
58 value={timeoutSeconds[field.profile]}
59 onChange={(e) => onTimeoutChange(field.profile, e.target.value)}
60 className="h-10"
61 />
62 <p className="mt-1 text-[11px] leading-snug text-muted-foreground">
63 {field.hint}
64 </p>
65 </div>
66 ))}
67 </div>
68 </CardContent>
69 </Card>
70
71 <Card className="mb-4">
72 <CardHeader className="p-5 pb-3">
73 <CardTitle className="text-base">{t('settings.proxySection')}</CardTitle>
74 </CardHeader>
75 <CardContent className="space-y-3 p-5 pt-0">
76 <div>
77 <label className="mb-1.5 block text-sm font-medium">{t('settings.proxyLabel')}</label>
78 <Input
79 value={proxyUrl}
80 onChange={(e) => onProxyUrlChange(e.target.value)}
81 placeholder={t('settings.proxyPlaceholder')}
82 className="h-10"
83 />
84 <p className="mt-2 text-xs text-muted-foreground">{t('settings.proxyHint')}</p>
85 </div>
86 <div className="grid gap-2.5 sm:grid-cols-2">
87 <div>
88 <label className="mb-1 block text-xs font-medium text-muted-foreground">
89 {t('settings.proxyUsernameLabel')}
90 </label>
91 <Input
92 autoComplete="off"
93 value={proxyUsername}
94 onChange={(e) => onProxyUsernameChange(e.target.value)}
95 placeholder={t('settings.proxyUsernamePlaceholder')}
96 className="h-10"
97 />
98 </div>
99 <div>
100 <label className="mb-1 block text-xs font-medium text-muted-foreground">
101 {t('settings.proxyPasswordLabel')}
102 </label>
103 <Input
104 type="password"
105 autoComplete="new-password"
106 value={proxyPassword}
107 onChange={(e) => onProxyPasswordChange(e.target.value)}
108 placeholder={t('settings.proxyPasswordPlaceholder')}
109 className="h-10"
110 />
111 </div>
112 </div>
113 <div>
114 <label className="mb-1.5 block text-sm font-medium">
115 {t('settings.proxyNoProxyLabel')}
116 </label>
117 <Input
118 value={proxyNoProxy}
119 onChange={(e) => onProxyNoProxyChange(e.target.value)}
120 placeholder={t('settings.proxyNoProxyPlaceholder')}
121 className="h-10"
122 />
123 <p className="mt-2 text-xs text-muted-foreground">{t('settings.proxyNoProxyHint')}</p>
124 </div>
125 </CardContent>
126 </Card>
127
128 <div className="flex justify-end">
129 <Button onClick={onSaveAdvanced} disabled={savingTimeouts}>
130 {savingTimeouts ? t('common.saving') : t('settings.saveTimeouts')}
131 </Button>
132 </div>
133 </>
134 )
135 }
136
136 lines Plain Text