Browse Source

测试阶段 --下载6

sophieChenyx 6 years ago
parent
commit
10dcf4e148
1 changed files with 8 additions and 5 deletions
  1. 8 5
      src/utils/request.js

+ 8 - 5
src/utils/request.js

@@ -79,10 +79,10 @@ export default function request(url, options) {
     } 
   }
   // download excel
-  if ( newOptions.DOWNLOAD ) {
-    console.log('download request');
-    delete newOptions.DOWNLOAD;
-  } 
+  // if ( newOptions.DOWNLOAD ) {
+  //   console.log('download request');
+  //   delete newOptions.DOWNLOAD;
+  // } 
 
   console.log('>>>>>>>>>newOptions',newOptions)
   return fetch(url, newOptions)
@@ -91,7 +91,10 @@ export default function request(url, options) {
       if (response.status === 204) {
         return response.text();
       }
-      console.log('fetch 中获取的response',response)
+      if ( newOptions.DOWNLOAD ) {
+        delete newOptions.DOWNLOAD;
+        return window.open(response.url);
+      } 
       return response.json();
 
     })