| | |
| | | import axios from 'axios'; |
| | | import { ElMessage } from 'element-plus'; |
| | | |
| | | const openLog = false; |
| | | const debug = true; |
| | | |
| | | let ip1 = 'http://47.100.191.150:9029/'; |
| | |
| | | } |
| | | |
| | | if (debug) { |
| | | ip1 = 'http://192.168.0.110:8084/'; |
| | | // ip1 = 'http://locahost:8084/'; |
| | | ws = `192.168.0.110:9031`; |
| | | ip1 = 'http://192.168.0.103:8084/'; |
| | | // ip1 = 'http://localhost:8084/'; |
| | | ws = `192.168.0.103:9031`; |
| | | // ws = `localhost:9031`; |
| | | } |
| | | |
| | | const $http = axios.create({ |
| | |
| | | i.interceptors.request.use( |
| | | function (config) { |
| | | // 在发送请求之前做些什么 |
| | | if (import.meta.env.DEV) { |
| | | if (import.meta.env.DEV && openLog) { |
| | | console.log('==>请求开始'); |
| | | console.log(`${config.baseURL}${config.url}`); |
| | | if (config.data) { |
| | |
| | | }, |
| | | function (error) { |
| | | // 对请求错误做些什么 |
| | | if (import.meta.env.DEV) { |
| | | if (import.meta.env.DEV && openLog) { |
| | | console.log('==>请求开始'); |
| | | console.log(error); |
| | | } |
| | |
| | | function (response) { |
| | | // 2xx 范围内的状态码都会触发该函数。 |
| | | // 对响应数据做点什么 |
| | | if (import.meta.env.DEV) { |
| | | if (import.meta.env.DEV && openLog) { |
| | | console.log(response); |
| | | console.log('==>请求结束'); |
| | | } |
| | |
| | | function (error) { |
| | | // 超出 2xx 范围的状态码都会触发该函数。 |
| | | // 对响应错误做点什么 |
| | | if (import.meta.env.DEV) { |
| | | if (import.meta.env.DEV && openLog) { |
| | | console.log(error); |
| | | console.log('==>请求结束'); |
| | | } |