sim-sdk-uni
v0.1.3
Published
UniApp (App + H5) IM transport — WebSocket
Readme
sim-sdk-uni
UniApp 用 IM SDK(HTTP 走 uni.request,长连接 WebSocket)。
与全局 uni.request 拦截器
本 SDK 在 存在全局 uni 时 所有 REST 都通过 uni.request 发出,并在请求头里设置 Authorization: Bearer <chat token>(来自 configure({ token }))。
若项目在 uni.addInterceptor('request', …) 里无条件写:
options.header.Authorization = `Bearer ${店铺或其它业务的 token}`则 会覆盖 SDK 已为聊天域名设好的头,聊天接口收到错误 token → 401 等。这与业务里 configure / login 传参是否正确无关。
建议: 仅在当前请求尚未带鉴权头时再补默认 token,例如:
const h = options.header || (options.header = {})
if (token && !h.Authorization && !h.authorization) {
h.Authorization = `Bearer ${token}`
}或对 聊天 API 的 host/path 跳过注入,避免误伤 IM 请求。
