|
@@ -2,6 +2,7 @@ import axios from 'axios'
|
|
import VueAxios from 'vue-axios'
|
|
import VueAxios from 'vue-axios'
|
|
import Vue from 'vue'
|
|
import Vue from 'vue'
|
|
import router from '../router'
|
|
import router from '../router'
|
|
|
|
+import store from '../store'
|
|
import ElementUI, {
|
|
import ElementUI, {
|
|
Loading
|
|
Loading
|
|
} from 'element-ui';
|
|
} from 'element-ui';
|
|
@@ -42,7 +43,7 @@ Vue.use(VueAxios, axios);
|
|
axios.defaults.baseURL = ''; //项目的的基础url
|
|
axios.defaults.baseURL = ''; //项目的的基础url
|
|
axios.defaults.headers.common['Authorization'] = ""; //请求token信息配置
|
|
axios.defaults.headers.common['Authorization'] = ""; //请求token信息配置
|
|
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; //请求type设置
|
|
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; //请求type设置
|
|
-axios.defaults.timeout = 1000 * 48; //在超时前,所有请求都会等待相应秒数
|
|
|
|
|
|
+axios.defaults.timeout = 1000 * 60; //在超时前,所有请求都会等待相应秒数
|
|
axios.defaults.withCredentials = true;
|
|
axios.defaults.withCredentials = true;
|
|
let isInvalid1 = false //用于控制登录信息过期后弹窗时间的截流,截流时间为5s
|
|
let isInvalid1 = false //用于控制登录信息过期后弹窗时间的截流,截流时间为5s
|
|
let isInvalid2 = false
|
|
let isInvalid2 = false
|
|
@@ -52,6 +53,16 @@ axios.interceptors.request.use(function (config) {
|
|
// 在发送请求之前处理
|
|
// 在发送请求之前处理
|
|
// 判断token在前台session中是否存在
|
|
// 判断token在前台session中是否存在
|
|
config.headers.common['Authorization'] = localStorage.getItem('Authorization');
|
|
config.headers.common['Authorization'] = localStorage.getItem('Authorization');
|
|
|
|
+
|
|
|
|
+ // 解决同一个浏览器中登录多个账户时,账户页面刷新后,页面数据更新为最后一个登录的账户。
|
|
|
|
+ // console.log(store.state.username);
|
|
|
|
+ // console.log(localStorage.getItem('username'));
|
|
|
|
+ if (store.state.username &&
|
|
|
|
+ localStorage.getItem('username') &&
|
|
|
|
+ store.state.username != localStorage.getItem('username')) {
|
|
|
|
+ window.location.reload();
|
|
|
|
+ }
|
|
|
|
+
|
|
if (config.noLoading === true) { //如果noLoading为true,不加载loading画面
|
|
if (config.noLoading === true) { //如果noLoading为true,不加载loading画面
|
|
console.log("noLoading");
|
|
console.log("noLoading");
|
|
} else {
|
|
} else {
|
|
@@ -116,7 +127,7 @@ const instance = axios.create({
|
|
|
|
|
|
instance.defaults.headers.common['Authorization'] = ""; //请求token信息配置
|
|
instance.defaults.headers.common['Authorization'] = ""; //请求token信息配置
|
|
instance.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; //请求type设置
|
|
instance.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; //请求type设置
|
|
-instance.defaults.timeout = 1000 * 60 * 3; //在超时前,所有请求都会等待
|
|
|
|
|
|
+instance.defaults.timeout = 1000 * 60 * 6; //在超时前,所有请求都会等待
|
|
instance.defaults.withCredentials = true;
|
|
instance.defaults.withCredentials = true;
|
|
|
|
|
|
instance.interceptors.request.use(function (config) {
|
|
instance.interceptors.request.use(function (config) {
|