import * as React from 'react'; import { Cpu, DownloadCloud, LogOut, Monitor, RotateCw, Settings, Tool, Trash2, } from '~/components/shared/FeatherIcons'; import { useTranslation } from 'react-i18next'; import Select from '~/components/shared/Select'; import { useConfigPage } from '~/modules/config/hooks'; import { CONFIG_CHART_STYLE_PROPS, getBackendContent, LANGUAGE_OPTIONS, LOG_LEVEL_OPTIONS, MODE_OPTIONS, PORT_FIELDS, TUN_STACK_OPTIONS, } from '~/modules/config/utils'; import { ClashGeneralConfig, DispatchFn } from '~/store/types'; import { ClashAPIConfig } from '~/types'; import Button from './Button'; import s0 from './Config.module.scss'; import ContentHeader from './ContentHeader'; import Input, { SelfControlledInput } from './Input'; import { Selection2 } from './Selection'; import { useStoreActions } from './StateProvider'; import Switch from './SwitchThemed'; import TrafficChartSample from './TrafficChartSample'; type Props = { dispatch: DispatchFn; configs: ClashGeneralConfig; selectedChartStyleIndex: number; apiConfig: ClashAPIConfig; }; export default function Config({ dispatch, configs, selectedChartStyleIndex, apiConfig, }: Props) { const { t, i18n } = useTranslation(); const { selectChartStyleIndex, updateAppConfig } = useStoreActions(); const { configState, openAPIConfigModal, handleInputOnChange, handleInputOnBlur, handleReloadConfigFile, handleRestartCore, handleUpgradeCore, handleUpgradeGeo, handleUpgradeUI, handleFlushFakeIPPool, versionQuery: { data: version }, } = useConfigPage({ apiConfig, configs, dispatch, updateAppConfig, }); return (
{t('general')}
{(version.meta && version.premium) || PORT_FIELDS.map((f) => configState[f.key] !== undefined ? (
{f.label}
handleInputOnChange({ name, value }) } onBlur={handleInputOnBlur} />
) : null )}
Mode
handleInputOnChange({ name: 'log-level', value: e.target.value })} />
{(version.meta && version.premium) || (
{t('allow_lan')}
handleInputOnChange({ name: 'allow-lan', value: value }) } />
)} {version.meta && !version.premium && (
{t('tls_sniffing')}
handleInputOnChange({ name: 'sniffing', value: value }) } />
)}
{version.meta && ( <> {version.premium || (
TUN
{t('enable_tun_device')}
handleInputOnChange({ name: 'enable', value: value }) } />
TUN IP Stack
Interface Name
)}
{t('management')}
Reload
{version.meta && !version.premium && (
GEO Databases
)} {version.meta && !version.premium && (
Dashboard UI
)}
FakeIP
{version.meta && !version.premium && (
Restart
)} {version.meta && !version.premium && (
⚠️ Upgrade ⚠️
)}
)}
{t('dashboard')}
{t('lang')}