import { Collapse, Divider, Input, InputNumber, Switch } from 'antd'; import { useTranslation } from 'react-i18next'; import type { AllSetting } from '@/models/setting'; import SettingListItem from '@/components/SettingListItem'; interface SubscriptionGeneralTabProps { allSetting: AllSetting; updateSetting: (patch: Partial) => void; } function sanitizePath(input: string): string { return String(input ?? '').replace(/[:*]/g, ''); } function normalizePath(input: string): string { let p = input || '/'; if (!p.startsWith('/')) p = '/' + p; if (!p.endsWith('/')) p += '/'; p = p.replace(/\/+/g, '/'); return p; } export default function SubscriptionGeneralTab({ allSetting, updateSetting }: SubscriptionGeneralTabProps) { const { t } = useTranslation(); return ( updateSetting({ subEnable: v })} /> updateSetting({ subJsonEnable: v })} /> updateSetting({ subClashEnable: v })} /> updateSetting({ subListen: e.target.value })} /> updateSetting({ subDomain: e.target.value })} /> updateSetting({ subPort: Number(v) || 0 })} /> updateSetting({ subPath: sanitizePath(e.target.value) })} onBlur={() => updateSetting({ subPath: normalizePath(allSetting.subPath) })} /> updateSetting({ subURI: e.target.value })} /> ), }, { key: '2', label: t('pages.settings.information'), children: ( <> updateSetting({ subEncrypt: v })} /> updateSetting({ subShowInfo: v })} /> updateSetting({ subEmailInRemark: v })} /> {t('pages.settings.subTitle')} updateSetting({ subTitle: e.target.value })} /> updateSetting({ subSupportUrl: e.target.value })} /> updateSetting({ subProfileUrl: e.target.value })} /> updateSetting({ subAnnounce: e.target.value })} /> Happ updateSetting({ subEnableRouting: v })} /> updateSetting({ subRoutingRules: e.target.value })} /> ), }, { key: '3', label: t('pages.settings.certs'), children: ( <> updateSetting({ subCertFile: e.target.value })} /> updateSetting({ subKeyFile: e.target.value })} /> ), }, { key: '4', label: t('pages.settings.intervals'), children: ( <> updateSetting({ subUpdates: Number(v) || 0 })} /> ), }, ]} /> ); }