2021-12-14 18:36:19 +08:00
|
|
|
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 => {
|
2022-03-30 19:20:44 +08:00
|
|
|
if (config.url.startsWith("/node")) {
|
|
|
|
|
config.baseURL = "/ns"
|
2022-05-27 11:51:18 +08:00
|
|
|
} else if (/\/project\/grid/.test(location.pathname)) {
|
2022-05-30 18:46:47 +08:00
|
|
|
config.baseURL = "/wg"
|
2022-04-28 16:25:30 +08:00
|
|
|
} else if (/\/project\/sass/.test(location.pathname)) {
|
|
|
|
|
config.baseURL = "/saas"
|
2022-03-30 19:20:44 +08:00
|
|
|
} else if (/\/xiushan/.test(location.pathname)) {
|
2022-02-22 11:31:29 +08:00
|
|
|
config.baseURL = "/xsjr"
|
|
|
|
|
config.url = config.url.replace(/(app|auth|admin)\//, "")
|
2022-03-30 19:20:44 +08:00
|
|
|
} else if (/project\/oms/.test(location.pathname)) {
|
2022-03-14 11:38:06 +08:00
|
|
|
config.baseURL = "/omsapi"
|
|
|
|
|
config.url = config.url.replace(/(app|auth|admin)\//, "")
|
2022-05-23 15:03:57 +08:00
|
|
|
} 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)\//, "")
|
|
|
|
|
}
|
2022-02-22 11:31:29 +08:00
|
|
|
}
|
2021-12-14 18:36:19 +08:00
|
|
|
return config
|
|
|
|
|
}, error => Message.error(error))
|
|
|
|
|
export default instance
|