mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
验证码获取测试
This commit is contained in:
parent
a040fd8ef1
commit
3d378aebe9
1 changed files with 6 additions and 4 deletions
|
|
@ -89,9 +89,10 @@ export default {
|
|||
try {
|
||||
this.captchaUuid = Date.now().toString()
|
||||
const response = await api.get(`/captcha?uuid=${this.captchaUuid}`, {
|
||||
responseType: 'blob', // Keep this as first config option
|
||||
responseType: 'blob',
|
||||
headers: {
|
||||
'Accept': 'image/gif' // Match with actual backend type
|
||||
'Content-Type': 'application/json;charset=utf8',
|
||||
'Accept': 'image/gif'
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -102,13 +103,14 @@ export default {
|
|||
|
||||
// 验证图片类型并创建新URL
|
||||
if (response.data.type === 'image/png') {
|
||||
// Directly use the received Blob
|
||||
|
||||
this.captchaUrl = URL.createObjectURL(response.data)
|
||||
console.log('PNG验证码加载成功,UUID:', this.captchaUuid)
|
||||
} else {
|
||||
throw new Error(`无效的图片类型: ${response.data.type}`)
|
||||
}
|
||||
} catch (error) {
|
||||
}
|
||||
catch (error) {
|
||||
// 清空验证码图片并显示错误
|
||||
this.captchaUrl = ''
|
||||
showDanger('验证码加载失败,请重试')
|
||||
|
|
|
|||
Loading…
Reference in a new issue