refactor(projects): 代码优化

This commit is contained in:
Soybean
2022-07-16 00:13:19 +08:00
parent 872bb84502
commit 6143605297
24 changed files with 107 additions and 104 deletions

View File

@ -1,30 +1,30 @@
/** 请求环境配置 */
type ServiceEnv = Record<EnvType, EnvConfig>;
type ServiceEnv = Record<ServiceEnvType, ServiceEnvConfig>;
/** 环境配置 */
const serviceEnvConfig: ServiceEnv = {
/** 不同服务的环境配置 */
const serviceEnv: ServiceEnv = {
dev: {
url: 'http://localhost:8080',
proxy: '/api'
proxy: '/proxy-flag'
},
test: {
url: 'http://localhost:8080',
proxy: '/api'
proxy: '/proxy-flag'
},
prod: {
url: 'http://localhost:8080',
proxy: '/api'
proxy: '/proxy-flag'
}
};
/**
* 获取环境配置
* @param env 环境描述
* 获取当前模式的环境配置
* @param env 环境
*/
export function getEnvConfig(env: ImportMetaEnv) {
const { VITE_ENV_TYPE = 'dev' } = env;
const envConfig = serviceEnvConfig[VITE_ENV_TYPE];
const envConfig = serviceEnv[VITE_ENV_TYPE];
return envConfig;
}