fix(ui): 完善界面交互与开发配置
This commit is contained in:
@@ -71,6 +71,21 @@ const TwoFAVerification = ({ onSuccess, onBack, isModal = false }) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 前端校验:与 handleSubmit 内原有判断一致,改为在输入框下方就地提示
|
||||
const codeRules = [
|
||||
{
|
||||
required: true,
|
||||
message: useBackupCode ? t('请输入备用码') : t('请输入验证码'),
|
||||
},
|
||||
{
|
||||
validator: (_, value) => {
|
||||
if (!value) return true;
|
||||
if (useBackupCode) return value.length === 8 || t('备用码必须是8位');
|
||||
return /^\d{6}$/.test(value) || t('验证码必须是6位数字');
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
if (isModal) {
|
||||
return (
|
||||
<div className='space-y-4'>
|
||||
@@ -88,6 +103,8 @@ const TwoFAVerification = ({ onSuccess, onBack, isModal = false }) => {
|
||||
value={verificationCode}
|
||||
onChange={setVerificationCode}
|
||||
onKeyPress={handleKeyPress}
|
||||
rules={codeRules}
|
||||
trigger='blur'
|
||||
style={{ marginBottom: 16 }}
|
||||
autoFocus
|
||||
/>
|
||||
@@ -177,6 +194,8 @@ const TwoFAVerification = ({ onSuccess, onBack, isModal = false }) => {
|
||||
value={verificationCode}
|
||||
onChange={setVerificationCode}
|
||||
onKeyPress={handleKeyPress}
|
||||
rules={codeRules}
|
||||
trigger='blur'
|
||||
style={{ marginBottom: 16 }}
|
||||
autoFocus
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user