Selaa lähdekoodia

fix: request cache if pro site (#2519)

信鑫-King 7 vuotta sitten
vanhempi
commit
4d4e419990
1 muutettua tiedostoa jossa 7 lisäystä ja 5 poistoa
  1. 7 5
      src/utils/request.js

+ 7 - 5
src/utils/request.js

@@ -60,15 +60,17 @@ const cachedSave = (response, hashcode) => {
  * Requests a URL, returning a promise.
  * Requests a URL, returning a promise.
  *
  *
  * @param  {string} url       The URL we want to request
  * @param  {string} url       The URL we want to request
- * @param  {object} [options] The options we want to pass to "fetch"
+ * @param  {object} [option] The options we want to pass to "fetch"
  * @return {object}           An object containing either "data" or "err"
  * @return {object}           An object containing either "data" or "err"
  */
  */
 export default function request(
 export default function request(
   url,
   url,
-  options = {
-    expirys: isAntdPro(),
-  }
+  option,
 ) {
 ) {
+  const options = {
+    expirys: isAntdPro(),
+    ...option,
+  };
   /**
   /**
    * Produce fingerprints based on url and parameters
    * Produce fingerprints based on url and parameters
    * Maybe url has the same parameters
    * Maybe url has the same parameters
@@ -104,7 +106,7 @@ export default function request(
     }
     }
   }
   }
 
 
-  const expirys = options.expirys || 60;
+  const expirys = options.expirys && 60;
   // options.expirys !== false, return the cache,
   // options.expirys !== false, return the cache,
   if (options.expirys !== false) {
   if (options.expirys !== false) {
     const cached = sessionStorage.getItem(hashcode);
     const cached = sessionStorage.getItem(hashcode);