2021-12-14 18:36:19 +08:00
|
|
|
import {Message} from 'element-ui'
|
2023-04-11 10:29:57 +08:00
|
|
|
import instance from '../../ui/lib/js/request'
|
2021-12-14 18:36:19 +08:00
|
|
|
|
|
|
|
|
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"
|
2023-01-29 10:40:38 +08:00
|
|
|
} else if (/\/project\/activeAnalysis/.test(location.pathname)) {
|
|
|
|
|
config.baseURL = "/analysis"
|
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-12-28 09:56:06 +08:00
|
|
|
} else if (/\/qianxinan/.test(location.pathname)) {
|
2023-06-16 15:45:54 +08:00
|
|
|
// config.baseURL = "/qxn"
|
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"
|
2023-04-11 10:29:57 +08:00
|
|
|
} else if (/project\/oms/.test(location.pathname)) {
|
|
|
|
|
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
|
|
|
}
|
2024-04-02 17:24:55 +08:00
|
|
|
if (["/xsjr", "/tfx", "/omsapi"].includes(config.baseURL)) {
|
2023-06-09 15:49:47 +08:00
|
|
|
config.url = config.url.replace(/(app|auth|admin|api)\//, "api/")
|
|
|
|
|
}
|
2023-01-29 10:40:38 +08:00
|
|
|
if (['/qxn', '/analysis'].includes(config.baseURL)) {
|
2023-01-03 11:54:23 +08:00
|
|
|
config.url = config.url.replace(/(app|auth|admin)\//, "api/")
|
|
|
|
|
}
|
2024-04-02 17:24:55 +08:00
|
|
|
if (process.env.VUE_APP_IS_SIMPLE_SERVER == 1) {
|
|
|
|
|
config.url = config.url.replace(/(app|auth|admin)\//, "api/")
|
|
|
|
|
}
|
2021-12-14 18:36:19 +08:00
|
|
|
return config
|
|
|
|
|
}, error => Message.error(error))
|
|
|
|
|
export default instance
|