From 7d9da9ff66991aaaed5c3c59769e923340577bfc Mon Sep 17 00:00:00 2001 From: ibuler Date: Mon, 15 Nov 2021 16:53:35 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/templates/_mfa_login_field.html | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/apps/templates/_mfa_login_field.html b/apps/templates/_mfa_login_field.html index 31d59ec24..f4811a11a 100644 --- a/apps/templates/_mfa_login_field.html +++ b/apps/templates/_mfa_login_field.html @@ -78,17 +78,15 @@ $(ele).attr('name', '').attr('required', false) }) - const currentMFAInput = $('#mfa-' + name + ' .input-style') - currentMFAInput.attr('name', 'code').attr('required', true) + const currentMFAInputRef = $('#mfa-' + name + ' .input-style') + currentMFAInputRef.attr('name', 'code').attr('required', true) // 登录页时,不应该默认focus - if ($('input[name="username"]').length == 0) { - currentMFAInput.focus() + const usernameRef = $('input[name="username"]') + if (!usernameRef || usernameRef.length === 0) { + currentMFAInputRef.focus() } - $('#mfa-' + name + ' .input-style') - .attr('name', 'code') - .attr('required', true) - .focus() + currentMFAInputRef.attr('name', 'code').attr('required', true) } function sendChallengeCode(currentBtn) {