docs(sdk): 添加 Android SDK 文档和 API 设计规范
- 新增 Android SDK 使用文档,包含模块结构、集成方式和快速开始指南 - 添加 SDK API 重设计规范,统一初始化和登录接口设计 - 补充安全设计规范,完善 UserSig 鉴权和敏感数据处理方案 - 创建平台 REST API 规范,定义服务端到服务端的调用接口 - 添加离线推送架构设计,集成各大厂商推送服务与 IM 联动方案
这个提交包含在:
父节点
92ba64ded4
当前提交
2c0ac124d7
@ -39,8 +39,6 @@ import { init } from '@xuqm/vue3-sdk'
|
|||||||
init({
|
init({
|
||||||
appKey: 'ak_your_app_key',
|
appKey: 'ak_your_app_key',
|
||||||
appSecret: 'as_your_app_secret',
|
appSecret: 'as_your_app_secret',
|
||||||
apiBaseUrl: 'https://api.xuqm.com',
|
|
||||||
imBaseUrl: 'wss://im.xuqm.com',
|
|
||||||
debug: import.meta.env.DEV,
|
debug: import.meta.env.DEV,
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|||||||
2
src/core/endpoints.ts
普通文件
2
src/core/endpoints.ts
普通文件
@ -0,0 +1,2 @@
|
|||||||
|
export const DEFAULT_API_BASE_URL = 'https://dev.xuqinmin.com'
|
||||||
|
export const DEFAULT_IM_WS_URL = 'wss://dev.xuqinmin.com/ws/im'
|
||||||
@ -1,5 +1,6 @@
|
|||||||
import type { SDKConfig } from '../types'
|
import type { SDKConfig } from '../types'
|
||||||
import { configureHttp } from './http'
|
import { configureHttp } from './http'
|
||||||
|
import { DEFAULT_API_BASE_URL } from './endpoints'
|
||||||
|
|
||||||
let _config: SDKConfig | null = null
|
let _config: SDKConfig | null = null
|
||||||
let _token: string | null = null
|
let _token: string | null = null
|
||||||
@ -7,7 +8,7 @@ let _userId: string | null = null
|
|||||||
|
|
||||||
export function init(config: SDKConfig) {
|
export function init(config: SDKConfig) {
|
||||||
_config = config
|
_config = config
|
||||||
configureHttp(config.apiBaseUrl, () => _token)
|
configureHttp(DEFAULT_API_BASE_URL, () => _token)
|
||||||
if (config.debug) console.log('[XuqmSDK] initialized', config.appKey)
|
if (config.debug) console.log('[XuqmSDK] initialized', config.appKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import type { ImMessage, SendMessageParams, ImEventMap } from '../types'
|
import type { ImMessage, SendMessageParams, ImEventMap } from '../types'
|
||||||
import { getConfig, getToken, getUserId } from '../core/sdk'
|
import { getConfig, getToken, getUserId } from '../core/sdk'
|
||||||
|
import { DEFAULT_IM_WS_URL } from '../core/endpoints'
|
||||||
|
|
||||||
type EventListener<K extends keyof ImEventMap> = ImEventMap[K]
|
type EventListener<K extends keyof ImEventMap> = ImEventMap[K]
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ export class ImClient {
|
|||||||
if (this.destroyed) return
|
if (this.destroyed) return
|
||||||
const config = getConfig()
|
const config = getConfig()
|
||||||
const token = getToken()
|
const token = getToken()
|
||||||
const url = `${config.imBaseUrl}/ws/im?token=${token ?? ''}`
|
const url = `${DEFAULT_IM_WS_URL}?token=${token ?? ''}`
|
||||||
|
|
||||||
this.ws = new WebSocket(url)
|
this.ws = new WebSocket(url)
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
export interface SDKConfig {
|
export interface SDKConfig {
|
||||||
appKey: string
|
appKey: string
|
||||||
appSecret: string
|
appSecret: string
|
||||||
apiBaseUrl: string
|
|
||||||
imBaseUrl: string
|
|
||||||
debug?: boolean
|
debug?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户