From 88f02c2c018fb1e5c171bd4975dac534c584c3ba Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 10 十二月 2019 09:31:37 +0800
Subject: [PATCH] 2019-12-10

---
 src/api/index.js |   45 +++++++++++++++++++++++++++++++++------------
 1 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/src/api/index.js b/src/api/index.js
index 46f3a15..150fdb4 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -22,17 +22,19 @@
   return Promise.reject(error)
 })
 
-// const setCurrentUrl = () => {
-//   if (!!(window.history && window.history.pushState)) {
-//     window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login')
-//     window.location.reload()
-//   }
-// }
+const setCurrentUrl = () => {
+  if (!!(window.history && window.history.pushState)) {
+    window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login')
+    window.location.reload()
+  }
+}
+
+let GlobMap = new Map()
 
 axios.interceptors.response.use((response) => {
   if (response.data.ErrCode === 'LoginError') {
-    // setCurrentUrl()
-    return Promise.resolve(response.data)
+    setCurrentUrl()
+    // return Promise.resolve(response.data)
   } else {
     return Promise.resolve(response.data)
   }
@@ -127,10 +129,29 @@
     if (window.GLOB.mainSystemApi) {
       param.rduri = window.GLOB.mainSystemApi
     }
-    return axios({
-      url: '/webapi/dostar',
-      data: param
-    })
+    if (param.isCache) { // 鏁版嵁闇�瑕佺紦瀛樻椂
+      delete param.isCache
+      
+      if (GlobMap.has(param)) {
+        return Promise.resolve(GlobMap.get(param))
+      } else {
+        return new Promise(resolve => {
+          axios({
+            url: '/webapi/dostar',
+            data: param
+          }).then(res => {
+            console.log(res)
+            GlobMap.set(param, res)
+            resolve(res)
+          })
+        })
+      }
+    } else {
+      return axios({
+        url: '/webapi/dostar',
+        data: param
+      })
+    }
   }
 
   /**

--
Gitblit v1.8.0