2026-04-24 16:16:31 +08:00
|
|
|
export interface XuqmInitOptions {
|
|
|
|
|
appId: string
|
2026-04-25 16:41:19 +08:00
|
|
|
serverUrl: string // e.g. "https://sentry.xuqinmin.com" — SDK fetches config from here
|
2026-04-24 16:16:31 +08:00
|
|
|
appKey?: string
|
|
|
|
|
debug?: boolean
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface XuqmConfig {
|
|
|
|
|
appId: string
|
|
|
|
|
appKey: string
|
2026-04-25 16:41:19 +08:00
|
|
|
serverUrl: string
|
|
|
|
|
apiBaseUrl: string // im-service base URL
|
|
|
|
|
imWsUrl: string // fetched from remote config
|
|
|
|
|
fileServiceUrl: string // fetched from remote config
|
2026-04-24 16:16:31 +08:00
|
|
|
debug: boolean
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let _config: XuqmConfig | null = null
|
|
|
|
|
|
2026-04-25 16:41:19 +08:00
|
|
|
export function initConfigFromRemote(
|
|
|
|
|
options: XuqmInitOptions,
|
|
|
|
|
remote: { imWsUrl: string; fileServiceUrl: string; apiBaseUrl: string },
|
|
|
|
|
): void {
|
2026-04-24 16:16:31 +08:00
|
|
|
_config = {
|
2026-04-25 16:41:19 +08:00
|
|
|
appId: options.appId,
|
|
|
|
|
appKey: options.appKey ?? options.appId,
|
|
|
|
|
serverUrl: options.serverUrl,
|
|
|
|
|
apiBaseUrl: remote.apiBaseUrl,
|
|
|
|
|
imWsUrl: remote.imWsUrl,
|
|
|
|
|
fileServiceUrl: remote.fileServiceUrl,
|
|
|
|
|
debug: options.debug ?? false,
|
2026-04-24 16:16:31 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function getConfig(): XuqmConfig {
|
2026-04-25 16:41:19 +08:00
|
|
|
if (!_config) throw new Error('[XuqmSDK] Not initialized — call XuqmSDK.initialize() first.')
|
2026-04-24 16:16:31 +08:00
|
|
|
return _config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function isInitialized(): boolean {
|
|
|
|
|
return _config !== null
|
|
|
|
|
}
|