| | |
| | | // 调用后台管理的 |
| | | const service = axios.create({ |
| | | timeout: 600000, // request timeout |
| | | headers: { "Content-Type": "application/json;charset=gbk" }, |
| | | }); |
| | | |
| | | // 返回其他状态码 |
| | | service.defaults.validateStatus = function (status) { |
| | | return status >= 200 && status <= 500; |
| | | }; |
| | | |
| | | // 跨域请求,允许保存cookie |
| | | // service.defaults.withCredentials = true |
| | | |
| | | // http request拦截 |
| | | service.interceptors.request.use( |
| | | (config) => { |
| | | if (!config.data) { |
| | | config.data = true // 解决请求没有参数时添加不上Content-Type问题 |
| | | } |
| | | config.headers['Content-type'] = 'application/json;charset=gbk' |
| | | store.commit('updateoverlayshow'); |
| | | if (config.apiKey) { |
| | | config.headers["Authorization"] = "Basic c2FiZXI6c2FiZXJfc2VjcmV0"; |
| | | config.headers["Content-Type"] = "application/json;charset=gbk"; |
| | | if (getToken() != undefined) { |
| | | config.headers["Blade-Auth"] = "bearer " + getToken(); |
| | | } |