提交 | 用户 | age
|
bb3b8f
|
1 |
import type { GlobEnvConfig } from '/@/types/config'; |
N |
2 |
|
8a9ca4
|
3 |
import { useGlobSetting } from '/@/hooks/setting'; |
V |
4 |
import pkg from '../../package.json'; |
|
5 |
|
236575
|
6 |
/** |
V |
7 |
* Get the global configuration (the configuration will be extracted independently when packaging) |
|
8 |
*/ |
144ab5
|
9 |
export function getGlobEnvConfig(): GlobEnvConfig { |
bb3b8f
|
10 |
const env = import.meta.env; |
N |
11 |
return (env as unknown) as GlobEnvConfig; |
144ab5
|
12 |
} |
bb3b8f
|
13 |
|
8a9ca4
|
14 |
// Generate cache key according to version |
V |
15 |
export function getStorageShortName() { |
|
16 |
const globSetting = useGlobSetting(); |
|
17 |
return `${globSetting.shortName}__${getEnv()}${`__${pkg.version}`}__`.toUpperCase(); |
|
18 |
} |
|
19 |
|
2f6253
|
20 |
/** |
236575
|
21 |
* @description: Development model |
2f6253
|
22 |
*/ |
陈 |
23 |
export const devMode = 'development'; |
|
24 |
|
|
25 |
/** |
236575
|
26 |
* @description: Production mode |
2f6253
|
27 |
*/ |
陈 |
28 |
export const prodMode = 'production'; |
|
29 |
|
|
30 |
/** |
236575
|
31 |
* @description: Get environment variables |
2f6253
|
32 |
* @returns: |
陈 |
33 |
* @example: |
|
34 |
*/ |
144ab5
|
35 |
export function getEnv(): string { |
V |
36 |
return import.meta.env.MODE; |
|
37 |
} |
2f6253
|
38 |
|
陈 |
39 |
/** |
236575
|
40 |
* @description: Is it a development mode |
2f6253
|
41 |
* @returns: |
陈 |
42 |
* @example: |
|
43 |
*/ |
144ab5
|
44 |
export function isDevMode(): boolean { |
V |
45 |
return import.meta.env.DEV; |
|
46 |
} |
2f6253
|
47 |
|
陈 |
48 |
/** |
236575
|
49 |
* @description: Is it a production mode |
2f6253
|
50 |
* @returns: |
陈 |
51 |
* @example: |
|
52 |
*/ |
144ab5
|
53 |
export function isProdMode(): boolean { |
V |
54 |
return import.meta.env.PROD; |
|
55 |
} |
2f6253
|
56 |
|
陈 |
57 |
/** |
236575
|
58 |
* @description: Whether to open mock |
2f6253
|
59 |
* @returns: |
陈 |
60 |
* @example: |
|
61 |
*/ |
144ab5
|
62 |
export function isUseMock(): boolean { |
V |
63 |
return import.meta.env.VITE_USE_MOCK === 'true'; |
|
64 |
} |