钟铮锁App web部分 需要打包放进对应的安卓项目 生成apk 才能正常使用功能
he wei
2024-12-20 552a8341d159e463e2946074e21deddb185c90ee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import axios from "axios";
 
import config from "./config";
const { serviceIp } = config;
 
if (process.env.NODE_ENV == "development") {
  // 跨域请求
  axios.defaults.baseURL = "http://localhost:8100/bl/";
  axios.defaults.withCredentials = true; // 保持请求头
} else {
  axios.defaults.baseURL = location.protocol + "//" + serviceIp + ":8100/bl/";
  // axios.defaults.baseURL = 'http:' + "//" + serviceIp + ":8100/bl/";
  // axios.defaults.baseURL = location.protocol + "//" + serviceIp + ":8443/bl/";
}
 
 
// 添加请求拦截器
axios.interceptors.request.use(
  function (config) {
    // 在发送请求之前做些什么
    return config;
  },
  function (error) {
    // 对请求错误做些什么
    return Promise.reject(error);
  }
);
 
// 添加响应拦截器
axios.interceptors.response.use(
  function (response) {
    // 对响应数据做点什么
    return response;
  },
  function (error) {
    return Promise.reject(error);
  }
);
 
export default axios;