XuqmGroup-Vue3SDK/src/core/sdk.ts

25 行
609 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
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 getToken(): string | null {
return _token
}
export function getConfig(): SDKConfig {
if (!_config) throw new Error('XuqmSDK not initialized. Call init() first.')
return _config
}