Blame view

src/utils/env.ts 1.04 KB
1
2
import type { GlobEnvConfig } from '/@/types/config';
vben authored
3
4
5
/**
 * Get the global configuration (the configuration will be extracted independently when packaging)
 */
6
export function getGlobEnvConfig(): GlobEnvConfig {
7
8
  const env = import.meta.env;
  return (env as unknown) as GlobEnvConfig;
9
}
10
陈文彬 authored
11
/**
vben authored
12
 * @description: Development model
陈文彬 authored
13
14
15
16
 */
export const devMode = 'development';

/**
vben authored
17
 * @description: Production mode
陈文彬 authored
18
19
20
21
 */
export const prodMode = 'production';

/**
vben authored
22
 * @description: Get environment variables
陈文彬 authored
23
24
25
 * @returns:
 * @example:
 */
26
27
28
export function getEnv(): string {
  return import.meta.env.MODE;
}
陈文彬 authored
29
30

/**
vben authored
31
 * @description: Is it a development mode
陈文彬 authored
32
33
34
 * @returns:
 * @example:
 */
35
36
37
export function isDevMode(): boolean {
  return import.meta.env.DEV;
}
陈文彬 authored
38
39

/**
vben authored
40
 * @description: Is it a production mode
陈文彬 authored
41
42
43
 * @returns:
 * @example:
 */
44
45
46
export function isProdMode(): boolean {
  return import.meta.env.PROD;
}
陈文彬 authored
47
48

/**
vben authored
49
 * @description: Whether to open mock
陈文彬 authored
50
51
52
 * @returns:
 * @example:
 */
53
54
55
export function isUseMock(): boolean {
  return import.meta.env.VITE_USE_MOCK === 'true';
}