投票流程大改
This commit is contained in:
@@ -9,7 +9,18 @@ const getToken = () => {
|
||||
return !!vuex ? JSON.parse(vuex).user.token : null
|
||||
}
|
||||
const source = axios.CancelToken.source();
|
||||
let throttleMap = {}
|
||||
instance.interceptors.request.use(config => {
|
||||
if (config.throttle) {// 节流处理
|
||||
let timer = throttleMap[config.url]
|
||||
if (!!timer) {
|
||||
config.cancelToken = source.token
|
||||
source.cancel("节流控制,取消请求:" + config.url)
|
||||
}
|
||||
throttleMap[config.url] = setTimeout(() => {
|
||||
throttleMap[config.url] = null
|
||||
}, config.throttle)
|
||||
}
|
||||
if (config.withoutToken) {
|
||||
return config
|
||||
} else if (getToken()) {
|
||||
|
||||
Reference in New Issue
Block a user