|
@@ -3,6 +3,12 @@ import axios from 'axios';
|
|
import VueAxios from 'vue-axios';
|
|
import VueAxios from 'vue-axios';
|
|
import getConfig from '../config/dev.js'
|
|
import getConfig from '../config/dev.js'
|
|
let list = getConfig()
|
|
let list = getConfig()
|
|
|
|
+const status = (res) => {
|
|
|
|
+ let regexp = /8880/
|
|
|
|
+ let r = regexp.test(res)
|
|
|
|
+
|
|
|
|
+ return r;
|
|
|
|
+}
|
|
// axios.defaults.headers.post['Content-Type'] = 'application/json';
|
|
// axios.defaults.headers.post['Content-Type'] = 'application/json';
|
|
axios.defaults.transformRequest = [function (data) {
|
|
axios.defaults.transformRequest = [function (data) {
|
|
if (data instanceof Object && !(data instanceof FormData)) {
|
|
if (data instanceof Object && !(data instanceof FormData)) {
|
|
@@ -11,41 +17,47 @@ axios.defaults.transformRequest = [function (data) {
|
|
return data;
|
|
return data;
|
|
}],
|
|
}],
|
|
|
|
|
|
-axios.defaults.baseURL = list.BASE_URL
|
|
|
|
- // 添加请求拦截器
|
|
|
|
- axios.interceptors.request.use(function (config) {
|
|
|
|
- // console.log('[ axios.config ] >', config)
|
|
|
|
- // if (config.url.startsWith("http")) {
|
|
|
|
- // return config;
|
|
|
|
- // }
|
|
|
|
- // let localhost = ''
|
|
|
|
- // if (process.env.NODE_ENV == "production") {
|
|
|
|
- // localhost = window.staticHost ? window.staticHost : "/spfm/"
|
|
|
|
- // }
|
|
|
|
- // console.log('[ axios.localhost ] >', localhost)
|
|
|
|
- // config.url = localhost + config.url
|
|
|
|
- // let url = localhost + config.url
|
|
|
|
- // console.log('[ axios.url ] >', url)
|
|
|
|
- console.log(list.BASE_URL);
|
|
|
|
- if (list.BASE_URL.indexOf('/sysmgr/sys/login/auth/captcha') == -1 && list.BASE_URL.indexOf('/sysmgr/sys/login/auth/token') == -1) {
|
|
|
|
- let token = window.sessionStorage.agileauthtoken;
|
|
|
|
- if (token != undefined && token != 'undefined') {
|
|
|
|
- token = JSON.parse(token);
|
|
|
|
|
|
+ axios.defaults.baseURL = list.BASE_URL
|
|
|
|
+// 添加请求拦截器
|
|
|
|
+axios.interceptors.request.use(function (config) {
|
|
|
|
+
|
|
|
|
+ var n = status(config.url)
|
|
|
|
+
|
|
|
|
+ // console.log('[ axios.config ] >', config)
|
|
|
|
+ // if (config.url.startsWith("http")) {
|
|
|
|
+ // return config;
|
|
|
|
+ // }
|
|
|
|
+ // let localhost = ''
|
|
|
|
+ // if (process.env.NODE_ENV == "production") {
|
|
|
|
+ // localhost = window.staticHost ? window.staticHost : "/spfm/"
|
|
|
|
+ // }
|
|
|
|
+ // console.log('[ axios.localhost ] >', localhost)
|
|
|
|
+ // config.url = localhost + config.url
|
|
|
|
+ // let url = localhost + config.url
|
|
|
|
+ // console.log('[ axios.url ] >', url)
|
|
|
|
+
|
|
|
|
+ if (list.BASE_URL.indexOf('/sysmgr/sys/login/auth/captcha') == -1 && list.BASE_URL.indexOf('/sysmgr/sys/login/auth/token') == -1) {
|
|
|
|
+ let token = window.sessionStorage.agileauthtoken;
|
|
|
|
+ if (token != undefined && token != 'undefined') {
|
|
|
|
+ token = JSON.parse(token);
|
|
|
|
+ if (n === false) {
|
|
config.headers['agileauthtoken'] = token
|
|
config.headers['agileauthtoken'] = token
|
|
- } else {
|
|
|
|
- global.$vm.$notify.error({
|
|
|
|
- title: '提示',
|
|
|
|
- message: '登录超时'
|
|
|
|
- })
|
|
|
|
- global.$vm.$router.push('/login')
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ global.$vm.$notify.error({
|
|
|
|
+ title: '提示',
|
|
|
|
+ message: '登录超时'
|
|
|
|
+ })
|
|
|
|
+ global.$vm.$router.push('/login')
|
|
}
|
|
}
|
|
- // 在发送请求之前做些什么
|
|
|
|
- return config;
|
|
|
|
- }, function (error) {
|
|
|
|
- // 对请求错误做些什么
|
|
|
|
- return Promise.reject(error);
|
|
|
|
- });
|
|
|
|
|
|
+ }
|
|
|
|
+ // 在发送请求之前做些什么
|
|
|
|
+ return config;
|
|
|
|
+}, function (error) {
|
|
|
|
+ // 对请求错误做些什么
|
|
|
|
+ return Promise.reject(error);
|
|
|
|
+});
|
|
|
|
|
|
|
|
|
|
// // 添加响应拦截器
|
|
// // 添加响应拦截器
|