mirror of
https://gitee.com/chu1204505056/vue-admin-beautiful.git
synced 2025-04-06 03:58:00 +08:00
commit
2f1e44ecd7
@ -18,22 +18,6 @@ import { isArray } from "@/utils/validate";
|
||||
|
||||
let loadingInstance;
|
||||
|
||||
/**
|
||||
* @author chuzhixin 1204505056@qq.com (不想保留author可删除)
|
||||
* @description 判断当前url是否需要加loading
|
||||
* @param {*} config
|
||||
* @returns
|
||||
*/
|
||||
const needLoading = (config) => {
|
||||
let status = false;
|
||||
debounce.forEach((item) => {
|
||||
if (Vue.prototype.$baseLodash.includes(config.url, item)) {
|
||||
status = true;
|
||||
}
|
||||
});
|
||||
return status;
|
||||
};
|
||||
|
||||
/**
|
||||
* @author chuzhixin 1204505056@qq.com (不想保留author可删除)
|
||||
* @description 处理code异常
|
||||
@ -77,17 +61,14 @@ instance.interceptors.request.use(
|
||||
config.data,
|
||||
Vue.prototype.$baseLodash.identity
|
||||
);
|
||||
|
||||
if (
|
||||
contentType === "application/x-www-form-urlencoded;charset=UTF-8" &&
|
||||
config.data
|
||||
) {
|
||||
config.data &&
|
||||
config.headers["Content-Type"] ===
|
||||
"application/x-www-form-urlencoded;charset=UTF-8"
|
||||
)
|
||||
config.data = qs.stringify(config.data);
|
||||
}
|
||||
|
||||
if (needLoading(config)) {
|
||||
if (debounce.some((item) => config.url.includes(item)))
|
||||
loadingInstance = Vue.prototype.$baseLoading();
|
||||
}
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
@ -99,7 +80,7 @@ instance.interceptors.response.use(
|
||||
(response) => {
|
||||
if (loadingInstance) loadingInstance.close();
|
||||
|
||||
const { status, data, config } = response;
|
||||
const { data, config } = response;
|
||||
const { code, msg } = data;
|
||||
// 操作正常Code数组
|
||||
const codeVerificationArray = isArray(successCode)
|
||||
|
Loading…
x
Reference in New Issue
Block a user