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.eject(0);
|
|
|
|
|
instance.interceptors.request.use(config => {
|
2022-02-22 11:31:29 +08:00
|
|
|
if (/^\/xiushan/.test(location.pathname)) {
|
|
|
|
|
config.baseURL = "/xsjr"
|
|
|
|
|
config.url = config.url.replace(/(app|auth|admin)\//, "")
|
|
|
|
|
}
|
2021-12-14 18:36:19 +08:00
|
|
|
if (!config.withoutToken && localStorage.getItem("ui-token")) {
|
|
|
|
|
config.headers['Authorization'] = ["Bearer", localStorage.getItem("ui-token")].join(" ")
|
|
|
|
|
}
|
|
|
|
|
return config
|
|
|
|
|
}, error => Message.error(error))
|
|
|
|
|
export default instance
|