ruoyi-plus-soybean/env.config.ts

47 lines
934 B
TypeScript
Raw Normal View History

2023-11-17 08:45:00 +08:00
/**
2023-12-14 21:45:29 +08:00
* Create service config by current env
*
* @param env The current env
2023-11-17 08:45:00 +08:00
*/
export function createServiceConfig(env: Env.ImportMeta) {
const mockURL = 'https://mock.apifox.com/m1/3109515-0-default';
2023-11-20 21:32:55 +08:00
const serviceConfigMap: App.Service.ServiceConfigMap = {
2023-11-17 08:45:00 +08:00
dev: {
baseURL: mockURL,
otherBaseURL: {
demo: 'http://localhost:9528'
}
},
test: {
baseURL: mockURL,
otherBaseURL: {
demo: 'http://localhost:9529'
}
},
prod: {
baseURL: mockURL,
otherBaseURL: {
demo: 'http://localhost:9530'
}
}
2023-11-20 21:32:55 +08:00
};
2023-11-17 08:45:00 +08:00
const { VITE_SERVICE_ENV = 'dev' } = env;
return serviceConfigMap[VITE_SERVICE_ENV];
}
/**
2023-12-14 21:45:29 +08:00
* Get proxy pattern of service url
*
* @param key If not set, will use the default key
2023-11-17 08:45:00 +08:00
*/
2023-11-20 21:32:55 +08:00
export function createProxyPattern(key?: App.Service.OtherBaseURLKey) {
2023-11-17 08:45:00 +08:00
if (!key) {
return '/proxy';
}
return `/proxy-${key}`;
}