BUG fix: send register code

This commit is contained in:
KUN1007 2023-11-01 12:41:36 +08:00
parent 5f417dd0c3
commit 78e62dd1b5
2 changed files with 28 additions and 32 deletions

View file

@ -1,8 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { ref, watch } from 'vue'
import { useKUNGalgameUserStore } from '@/store/modules/kungalgamer' import { useKUNGalgameUserStore } from '@/store/modules/kungalgamer'
// Using global notifications
import { useKUNGalgameMessageStore } from '@/store/modules/message' import { useKUNGalgameMessageStore } from '@/store/modules/message'
const info = useKUNGalgameMessageStore() const info = useKUNGalgameMessageStore()
@ -16,12 +15,9 @@ const isSending = ref(false)
const countdown = ref(0) const countdown = ref(0)
const sendCode = () => { watch(
// If the parent component passes a false value, return directly () => props.isSendCode,
if (!props.isSendCode) { async () => {
return
}
if (!isSending.value) { if (!isSending.value) {
isSending.value = true isSending.value = true
countdown.value = 30 countdown.value = 30
@ -35,15 +31,16 @@ const sendCode = () => {
}, 1000) }, 1000)
// Send the verification code // Send the verification code
useKUNGalgameUserStore().sendCode(props.email) await useKUNGalgameUserStore().sendCode(props.email)
info.info('AlertInfo.code.code') info.info('AlertInfo.code.code')
} }
} }
)
</script> </script>
<template> <template>
<button @click="sendCode" :disabled="isSending"> <button :disabled="isSending">
{{ isSending ? countdown : $tm('login.register.send') }} {{ isSending ? countdown : $tm('login.register.send') }}
</button> </button>
</template> </template>

View file

@ -110,15 +110,14 @@ const handleSendCode = () => {
return return
} }
// If human verification is not completed if (isCaptureSuccessful.value) {
if (!isCaptureSuccessful.value) { // Change isSendCode, because Code component use watch
isSendCode.value = !isSendCode.value
isCaptureSuccessful.value = false
} else {
// Show human verification // Show human verification
isShowCapture.value = true isShowCapture.value = true
return
} }
// Mark that the code has been sent
isSendCode.value = true
} }
const handleRegister = async () => { const handleRegister = async () => {