优化某些情况下登录权限问题

master
paulGao 2022-07-06 16:22:46 +08:00 committed by 学习很差啦
parent b840a0adf1
commit ba02c6ca7d
1 changed files with 23 additions and 24 deletions

View File

@ -112,7 +112,7 @@ http.interceptors.response.use(
// cleanStorage(); // cleanStorage();
// isRefreshing = false; // isRefreshing = false;
// } // }
console.log(response)
let token = storage.getAccessToken(); let token = storage.getAccessToken();
if ( if (
(token && response.statusCode === 403) || (token && response.statusCode === 403) ||
@ -131,7 +131,7 @@ http.interceptors.response.use(
response.header.accessToken = `${accessToken}`; response.header.accessToken = `${accessToken}`;
// token 刷新后将数组的方法重新执行 // token 刷新后将数组的方法重新执行
console.log('接口队列',requests,'新token',accessToken) // console.log('接口队列', requests, '新token', accessToken)
requests.forEach((cb) => cb(accessToken)); requests.forEach((cb) => cb(accessToken));
requests = []; // 重新请求完清空 requests = []; // 重新请求完清空
return http.request(response.config); return http.request(response.config);
@ -154,13 +154,12 @@ http.interceptors.response.use(
}); });
}); });
} }
// 如果当前返回没登录 // 如果当前返回没登录
} else if ( } else if (
(!token && !storage.getRefreshToken() && response.statusCode === 403) || (!token && !storage.getRefreshToken() && response.statusCode === 403) ||
response.data.code === 403 response.data.code === 403 || response.data.code === 20004
) { ) {
console.log('没有token 以及刷新token 内容',token,storage.getRefreshToken()) // console.log('没有token 以及刷新token 内容', token, storage.getRefreshToken())
cleanStorage(); cleanStorage();
// 如果当前状态码为正常但是success为不正常时 // 如果当前状态码为正常但是success为不正常时