generated from Leo_Ding/web-template
添加验证码
This commit is contained in:
parent
94bcce4499
commit
3e24b16843
@ -95,11 +95,24 @@ onMounted(() => {
|
||||
* 获取 验证码ID
|
||||
*/
|
||||
async function getCaptcha() {
|
||||
const { data } = await apis.common.getCaptcha().catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
try {
|
||||
// 1. 获取 captcha_id
|
||||
const response = await apis.common.getCaptcha()
|
||||
const data = response.data
|
||||
if (!data?.captcha_id) {
|
||||
console.warn('验证码ID缺失')
|
||||
return
|
||||
}
|
||||
captcha_id.value = data.captcha_id
|
||||
captcha_img.value = httpApi + `?id=${data.captcha_id}`
|
||||
const imageResponse = await apis.common.getCaptchaImage({ id: data.captcha_id,reload:1 })
|
||||
console.log('Blob 对象:', imageResponse)
|
||||
const blobUrl = URL.createObjectURL(imageResponse)
|
||||
captcha_img.value = blobUrl
|
||||
console.log('验证码图片URL:', blobUrl)
|
||||
} catch (err) {
|
||||
console.error('获取验证码失败:', err)
|
||||
captcha_img.value = ''
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 登录
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user