king
2019-12-10 88f02c2c018fb1e5c171bd4975dac534c584c3ba
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
      })
    }
  }
  /**