1
1
import { For } from 'solid-js'
2
+ import { localesOptions } from '@/locale'
3
+ import { useI18n } from '@/hooks'
2
4
import SettingsUIComponent from './SettingsUIComponent'
3
5
import type { Accessor } from 'solid-js'
4
6
import type { GeneralSettings } from '@/types/app'
7
+ import type { SettingsUI } from '@/types/provider'
5
8
6
9
interface Props {
7
10
settingsValue : Accessor < GeneralSettings >
8
11
updateSettings : ( v : Partial < GeneralSettings > ) => void
9
12
}
10
13
11
- const settingsUIList = [
14
+ const settingsUIList : SettingsUI [ ] = [
12
15
{
13
16
key : 'requestWithBackend' ,
14
17
name : 'Request With Backend' ,
15
18
type : 'toggle' ,
19
+ default : false ,
16
20
} ,
17
- ] as const
21
+ {
22
+ key : 'locale' ,
23
+ name : 'Change system language' ,
24
+ type : 'select' ,
25
+ default : 'en' ,
26
+ options : localesOptions ,
27
+ } ,
28
+ ]
18
29
19
30
export default ( props : Props ) => {
31
+ const { t } = useI18n ( )
32
+
20
33
return (
21
34
< div class = "px-4 py-3 transition-colors border-b border-base" >
22
35
< h3 class = "fi gap-2" >
23
36
< div class = "flex-1 fi gap-1.5 overflow-hidden" >
24
37
< div class = "i-carbon-settings" />
25
- < div class = "flex-1 text-sm truncate" > General </ div >
38
+ < div class = "flex-1 text-sm truncate" > { t ( 'settings.general.title' ) } </ div >
26
39
</ div >
27
40
</ h3 >
28
41
< div class = "mt-2 flex flex-col" >
@@ -32,9 +45,9 @@ export default (props: Props) => {
32
45
< SettingsUIComponent
33
46
settings = { item }
34
47
editing = { ( ) => true }
35
- value = { ( ) => props . settingsValue ( ) [ item . key ] || false }
48
+ value = { ( ) => props . settingsValue ( ) [ item . key as keyof GeneralSettings ] || false }
36
49
setValue = { ( v ) => {
37
- props . updateSettings ( { [ item . key ] : v as boolean } )
50
+ props . updateSettings ( { [ item . key ] : v } )
38
51
} }
39
52
/>
40
53
)
0 commit comments