mirror of
https://gitee.com/chu1204505056/vue-admin-beautiful.git
synced 2025-04-25 10:40:17 +08:00
🐛修复代码合并出现的bug
This commit is contained in:
parent
acc7c0f9ad
commit
7a86e4eda6
@ -5,7 +5,7 @@ import {
|
|||||||
contentType,
|
contentType,
|
||||||
debounce,
|
debounce,
|
||||||
invalidCode,
|
invalidCode,
|
||||||
noRoleCode,
|
noPermissionCode,
|
||||||
requestTimeout,
|
requestTimeout,
|
||||||
successCode,
|
successCode,
|
||||||
tokenName,
|
tokenName,
|
||||||
@ -19,7 +19,7 @@ import { isArray } from "@/utils/validate";
|
|||||||
let loadingInstance;
|
let loadingInstance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author chuzhixin 1204505056@qq.com
|
* @copyright chuzhixin 1204505056@qq.com
|
||||||
* @description 判断当前url是否需要加loading
|
* @description 判断当前url是否需要加loading
|
||||||
* @param {*} config
|
* @param {*} config
|
||||||
* @returns
|
* @returns
|
||||||
@ -35,7 +35,7 @@ const needLoading = (config) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author chuzhixin 1204505056@qq.com
|
* @copyright chuzhixin 1204505056@qq.com
|
||||||
* @description 处理code异常
|
* @description 处理code异常
|
||||||
* @param {*} code
|
* @param {*} code
|
||||||
* @param {*} msg
|
* @param {*} msg
|
||||||
@ -44,15 +44,12 @@ const handleCode = (code, msg) => {
|
|||||||
switch (code) {
|
switch (code) {
|
||||||
case invalidCode:
|
case invalidCode:
|
||||||
Vue.prototype.$baseMessage(msg || `后端接口${code}异常`, "error");
|
Vue.prototype.$baseMessage(msg || `后端接口${code}异常`, "error");
|
||||||
|
|
||||||
store.dispatch("user/resetAccessToken").catch(() => {});
|
store.dispatch("user/resetAccessToken").catch(() => {});
|
||||||
|
|
||||||
if (loginInterception) {
|
if (loginInterception) {
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case noRoleCode:
|
case noPermissionCode:
|
||||||
router.push({ path: "/401" }).catch(() => {});
|
router.push({ path: "/401" }).catch(() => {});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -67,7 +64,6 @@ const instance = axios.create({
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": contentType,
|
"Content-Type": contentType,
|
||||||
},
|
},
|
||||||
//withCredentials: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.interceptors.request.use(
|
instance.interceptors.request.use(
|
||||||
@ -75,6 +71,12 @@ instance.interceptors.request.use(
|
|||||||
if (store.getters["user/accessToken"]) {
|
if (store.getters["user/accessToken"]) {
|
||||||
config.headers[tokenName] = 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 (
|
if (
|
||||||
contentType === "application/x-www-form-urlencoded;charset=UTF-8" &&
|
contentType === "application/x-www-form-urlencoded;charset=UTF-8" &&
|
||||||
@ -97,7 +99,7 @@ instance.interceptors.response.use(
|
|||||||
(response) => {
|
(response) => {
|
||||||
if (loadingInstance) loadingInstance.close();
|
if (loadingInstance) loadingInstance.close();
|
||||||
|
|
||||||
const { data, config } = response;
|
const { status, data, config } = response;
|
||||||
const { code, msg } = data;
|
const { code, msg } = data;
|
||||||
// 操作正常Code数组
|
// 操作正常Code数组
|
||||||
const codeVerificationArray = isArray(successCode)
|
const codeVerificationArray = isArray(successCode)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user