diff --git a/src/utils/request.ts b/src/utils/request.ts index c2c9674..ba2e479 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -25,6 +25,21 @@ export const globalHeaders = () => { axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'; axios.defaults.headers['clientid'] = import.meta.env.VITE_APP_CLIENT_ID; + +//请求地址处理,兼容使用模块化,wms分为wms1\2\3多个微服务端口 +const getUrl = () =>{ + let routeType = router.currentRoute.value.query.routeType + if(!routeType) return "/wms/" + if(routeType == '1'){ + return "/wms1/" + } + if(routeType == '2'){ + return "/wms2/" + } + if(routeType == '3'){ + return "/wms3/" + } +} // 创建 axios 实例 const service = axios.create({ baseURL: import.meta.env.VITE_APP_BASE_API, @@ -34,6 +49,12 @@ const service = axios.create({ // 请求拦截器 service.interceptors.request.use( (config: InternalAxiosRequestConfig) => { + + // 请求地址处理,兼容使用模块化,wms分为wms1\2\3多个微服务端口 + config.url = config.url.replaceAll('/wms/',getUrl()) + console.log(config.url); + + // 对应国际化资源文件后缀 config.headers['Content-Language'] = getLanguage();