diff --git a/.env-config.ts b/.env-config.ts new file mode 100644 index 0000000..2b25ebd --- /dev/null +++ b/.env-config.ts @@ -0,0 +1,57 @@ +/** 请求服务的环境配置 */ +type ServiceEnv = Record; + +/** 不同请求服务的环境配置 */ +export const serviceEnv: ServiceEnv = { + dev: { + // url: 'http://huaerda-api.24yt.com', + url: 'http://106.227.80.14:8086/', + // url: 'http://127.0.0.1:8080/', + // url: 'http://192.168.9.89:8080', + // url: 'http://192.168.20.80:8080', + // url: 'http://192.168.110.65:8080', + kkFileUrl: 'http://192.168.9.68:8012', + reportServerUrl: 'http://192.168.9.128:9908' + // reportServerUrl: 'http://huaerda-jimu.24yt.com/'6 + }, + test: { + url: 'http://106.227.80.14:8088/', + // url: 'http://192.168.9.128:8080' + kkFileUrl: 'http://192.168.9.68:8012', + // reportServerUrl: 'http://192.168.9.128:9908' + reportServerUrl: 'http://huaerda-jimu.24yt.com/' + }, + prod: { + // url: 'http://192.168.9.149:8021' + // url: 'http://huaerda-api.24yt.com', + url: 'http://106.227.80.14:8088/', + kkFileUrl: 'http://kkfile.24yt.com', + // reportServerUrl: 'http://localhost:9908' + reportServerUrl: 'http://huaerda-jimu.24yt.com/' + } +}; +if (typeof window !== 'undefined') { + const protocol = window.location.protocol; + if (protocol === 'https:') { + // serviceEnv.dev.url = 'https://192.168.9.237:8182'; + serviceEnv.dev.url = 'http://106.227.80.14:8088/'; + serviceEnv.test.url = 'http://106.227.80.14:8088/'; + // serviceEnv.prod.url = 'https://huaerda-api.24yt.com'; + serviceEnv.prod.url = 'http://106.227.80.14:8088/'; + serviceEnv.prod.reportServerUrl = 'https://huaerda-jimu.24yt.com/'; + } +} +/** + * 获取当前环境模式下的请求服务的配置 + * @param env 环境 + */ +export function getServiceEnvConfig(env: ImportMetaEnv): ServiceEnvConfigWithProxyPattern { + const { VITE_SERVICE_ENV = 'dev' } = env; + + const config = serviceEnv[VITE_SERVICE_ENV]; + + return { + ...config, + proxyPattern: '/api' + }; +}