Commit 2c001a80 by pangchong

feat: 优化alova

parent ef68a0e3
...@@ -66,11 +66,11 @@ export const alova = createAlova({ ...@@ -66,11 +66,11 @@ export const alova = createAlova({
// 响应拦截器 // 响应拦截器
responded: { responded: {
// 当使用GlobalFetch请求适配器时,第一个参数接收Response对象 // 当使用GlobalFetch请求适配器时,第一个参数接收Response对象
onSuccess: async (response) => { onSuccess: async (response, method) => {
if (response.status >= 400) { if (response.status >= 400) {
throw new Error(response.statusText) throw new Error(response.statusText)
} }
if (response.url.endsWith('/admin/getCaptcha')) { if (method.meta.blob) {
return await response.blob() return await response.blob()
} }
const json = await response.json() const json = await response.json()
......
...@@ -87,7 +87,17 @@ loginSuccess(({ data: res }) => { ...@@ -87,7 +87,17 @@ loginSuccess(({ data: res }) => {
//获取验证码 //获取验证码
const loginCode = ref('') const loginCode = ref('')
const getCaptcha = async () => { const getCaptcha = async () => {
alova.Post('/admin/getCaptcha', { username: loginForm.username }).then((blob: any) => { alova
.Post(
'/admin/getCaptcha',
{ username: loginForm.username },
{
meta: {
blob: true
}
}
)
.then((blob: any) => {
if (blob) { if (blob) {
loginCode.value = URL.createObjectURL(blob) loginCode.value = URL.createObjectURL(blob)
} }
......
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