Files
dvcp_v2_webapp/examples/router/axios.js
aixianling 47d44a94b8 BUG 30018
2022-06-07 16:34:09 +08:00

32 lines
1.1 KiB
JavaScript

import instance from 'dvcp-ui/lib/js/request'
import {Message} from 'element-ui'
let baseURLs = {
production: "/",
development: '/lan',
oms: '/oms'
}
instance.defaults.baseURL = baseURLs[process.env.NODE_ENV]
instance.interceptors.request.use(config => {
if (config.url.startsWith("/node")) {
config.baseURL = "/ns"
} else if (/\/project\/beta/.test(location.pathname)) {
config.baseURL = "/wg"
} else if (/\/project\/sass/.test(location.pathname)) {
config.baseURL = "/saas"
} else if (/\/xiushan/.test(location.pathname)) {
config.baseURL = "/xsjr"
config.url = config.url.replace(/(app|auth|admin)\//, "")
} else if (/project\/oms/.test(location.pathname)) {
config.baseURL = "/omsapi"
config.url = config.url.replace(/(app|auth|admin)\//, "")
} else if (/#url-/.test(location.hash)) {
config.baseURL = location.hash.replace(/#url-/, '/')
if (["/xsjr", "/omsapi"].includes(config.baseURL)) {
config.url = config.url.replace(/(app|auth|admin)\//, "")
}
}
return config
}, error => Message.error(error))
export default instance