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