XuqmGroup-Vue3SDK/src/core/sdk.ts
XuqmGroup ebf6a389cf feat(im): 添加即时通讯功能模块
- 添加了 IM API 接口定义,包含登录、消息、群组、好友等接口
- 实现了 ImSDK 核心功能,支持发送各类消息和管理会话
- 集成了 WebSocket 连接管理和自动重连机制
- 添加了本地联系人缓存并优化对话标题显示逻辑
- 实现了 HarmonyOS 平台 HTTP 客户端基础功能
2026-04-28 16:55:12 +08:00

34 行
781 B
TypeScript

import type { SDKConfig } from '../types'
import { configureHttp } from './http'
let _config: SDKConfig | null = null
let _token: string | null = null
let _userId: string | null = null
export function init(config: SDKConfig) {
_config = config
configureHttp(config.apiBaseUrl, () => _token)
if (config.debug) console.log('[XuqmSDK] initialized', config.appKey)
}
export function setToken(token: string | null) {
_token = token
}
export function setUserId(userId: string | null) {
_userId = userId
}
export function getToken(): string | null {
return _token
}
export function getUserId(): string | null {
return _userId
}
export function getConfig(): SDKConfig {
if (!_config) throw new Error('XuqmSDK not initialized. Call init() first.')
return _config
}