XuqmGroup-Vue3SDK/src/core/sdk.ts

34 行
781 B
TypeScript

2026-04-21 22:07:29 +08:00
import type { SDKConfig } from '../types'
import { configureHttp } from './http'
let _config: SDKConfig | null = null
let _token: string | null = null
let _userId: string | null = null
2026-04-21 22:07:29 +08:00
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
}
2026-04-21 22:07:29 +08:00
export function getToken(): string | null {
return _token
}
export function getUserId(): string | null {
return _userId
}
2026-04-21 22:07:29 +08:00
export function getConfig(): SDKConfig {
if (!_config) throw new Error('XuqmSDK not initialized. Call init() first.')
return _config
}