Commit 2ffd29d4 authored by Nature's avatar Nature
parents 159c106c db5644fe
// 引入axios
import axios from 'axios'
import hlsPopup from './hlsPopup'
......@@ -7,6 +6,9 @@ let cancel = {}
const CancelToken = axios.CancelToken
// 请求拦截器
axios.interceptors.request.use(config => {
config.cancelToken = new CancelToken(c => {
cancel = c
})
// 发起请求时,取消掉当前正在进行的相同请求
if (promiseArr[config.url]) {
promiseArr[config.url]('操作取消')
......@@ -14,9 +16,6 @@ axios.interceptors.request.use(config => {
} else {
promiseArr[config.url] = cancel
}
config.cancelToken = new CancelToken(c => {
cancel = c
})
return config
}, error => {
return Promise.reject(error)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment