devApiEnvironments.ts
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/** 各环境 URL 定义;切换请改 `activeDevApiEnv.ts` 中的 `ACTIVE_DEV_API_ENV` */
export type DevApiEnvKey = 'test' | 'prod' | 'local-125' | 'local-6901' | 'local-108';
export interface ApiEnvConfig {
apiUrl: string;
baseUrl: string;
label: string;
}
/** 开发态可切换的 API 预设(与 `.env.development` 历史注释块对齐) */
export const DEV_API_ENVIRONMENTS: Record<DevApiEnvKey, ApiEnvConfig> = {
test: {
label: '测试 aus.test',
apiUrl: 'https://aus.test.glsx.com.cn/app/api/',
baseUrl: 'https://aus.test.glsx.com.cn/app/',
},
prod: {
label: '生产 aus',
apiUrl: 'https://aus.glsx.com.cn/app/api/',
baseUrl: 'https://aus.glsx.com.cn/app/',
},
'local-125': {
label: '内网 192.168.1.125',
apiUrl: 'http://192.168.1.125:6901/api/',
baseUrl: 'http://192.168.1.125:6901/',
},
'local-6901': {
label: '本机 localhost:6901',
apiUrl: 'http://localhost:6901/api/',
baseUrl: 'http://localhost:6901/',
},
'local-108': {
label: '内网 192.168.0.108',
apiUrl: 'http://192.168.0.108:5001/rest/api/',
baseUrl: 'http://192.168.0.108:5001/rest/',
},
};
export const DEV_API_ENV_KEYS = Object.keys(DEV_API_ENVIRONMENTS) as DevApiEnvKey[];
export function isDevApiEnvKey(key: string): key is DevApiEnvKey {
return (DEV_API_ENV_KEYS as string[]).includes(key);
}