Files
dvcp_v2_webapp/examples/router/axios.js

31 lines
1.0 KiB
JavaScript
Raw Normal View History

2021-12-14 18:36:19 +08:00
import instance from 'dvcp-ui/lib/js/request'
import {Message} from 'element-ui'
let baseURLs = {
production: "/",
2022-07-27 14:26:26 +08:00
development: '/lan'
2021-12-14 18:36:19 +08:00
}
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")) {
2022-07-04 10:46:39 +08:00
config.baseURL = "/ns"
2022-06-07 16:34:09 +08:00
} else if (/\/project\/beta/.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-11-01 16:20:13 +08:00
} else if (/\/tianfuxing/.test(location.pathname)) {
config.baseURL = "/tfx"
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"
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"
2022-05-23 15:03:57 +08:00
} else if (/#url-/.test(location.hash)) {
config.baseURL = location.hash.replace(/#url-/, '/')
2022-07-26 09:34:00 +08:00
}
2022-11-01 16:20:13 +08:00
if (["/xsjr", "/omsapi", "/tfx"].includes(config.baseURL)) {
2022-07-26 09:34:00 +08:00
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