import { hasPermission } from '@/util/auth' import { r_sys_settings_two_factor_get, r_sys_settings_two_factor_update } from '@/services/system' import SettingsCard from '@/components/system/SettingCard' const TwoFactor = () => { const [twoFactorForm] = AntdForm.useForm() const twoFactorFormValues = AntdForm.useWatch([], twoFactorForm) const [loading, setLoading] = useState(false) const handleOnReset = () => { getTwoFactorSettings() } const handleOnSave = () => { void r_sys_settings_two_factor_update(twoFactorFormValues).then((res) => { const response = res.data if (response.success) { void message.success('保存设置成功') getTwoFactorSettings() } else { void message.error('保存设置失败,请稍后重试') } }) } const getTwoFactorSettings = () => { if (loading) { return } setLoading(true) void r_sys_settings_two_factor_get().then((res) => { const response = res.data if (response.success) { const data = response.data data && twoFactorForm.setFieldsValue(data) setLoading(false) } }) } useEffect(() => { getTwoFactorSettings() }, []) return ( <> ) } export default TwoFactor