fix login validator

This commit is contained in:
2025-01-13 15:02:35 +08:00
parent 9d0cabcffa
commit d31d3d0910

View File

@@ -48,14 +48,14 @@
</q-layout>> </q-layout>>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useQuasar } from 'quasar' import { useQuasar, QForm } from 'quasar'
// import { useRouter } from 'vue-router'; // import { useRouter } from 'vue-router';
import { ref } from 'vue'; import { ref } from 'vue';
// import { Auth } from '../control/auth' // import { Auth } from '../control/auth'
import { useAuthStore } from 'stores/useAuthStore'; import { useAuthStore } from 'stores/useAuthStore';
const authStore = useAuthStore(); const authStore = useAuthStore();
const $q = useQuasar() const $q = useQuasar()
const loginForm = ref(null); const loginForm = ref<QForm>();
const loading = ref(false); const loading = ref(false);
let title = ref('ログイン'); let title = ref('ログイン');
let email = ref(''); let email = ref('');
@@ -78,7 +78,12 @@ import { useAuthStore } from 'stores/useAuthStore';
passwordFieldType.value = visibility.value ? 'text' : 'password' passwordFieldType.value = visibility.value ? 'text' : 'password'
visibilityIcon.value = visibility.value ? 'visibility_off' : 'visibility' visibilityIcon.value = visibility.value ? 'visibility_off' : 'visibility'
} }
const submit = async () =>{ const submit = () => {
if (!loginForm.value) {
return;
}
loginForm.value.validate().then(async (success) => {
if (success) {
loading.value=true; loading.value=true;
try { try {
const result = await authStore.login(email.value,password.value); const result = await authStore.login(email.value,password.value);
@@ -106,7 +111,8 @@ import { useAuthStore } from 'stores/useAuthStore';
message: 'ログイン失敗' message: 'ログイン失敗'
}); });
} }
}
})
} }
</script> </script>