// 创建intercept.js,接口请求从intercept走
import store from '../store/index.js'
import { staticToken, superToken, } from './token'
import request from '@/http/request.js'
//队列
const quee = [];
//标识队列是否正在进行中,false请求进入队列立即执行,true请求进入队列排队
let wait = false;
//请求入口
export async function intercept(config){
let status = await checkStaticToken()
if (status) {
return new Promise(resolve => {
resolve(add(config))
})
}
}
//拓展请求方式
['get','post','put','patch','delete','head','options'].forEach(el => {
intercept[el] = function(url, data, conf = {}){
const options = {
url,
method: el,
...conf
}
if(el == 'post' || el == 'put') {
options.data = data;
} else {
options.params = data;
}
options.url = replaceUrl(options.url, data);
return intercept(option