From 39e40b6783e01884634fbf53842179ce6229434d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=99=AE=E5=BB=BA?= <450837357@qq.com> Date: Sun, 16 Mar 2025 09:23:34 +0800 Subject: [PATCH] first --- .env-config.ts | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .env-config.ts 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' + }; +}