|
|
@@ -8,11 +8,19 @@
|
|
|
import axios from 'axios';
|
|
|
import store from '@/store/';
|
|
|
import router from '@/router/router';
|
|
|
-import {serialize} from '@/util/util';
|
|
|
-import {getToken} from '@/util/auth';
|
|
|
-import {Message} from 'element-ui';
|
|
|
+import {
|
|
|
+ serialize
|
|
|
+} from '@/util/util';
|
|
|
+import {
|
|
|
+ getToken
|
|
|
+} from '@/util/auth';
|
|
|
+import {
|
|
|
+ Message
|
|
|
+} from 'element-ui';
|
|
|
import website from '@/config/website';
|
|
|
-import {Base64} from 'js-base64';
|
|
|
+import {
|
|
|
+ Base64
|
|
|
+} from 'js-base64';
|
|
|
import NProgress from 'nprogress';
|
|
|
import 'nprogress/nprogress.css';
|
|
|
import crypto from '@/util/crypto.js';
|
|
|
@@ -21,7 +29,7 @@ import crypto from '@/util/crypto.js';
|
|
|
//默认超时时间
|
|
|
axios.defaults.timeout = 10000;
|
|
|
//返回其他状态码
|
|
|
-axios.defaults.validateStatus = function (status) {
|
|
|
+axios.defaults.validateStatus = function(status) {
|
|
|
return status >= 200 && status <= 500;
|
|
|
};
|
|
|
//跨域请求,允许保存cookie
|
|
|
@@ -51,10 +59,9 @@ axios.interceptors.request.use(config => {
|
|
|
config.data = serialize(config.data);
|
|
|
}
|
|
|
//报文加密
|
|
|
- console.log(config.method === 'post',"/*************");
|
|
|
- if (config.method === 'post' && config.data) {
|
|
|
+ if (config.method === 'post' && config.data && crypto.isNotInWhiteList(config.url)) {
|
|
|
let encrypt = crypto.encrypt(JSON.stringify(config.data))
|
|
|
- config.data=encrypt
|
|
|
+ config.data = encrypt
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -73,7 +80,9 @@ axios.interceptors.response.use(res => {
|
|
|
//如果在白名单里则自行catch逻辑处理
|
|
|
if (statusWhiteList.includes(status)) return Promise.reject(res);
|
|
|
//如果是401则跳转到登录页面
|
|
|
- if (status === 401) store.dispatch('FedLogOut').then(() => router.push({path: '/login'}));
|
|
|
+ if (status === 401) store.dispatch('FedLogOut').then(() => router.push({
|
|
|
+ path: '/login'
|
|
|
+ }));
|
|
|
// 如果请求为非200否者默认统一处理
|
|
|
if (status !== 200) {
|
|
|
Message({
|