import React, { FC } from 'react'; import { Page } from '../components/Page'; import { 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 } export const Settings: FC = observer(() => { const { t, i18n } = useTranslation(); 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.value }); }} /> } /> } /> ); });