This commit is contained in:
AceDataCloud committed 2023-01-25 23:35:37 +08:00
1 parent a3e1a93524
commit 537ef21cf3
6 files changed
+29 -9

No files matched your search

+5 -4
View File
@@ -1,3 +1,4 @@
import { ENV_LOCAL, ENV_TEST } from '@/constants';
import { getEnv } from './env';
/**
@@ -6,9 +7,9 @@ import { getEnv } from './env';
*/
export const getDataBaseUrl = () => {
const env = getEnv();
if (env === 'local') {
if (env === ENV_LOCAL) {
return 'https://data.local.zhishuyun.com';
} else if (env === 'test') {
} else if (env === ENV_TEST) {
return 'https://data.test.zhishuyun.com';
} else {
return 'https://data.zhishuyun.com';
@@ -17,9 +18,9 @@ export const getDataBaseUrl = () => {
export const getAuthBaseUrl = () => {
const env = getEnv();
if (env === 'local') {
if (env === ENV_LOCAL) {
return 'https://auth.test.zhishuyun.com';
} else if (env === 'test') {
} else if (env === ENV_TEST) {
return 'https://auth.test.zhishuyun.com';
} else {
return 'https://auth.zhishuyun.com';
+13 -1
View File
@@ -1,7 +1,19 @@
import { ENV_LOCAL, ENV_PRODUCTION, ENV_TEST } from '@/constants';
const PATTERN_TEST_ENV = '.test.zhishuyun.com';
const PATTERN_LOCAL_ENV = '.lcoal.zhishuyun.com';
/**
* Get env of App, return local, test, production
* @returns
*/
export const getEnv = () => {
return import.meta.env.VITE_APP_ENV;
const host = window.location.host;
if (host.indexOf(PATTERN_LOCAL_ENV) > 0) {
return ENV_LOCAL;
}
if (host.indexOf(PATTERN_TEST_ENV) > 0) {
return ENV_TEST;
}
return ENV_PRODUCTION;
};