|
|
|
@ -2,21 +2,20 @@ import axios from 'axios'
@@ -2,21 +2,20 @@ import axios from 'axios'
|
|
|
|
|
import qs from 'qs' |
|
|
|
|
import { checkUrl } from './index' |
|
|
|
|
window.$glob = { |
|
|
|
|
url: '', |
|
|
|
|
params: {}, |
|
|
|
|
url: process.env.VUE_APP_BASE_API, |
|
|
|
|
ticket: '', |
|
|
|
|
query: {}, |
|
|
|
|
header: {} |
|
|
|
|
} |
|
|
|
|
// 认证方案:使用token进行请求
|
|
|
|
|
window.$glob.params.token && |
|
|
|
|
(window.$glob.header['Authorization'] = `Bearer ${window.$glob.params.token}`) |
|
|
|
|
axios.defaults.timeout = 30000 |
|
|
|
|
axios.defaults.validateStatus = function (status) { |
|
|
|
|
return status >= 200 && status <= 500 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
axios.interceptors.request.use(config => { |
|
|
|
|
if (!checkUrl(config.url)) config.url = window.$glob.url + config.url |
|
|
|
|
// 认证方案:使用Bearer
|
|
|
|
|
window.$glob.ticket && |
|
|
|
|
(config.headers['Authorization'] = `Bearer ${window.$glob.ticket}`) |
|
|
|
|
let header = window.$glob.header || {} |
|
|
|
|
config.headers = Object.assign(config.headers, header) |
|
|
|
|
let data = window.$glob.query || {} |
|
|
|
|