bug
Codex Assistant
2025-11-05 3714621173c606c4c58439ed8941100ce9ddea14
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
44
45
46
47
48
49
50
51
52
53
54
import { graphqlRequest } from '../config/api.ts';
 
export const serverUrl =
  (typeof window !== 'undefined' && window.__APP_SERVER_URL__) ||
  (typeof import.meta !== 'undefined' && import.meta.env && import.meta.env.VITE_SERVER_URL) ||
  'http://139.155.104.10:8080';
 
 
 
const GET_APP_CONFIG = `
 
  query AppConfig {
 
    appConfig {
 
      mediaBaseUrl
 
    }
 
  }
 
`;
 
 
 
export async function loadAppConfig() {
 
  try {
 
    const result = await graphqlRequest(GET_APP_CONFIG);
 
    const mediaBaseUrl = result.data?.appConfig?.mediaBaseUrl || '';
 
    // 作为全局变量暴露
 
    window.__APP_MEDIA_BASE_URL__ = mediaBaseUrl;
 
    return mediaBaseUrl;
 
  } catch (e) {
 
    // 如果GraphQL查询失败,使用默认配置
 
    console.warn('loadAppConfig failed, using default config:', e?.message || e);
 
    const defaultMediaBaseUrl = serverUrl;
 
    window.__APP_MEDIA_BASE_URL__ = defaultMediaBaseUrl;
 
    return defaultMediaBaseUrl;
 
  }
 
}