11<script setup lang="ts">
2- import { computed , onBeforeUnmount , ref } from ' vue'
2+ import { computed , onBeforeUnmount , onMounted , ref } from ' vue'
33import { useI18n } from ' vue-i18n'
4+ import type { VTextField } from ' vuetify/components'
45import { useSession } from ' @/stores/session'
56
67/** Login fixo (D-129): nome + senha; erro genérico (D-135) e contagem regressiva no 429 (D-146). */
@@ -14,6 +15,7 @@ const password = ref('')
1415const busy = ref (false )
1516const invalid = ref (false )
1617const wait = ref (0 )
18+ const nameField = ref <VTextField | null >(null )
1719let timer: ReturnType <typeof setInterval > | null = null
1820
1921const canSubmit = computed (() => ! busy .value && wait .value === 0 && name .value .trim () !== ' ' && password .value !== ' ' )
@@ -56,6 +58,14 @@ async function submit() {
5658 }
5759}
5860
61+ // Na página o foco vai ao usuário já ao montar: o autofocus do Vuetify espera ~50 ms e tiraria o foco de quem já começou a
62+ // digitar. No diálogo de sessão expirada (usuário travado) fica o autofocus da senha, que espera a transição do diálogo.
63+ onMounted (() => {
64+ if (! props .lockedName ) {
65+ nameField .value ?.focus ()
66+ }
67+ })
68+
5969onBeforeUnmount (() => timer && clearInterval (timer ))
6070 </script >
6171
@@ -76,13 +86,13 @@ onBeforeUnmount(() => timer && clearInterval(timer))
7686 {{ t('auth.login.throttled', { seconds: wait }) }}
7787 </v-alert >
7888 <v-text-field
89+ ref =" nameField"
7990 v-model =" name"
8091 :label =" t('auth.login.name')"
8192 autocomplete =" username"
8293 :readonly =" Boolean(lockedName)"
8394 prepend-inner-icon =" mdi-account"
8495 name =" name"
85- autofocus
8696 />
8797 <v-text-field
8898 v-model =" password"
0 commit comments