common: - 新增 autoInit.ts 自动初始化(对齐 Android ContentProvider 模式) - 新增 configCrypto.ts 内置配置文件解密 - XuqmSDK 新增 initWithConfigFile / setUserInfo / getUserInfo - 新增 crypto-types.d.ts Web Crypto 类型声明 update: - 重写 UpdateSDK:checkAppUpdate / checkPluginUpdate / checkAndCachePlugin - 移除 checkAndPromptAppUpdate(SDK 不做 UI) - 新增插件脚手架 create-plugin.mjs - 重命名 RnUpdateInfo → PluginUpdateInfo license: - crypto.ts 支持 XUQM-CONFIG-V1 + XUQM-LICENSE-V1 双格式 - 新增 decryptConfigFile 导出 docs: - 重写 README.md - 新增 docs/SDK-API参考.md - 新增 docs/插件脚手架.md - 新增 docs/配置文件规范.md
67 行
1.4 KiB
TypeScript
67 行
1.4 KiB
TypeScript
export interface XuqmInitOptions {
|
|
appKey: string
|
|
debug?: boolean
|
|
}
|
|
|
|
export interface XuqmConfig {
|
|
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 interface XuqmUserInfo {
|
|
userId?: string
|
|
name?: string
|
|
email?: string
|
|
phone?: string
|
|
}
|
|
|
|
let _userInfo: XuqmUserInfo | null = null
|
|
|
|
export function initConfigFromRemote(
|
|
options: XuqmInitOptions,
|
|
remote: { imWsUrl: string; fileServiceUrl: string; apiUrl: string },
|
|
): void {
|
|
_config = {
|
|
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
|
|
}
|
|
|
|
export function setUserInfo(info: XuqmUserInfo | null): void {
|
|
_userInfo = info
|
|
// Sync userId for backward compatibility
|
|
if (info?.userId) {
|
|
_userId = info.userId
|
|
}
|
|
}
|
|
|
|
export function getUserInfo(): XuqmUserInfo | null {
|
|
return _userInfo
|
|
}
|