增加按钮
All checks were successful
site-dist-deploy / build-and-deploy (push) Successful in 1m16s

This commit is contained in:
speakeloudest 2026-01-07 00:01:48 -08:00
parent 0aee63988c
commit efafec56e0
2 changed files with 47 additions and 24 deletions

View File

@ -11,7 +11,7 @@
></div>
<div
class="relative z-10 w-full max-w-[280px] rounded-[40px] border border-white/10 bg-[#999999] p-8 shadow-2xl"
class="relative z-10 w-full max-w-[280px] rounded-[40px] border border-white/0 bg-[#DDDDDD] px-8 pt-8 pb-4 shadow-2xl"
@click.stop
>
<div class="space-y-2 text-black">
@ -20,6 +20,15 @@
验证邮件已发送至邮箱如无法找到请检查垃圾邮件箱或营销邮件箱
</p>
</div>
<div class="flex justify-center pt-3">
<Button
class="h-[40px] w-[85px] cursor-pointer rounded-full bg-[#A8FF53] font-medium text-black hover:bg-[#96E64A]"
@click.stop="hide"
>
好的
</Button>
</div>
</div>
</div>
</Transition>
@ -28,6 +37,7 @@
<script setup lang="ts">
import { ref, onBeforeUnmount } from 'vue'
import { Button } from '@/components/ui/button'
const visible = ref(false)
const timer: ReturnType<typeof setTimeout> | null = null

View File

@ -50,12 +50,17 @@
/>
</div>
<Button
type="button"
@click="handleGetCode"
:disabled="countdown > 0"
class="h-10 rounded-full bg-[#4B94E6] px-[32px] text-base font-bold text-white hover:bg-[#4B94E6]/90 md:px-[45px] md:text-[18px]"
:disabled="countdown > 0 || isSendingCode"
class="relative h-10 min-w-[100px] cursor-pointer overflow-hidden rounded-full bg-[#4B94E6] px-[32px] text-base font-bold text-white hover:bg-[#4B94E6]/90 md:min-w-[130px] md:px-[45px] md:text-[18px]"
>
{{ countdown > 0 ? `${countdown}s` : '获取' }}
<div class="flex items-center justify-center">
<Loader2 v-if="isSendingCode" class="absolute left-4 h-4 w-4 animate-spin md:left-8" />
<span :class="{ 'ml-4': isSendingCode }">
{{ isSendingCode ? '发送中' : countdown > 0 ? `${countdown}s` : '获取' }}
</span>
</div>
</Button>
</div>
</div>
@ -88,6 +93,7 @@ import { toast } from 'vue-sonner'
import CodeSentTip from '@/pages/Home/components/CodeSentTip.vue'
import request from '@/utils/request'
import { useRouter } from 'vue-router'
import { Loader2 } from 'lucide-vue-next'
const CodeSentTipRef = ref<InstanceType<typeof CodeSentTip> | null>(null)
const email = ref('')
@ -96,6 +102,7 @@ const countdown = ref(0)
const isFocused = ref(false)
const commonSuffixes = ['@gmail.com', '@outlook.com', '@qq.com', '@163.com']
const activeIndex = ref(-1) //
const isSendingCode = ref(false) // loading
// 1. @
const prefix = computed(() => {
@ -161,37 +168,43 @@ const validateEmail = (str: string) => {
return /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(str)
}
const emit = defineEmits(['close'])
const handleGetCode = () => {
const handleGetCode = async () => {
if (!email.value) {
toast('请输入邮箱')
return
}
//
if (!validateEmail(email.value)) {
return toast.error('邮箱格式无效,请检查')
}
request
.get<{ exist: boolean }>('/api/v1/auth/check', {
isSendingCode.value = true // []
try {
// 1.
const { exist } = await request.get<{ exist: boolean }>('/api/v1/auth/check', {
email: email.value,
})
.then(({ exist }) => {
request
.post('/api/v1/common/send_code', {
// 1=, 2=,
email: email.value,
type: exist ? 2 : 1,
})
.then(() => {
CodeSentTipRef.value?.show()
countdown.value = 60
const timer = setInterval(() => {
countdown.value--
if (countdown.value <= 0) clearInterval(timer)
}, 1000)
})
// 2.
await request.post('/api/v1/common/send_code', {
email: email.value,
type: exist ? 2 : 1, // 1=, 2=
})
// 3.
CodeSentTipRef.value?.show()
countdown.value = 60
const timer = setInterval(() => {
countdown.value--
if (countdown.value <= 0) clearInterval(timer)
}, 1000)
} catch (error: any) {
console.error('发送验证码失败:', error)
// request toast
} finally {
isSendingCode.value = false // []
}
}
const router = useRouter()
const handleLogin = () => {