samlax12 commited on
Commit
1d60310
·
verified ·
1 Parent(s): 8cdfb67

Update config/preset.ts

Browse files
Files changed (1) hide show
  1. config/preset.ts +39 -28
config/preset.ts CHANGED
@@ -1,29 +1,40 @@
1
- // 预置配置管理
2
- interface PresetConfig {
3
- name: string;
4
- baseUrl: string;
5
- apiKey: string;
6
- }
7
-
8
- // 从环境变量读取预置配置
9
- export function getPresetConfig(): PresetConfig | null {
10
- // 在构建时从环境变量读取
11
- const baseUrl = import.meta.env.VITE_PRESET_BASE_URL;
12
- const apiKey = import.meta.env.VITE_PRESET_API_KEY;
13
- const name = import.meta.env.VITE_PRESET_NAME || '快速体验渠道';
14
-
15
- if (!baseUrl || !apiKey) {
16
- return null;
17
- }
18
-
19
- return {
20
- name,
21
- baseUrl,
22
- apiKey
23
- };
24
- }
25
-
26
- // 检查是否有预置配置
27
- export function hasPresetConfig(): boolean {
28
- return getPresetConfig() !== null;
 
 
 
 
 
 
 
 
 
 
 
29
  }
 
1
+ // 预置配置管理
2
+ interface PresetConfig {
3
+ name: string;
4
+ baseUrl: string;
5
+ apiKey: string;
6
+ }
7
+
8
+ // 从环境变量读取预置配置
9
+ export function getPresetConfig(): PresetConfig | null {
10
+ // 在构建时从环境变量读取
11
+ const baseUrl = import.meta.env.VITE_PRESET_BASE_URL;
12
+ const apiKey = import.meta.env.VITE_PRESET_API_KEY;
13
+ const name = import.meta.env.VITE_PRESET_NAME || '快速体验渠道';
14
+
15
+ // 添加调试日志
16
+ console.log('Preset config environment variables:', {
17
+ hasBaseUrl: !!baseUrl,
18
+ hasApiKey: !!apiKey,
19
+ name: name,
20
+ baseUrl: baseUrl ? '***' : undefined,
21
+ apiKey: apiKey ? '***' : undefined
22
+ });
23
+
24
+ if (!baseUrl || !apiKey) {
25
+ console.log('Preset config not available: missing baseUrl or apiKey');
26
+ return null;
27
+ }
28
+
29
+ return {
30
+ name,
31
+ baseUrl,
32
+ apiKey
33
+ };
34
+ }
35
+
36
+ // 检查是否有预置配置
37
+ export function hasPresetConfig(): boolean {
38
+ const config = getPresetConfig();
39
+ return config !== null;
40
  }