37 行
790 B
TypeScript
37 行
790 B
TypeScript
|
|
import { API_BASE_URL, IM_WS_URL } from './constants'
|
||
|
|
|
||
|
|
export interface XuqmInitOptions {
|
||
|
|
appId: string
|
||
|
|
appKey?: string
|
||
|
|
debug?: boolean
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface XuqmConfig {
|
||
|
|
appId: string
|
||
|
|
appKey: string
|
||
|
|
apiBaseUrl: string
|
||
|
|
imWsUrl: string
|
||
|
|
debug: boolean
|
||
|
|
}
|
||
|
|
|
||
|
|
let _config: XuqmConfig | null = null
|
||
|
|
|
||
|
|
export function initConfig(options: XuqmInitOptions): void {
|
||
|
|
_config = {
|
||
|
|
appId: options.appId,
|
||
|
|
appKey: options.appKey ?? options.appId,
|
||
|
|
apiBaseUrl: API_BASE_URL,
|
||
|
|
imWsUrl: IM_WS_URL,
|
||
|
|
debug: options.debug ?? false,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export function getConfig(): XuqmConfig {
|
||
|
|
if (!_config) throw new Error('[XuqmSDK] Not initialized — call XuqmSDK.init() first.')
|
||
|
|
return _config
|
||
|
|
}
|
||
|
|
|
||
|
|
export function isInitialized(): boolean {
|
||
|
|
return _config !== null
|
||
|
|
}
|