Kaynağa Gözat

perf(api): 优化接口请求函数

1. 响应内容不是 json 类型时,直接返回原始数据
ccnnde 2 ay önce
ebeveyn
işleme
d783fcabd1
1 değiştirilmiş dosya ile 5 ekleme ve 0 silme
  1. 5 0
      src/http.ts

+ 5 - 0
src/http.ts

@@ -109,6 +109,11 @@ axios.interceptors.response.use(
       return;
     }
 
+
+    if (!response.headers['content-type'].startsWith('application/json')) {
+      return response.data
+    }
+
     const { data, code, msg } = response.data;
 
     if (code !== 0) {