import React, { FC, useEffect, useRef } from 'react'; import { Page } from '../components/Page'; import { Accordion, AccordionHeader, AccordionItem, AccordionPanel, Dropdown, Input, Option, Switch } from '@fluentui/react-components'; import { Labeled } from '../components/Labeled'; import commonStore from '../stores/commonStore'; import { observer } from 'mobx-react-lite'; import { useTranslation } from 'react-i18next'; import { checkUpdate } from '../utils'; export const Languages = { dev: 'English', // i18n default zh: '简体中文' }; export type Language = keyof typeof Languages; export type SettingsType = { language: Language darkMode: boolean autoUpdatesCheck: boolean giteeUpdatesSource: boolean cnMirror: boolean host: string customModelsPath: string customPythonPath: string } export const Settings: FC = observer(() => { const { t, i18n } = useTranslation(); const advancedHeaderRef = useRef(null); useEffect(() => { if (advancedHeaderRef.current) (advancedHeaderRef.current.firstElementChild as HTMLElement).style.padding = '0'; }, []); return ( { if (data.optionValue) { const lang = data.optionValue as Language; commonStore.setSettings({ language: lang }); i18n.changeLanguage(lang); } }}> { Object.entries(Languages).map(([langKey, desc]) => ) } } /> { commonStore.setSettings({ darkMode: data.checked }); }} /> } /> { commonStore.setSettings({ autoUpdatesCheck: data.checked }); if (data.checked) checkUpdate(true); }} /> } /> { commonStore.settings.language === 'zh' && { commonStore.setSettings({ giteeUpdatesSource: data.checked }); }} /> } /> } { commonStore.settings.language === 'zh' && { commonStore.setSettings({ cnMirror: data.checked }); }} /> } /> } { commonStore.setSettings({ host: data.checked ? '0.0.0.0' : '127.0.0.1' }); }} /> } /> {t('Advanced')}
{commonStore.platform !== 'darwin' && { commonStore.setSettings({ customModelsPath: data.value }); }} /> } /> } { commonStore.setSettings({ customPythonPath: data.value }); }} /> } />
} /> ); });