增加按钮
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>
<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 @click.stop
> >
<div class="space-y-2 text-black"> <div class="space-y-2 text-black">
@ -20,6 +20,15 @@
验证邮件已发送至邮箱如无法找到请检查垃圾邮件箱或营销邮件箱 验证邮件已发送至邮箱如无法找到请检查垃圾邮件箱或营销邮件箱
</p> </p>
</div> </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>
</div> </div>
</Transition> </Transition>
@ -28,6 +37,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onBeforeUnmount } from 'vue' import { ref, onBeforeUnmount } from 'vue'
import { Button } from '@/components/ui/button'
const visible = ref(false) const visible = ref(false)
const timer: ReturnType<typeof setTimeout> | null = null const timer: ReturnType<typeof setTimeout> | null = null

View File

@ -50,12 +50,17 @@
/> />
</div> </div>
<Button <Button
type="button"
@click="handleGetCode" @click="handleGetCode"
:disabled="countdown > 0" :disabled="countdown > 0 || isSendingCode"
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]" 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> </Button>
</div> </div>
</div> </div>
@ -88,6 +93,7 @@ import { toast } from 'vue-sonner'
import CodeSentTip from '@/pages/Home/components/CodeSentTip.vue' import CodeSentTip from '@/pages/Home/components/CodeSentTip.vue'
import request from '@/utils/request' import request from '@/utils/request'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { Loader2 } from 'lucide-vue-next'
const CodeSentTipRef = ref<InstanceType<typeof CodeSentTip> | null>(null) const CodeSentTipRef = ref<InstanceType<typeof CodeSentTip> | null>(null)
const email = ref('') const email = ref('')
@ -96,6 +102,7 @@ const countdown = ref(0)
const isFocused = ref(false) const isFocused = ref(false)
const commonSuffixes = ['@gmail.com', '@outlook.com', '@qq.com', '@163.com'] const commonSuffixes = ['@gmail.com', '@outlook.com', '@qq.com', '@163.com']
const activeIndex = ref(-1) // const activeIndex = ref(-1) //
const isSendingCode = ref(false) // loading
// 1. @ // 1. @
const prefix = computed(() => { 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) return /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(str)
} }
const emit = defineEmits(['close']) const emit = defineEmits(['close'])
const handleGetCode = () => { const handleGetCode = async () => {
if (!email.value) { if (!email.value) {
toast('请输入邮箱') toast('请输入邮箱')
return return
} }
//
if (!validateEmail(email.value)) { if (!validateEmail(email.value)) {
return toast.error('邮箱格式无效,请检查') return toast.error('邮箱格式无效,请检查')
} }
request isSendingCode.value = true // []
.get<{ exist: boolean }>('/api/v1/auth/check', {
try {
// 1.
const { exist } = await request.get<{ exist: boolean }>('/api/v1/auth/check', {
email: email.value, email: email.value,
}) })
.then(({ exist }) => {
request // 2.
.post('/api/v1/common/send_code', { await request.post('/api/v1/common/send_code', {
// 1=, 2=, email: email.value,
email: email.value, type: exist ? 2 : 1, // 1=, 2=
type: exist ? 2 : 1,
})
.then(() => {
CodeSentTipRef.value?.show()
countdown.value = 60
const timer = setInterval(() => {
countdown.value--
if (countdown.value <= 0) clearInterval(timer)
}, 1000)
})
}) })
// 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 router = useRouter()
const handleLogin = () => { const handleLogin = () => {