Commit 2c001a80 by pangchong

feat: 优化alova

parent ef68a0e3
......@@ -66,11 +66,11 @@ export const alova = createAlova({
// 响应拦截器
responded: {
// 当使用GlobalFetch请求适配器时,第一个参数接收Response对象
onSuccess: async (response) => {
onSuccess: async (response, method) => {
if (response.status >= 400) {
throw new Error(response.statusText)
}
if (response.url.endsWith('/admin/getCaptcha')) {
if (method.meta.blob) {
return await response.blob()
}
const json = await response.json()
......
......@@ -87,11 +87,21 @@ loginSuccess(({ data: res }) => {
//获取验证码
const loginCode = ref('')
const getCaptcha = async () => {
alova.Post('/admin/getCaptcha', { username: loginForm.username }).then((blob: any) => {
if (blob) {
loginCode.value = URL.createObjectURL(blob)
}
})
alova
.Post(
'/admin/getCaptcha',
{ username: loginForm.username },
{
meta: {
blob: true
}
}
)
.then((blob: any) => {
if (blob) {
loginCode.value = URL.createObjectURL(blob)
}
})
}
watch(
() => loginForm.username,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment