feat: MFA verification code automatically obtains focus (#10213)

refs #8032
This commit is contained in:
2025-09-01 14:20:48 +08:00 committed by GitHub
parent 29306827ba
commit f62ce085bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -12,6 +12,7 @@
<div class="space-y-6 flex-grow">
<el-form-item>
<el-input
ref="mfaLoginRef"
size="large"
:placeholder="$t('commons.login.mfaCode')"
v-model.trim="mfaLoginForm.code"
@ -27,7 +28,7 @@
<el-button
@focus="mfaButtonFocused = true"
@blur="mfaButtonFocused = false"
class="w-full"
class="w-full login-button"
type="primary"
@click="mfaLogin(false)"
>
@ -181,7 +182,7 @@
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue';
import { ref, reactive, onMounted, computed, nextTick } from 'vue';
import type { ElForm } from 'element-plus';
import { loginApi, getCaptcha, mfaLoginApi, getLoginSetting } from '@/api/modules/auth';
import { GlobalStore, MenuStore, TabsStore } from '@/store';
@ -252,6 +253,7 @@ function checkAgreeLicense(rule: any, value: any, callback: any) {
}
let isLoggingIn = false;
const mfaLoginRef = ref();
const mfaButtonFocused = ref();
const mfaLoginForm = reactive({
name: '',
@ -338,6 +340,9 @@ const login = (formEl: FormInstance | undefined) => {
if (res.data.mfaStatus === 'Enable') {
mfaShow.value = true;
errMfaInfo.value = false;
nextTick(() => {
mfaLoginRef.value?.focus();
});
return;
}
globalStore.setLogStatus(true);