XuqmGroup-RNSDK/packages/common/src/config.ts
XuqmGroup 67d54bf1f2 docs(sdk): 添加 Android SDK 文档和 API 设计规范
- 新增 Android SDK 使用文档,包含模块结构、集成方式和快速开始指南
- 添加 SDK API 重设计规范,统一初始化和登录接口设计
- 补充安全设计规范,完善 UserSig 鉴权和敏感数据处理方案
- 创建平台 REST API 规范,定义服务端到服务端的调用接口
- 添加离线推送架构设计,集成各大厂商推送服务与 IM 联动方案
2026-04-29 15:46:40 +08:00

48 行
1.1 KiB
TypeScript

export interface XuqmInitOptions {
appKey: string
debug?: boolean
}
export interface XuqmConfig {
appId: string
appKey: string
apiUrl: string
imWsUrl: string
fileServiceUrl: string // fetched from remote config
debug: boolean
}
let _config: XuqmConfig | null = null
let _userId: string | null = null
export function initConfigFromRemote(
options: XuqmInitOptions,
remote: { imWsUrl: string; fileServiceUrl: string; apiUrl: string },
): void {
_config = {
appId: options.appKey,
appKey: options.appKey,
apiUrl: remote.apiUrl,
imWsUrl: remote.imWsUrl,
fileServiceUrl: remote.fileServiceUrl,
debug: options.debug ?? false,
}
}
export function getConfig(): XuqmConfig {
if (!_config) throw new Error('[XuqmSDK] Not initialized — call XuqmSDK.initialize() first.')
return _config
}
export function setUserId(userId: string | null): void {
_userId = userId
}
export function getUserId(): string | null {
return _userId
}
export function isInitialized(): boolean {
return _config !== null
}