解决了多次加载中
This commit is contained in:
parent
80d159f344
commit
509c3df652
@ -11,24 +11,43 @@ import store from '@/store';
|
||||
export interface Get {
|
||||
<T>(url: string, params?: unknown, config?: AxiosRequestConfig): Promise<CustomSuccessData<T>>;
|
||||
}
|
||||
const login: MessageType[] = []
|
||||
let login: MessageType;
|
||||
let count = 0;
|
||||
axios.interceptors.request.use((config)=>{
|
||||
login.push(message.loading('加载中..', 0))
|
||||
if(count == 0){
|
||||
login = message.loading('加载中..', 0)
|
||||
}
|
||||
count++;
|
||||
return config;
|
||||
})
|
||||
|
||||
axios.interceptors.response.use((response)=>{
|
||||
// console.log(response)
|
||||
login[0]();
|
||||
login.splice(0,1);
|
||||
if(count != 0){
|
||||
setTimeout(()=>{
|
||||
count--;
|
||||
if(count == 0){
|
||||
login();
|
||||
}
|
||||
console.log(count)
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
if(response.data.code == 1001){
|
||||
store.commit("login", false)
|
||||
router.push("/")
|
||||
}
|
||||
return response;
|
||||
},(error)=>{
|
||||
login[0]();
|
||||
login.splice(0,1);
|
||||
if(count != 0){
|
||||
setTimeout(()=>{
|
||||
count--;
|
||||
if(count == 0){
|
||||
login();
|
||||
}
|
||||
console.log(count)
|
||||
}, 1000)
|
||||
}
|
||||
message.error(error.response.data.message)
|
||||
return Promise.reject(error)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user