|
@@ -14,6 +14,7 @@ Vue.use(ElementUI);
|
|
|
|
|
|
const qmInstance = axios.create({});
|
|
|
let wk_token;
|
|
|
+let wk_key;
|
|
|
// 正在处理的请求数
|
|
|
window.requestInProcessingTotal = 0;
|
|
|
// 并发的总错误数
|
|
@@ -23,19 +24,24 @@ window.faceppConcurrencyErrorNumPerMinute = 0;
|
|
|
let faceppConCurrencyErrorArray = [];
|
|
|
qmInstance.interceptors.request.use(
|
|
|
config => {
|
|
|
- if (config.url.includes("/login") === false) {
|
|
|
- if (!wk_token) {
|
|
|
- wk_token = window.localStorage.getItem("token");
|
|
|
- }
|
|
|
- if (wk_token && config.headers.common["token"] == null) {
|
|
|
- config.headers.common["key"] = window.localStorage.getItem("key");
|
|
|
- config.headers.common["token"] = wk_token;
|
|
|
+ if (config.url.startsWith("/")) {
|
|
|
+ if (config.url.includes("/login") === false) {
|
|
|
+ if (!wk_token) {
|
|
|
+ wk_token = window.localStorage.getItem("token");
|
|
|
+ wk_key = window.localStorage.getItem("key");
|
|
|
+ }
|
|
|
+ if (wk_token && config.headers.common["token"] == null) {
|
|
|
+ config.headers.common["key"] = wk_key;
|
|
|
+ config.headers.common["token"] = wk_token;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ wk_token = null;
|
|
|
}
|
|
|
- } else {
|
|
|
- wk_token = null;
|
|
|
}
|
|
|
|
|
|
- window.requestInProcessingTotal++;
|
|
|
+ if (config.url.startsWith("https://api-cn.faceplusplus.com")) {
|
|
|
+ window.requestInProcessingTotal++;
|
|
|
+ }
|
|
|
|
|
|
return config;
|
|
|
},
|
|
@@ -62,7 +68,9 @@ function calcErrorPerMinute(now) {
|
|
|
//响应拦截
|
|
|
qmInstance.interceptors.response.use(
|
|
|
response => {
|
|
|
- window.requestInProcessingTotal--;
|
|
|
+ if (response.config.url.startsWith("https://api-cn.faceplusplus.com")) {
|
|
|
+ window.requestInProcessingTotal--;
|
|
|
+ }
|
|
|
|
|
|
// 相当于timer的作用
|
|
|
const now = Date.now();
|
|
@@ -70,7 +78,9 @@ qmInstance.interceptors.response.use(
|
|
|
return response;
|
|
|
},
|
|
|
error => {
|
|
|
- window.requestInProcessingTotal--;
|
|
|
+ if (error.config.url.startsWith("https://api-cn.faceplusplus.com")) {
|
|
|
+ window.requestInProcessingTotal--;
|
|
|
+ }
|
|
|
// 这里是返回状态码不为200时候的错误处理
|
|
|
const status = error.response.status;
|
|
|
if (status != 200) {
|
|
@@ -142,13 +152,11 @@ axiosRetry(qmInstance, {
|
|
|
`below error status code: ${err.response.status} and retry ...`
|
|
|
);
|
|
|
console.log(err);
|
|
|
- console.log();
|
|
|
return true;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
Vue.prototype.$http = qmInstance;
|
|
|
-
|
|
|
new Vue({
|
|
|
router,
|
|
|
render: h => h(App)
|