Browse Source

请求工具修改超时时间

Koishi 3 years ago
parent
commit
86f928751f
1 changed files with 4 additions and 6 deletions
  1. 4 6
      src/api/axios.js

+ 4 - 6
src/api/axios.js

@@ -25,7 +25,7 @@ axios.defaults.withCredentials = true;
   });
 
  */
-export function requestData (options) {
+export function requestData(options) {
   return new Promise((resolve, reject) => {
 
     if (options.showLoading) {
@@ -49,7 +49,7 @@ export function requestData (options) {
       withCredentials: true,
       crossDomain: true,
       baseURL: options.baseURL || window.__MODE__.baseURL || '/api/',
-      timeout: options.timeout || 3000, // 请求超时时间 - 3s
+      timeout: options.timeout || 30000, // 请求超时时间 - 3s
     });
 
     // 请求拦截器
@@ -81,10 +81,8 @@ export function requestData (options) {
           msg: (response.data && response.data.msg) || ("请求出错[" + response.data.code + "]")
         });
 
-        setTimeout(() => {
-          // window.location.reload();
-          // window.__STATICVUE__.$router.replace('/login');
-        }, 1000);
+        // window.location.reload();
+        // window.__STATICVUE__.$router.replace('/login');
 
       } else if (response.data.code === 200) { // 请求成功 code