🐛修复代码合并出现的bug

This commit is contained in:
chuzhixin 2020-09-09 14:49:50 +08:00
parent acc7c0f9ad
commit 7a86e4eda6

View File

@ -5,7 +5,7 @@ import {
contentType,
debounce,
invalidCode,
noRoleCode,
noPermissionCode,
requestTimeout,
successCode,
tokenName,
@ -19,7 +19,7 @@ import { isArray } from "@/utils/validate";
let loadingInstance;
/**
* @author chuzhixin 1204505056@qq.com
* @copyright chuzhixin 1204505056@qq.com
* @description 判断当前url是否需要加loading
* @param {*} config
* @returns
@ -35,7 +35,7 @@ const needLoading = (config) => {
};
/**
* @author chuzhixin 1204505056@qq.com
* @copyright chuzhixin 1204505056@qq.com
* @description 处理code异常
* @param {*} code
* @param {*} msg
@ -44,15 +44,12 @@ const handleCode = (code, msg) => {
switch (code) {
case invalidCode:
Vue.prototype.$baseMessage(msg || `后端接口${code}异常`, "error");
store.dispatch("user/resetAccessToken").catch(() => {});
if (loginInterception) {
location.reload();
}
break;
case noRoleCode:
case noPermissionCode:
router.push({ path: "/401" }).catch(() => {});
break;
default:
@ -67,7 +64,6 @@ const instance = axios.create({
headers: {
"Content-Type": contentType,
},
//withCredentials: true,
});
instance.interceptors.request.use(
@ -75,6 +71,12 @@ instance.interceptors.request.use(
if (store.getters["user/accessToken"]) {
config.headers[tokenName] = store.getters["user/accessToken"];
}
//这里会过滤所有为空、0、false的key如果不需要请自行注释
if (config.data)
config.data = Vue.prototype.$baseLodash.pickBy(
config.data,
Vue.prototype.$baseLodash.identity
);
if (
contentType === "application/x-www-form-urlencoded;charset=UTF-8" &&
@ -97,7 +99,7 @@ instance.interceptors.response.use(
(response) => {
if (loadingInstance) loadingInstance.close();
const { data, config } = response;
const { status, data, config } = response;
const { code, msg } = data;
// 操作正常Code数组
const codeVerificationArray = isArray(successCode)