投票流程大改

This commit is contained in:
aixianling
2023-01-03 15:06:38 +08:00
parent dd134b6b23
commit 609b697440
5 changed files with 99 additions and 17 deletions

View File

@@ -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()) {