feat(sdk): 更新 SDK 设计文档和 API 重构
- 添加 expiresAt 和 refreshUserSig 参数支持自动续签 - 修改 PushSDK 初始化方式,自动完成设备注册和厂商初始化 - 调整过期续签策略,从提前 15 分钟改为提前 5 分钟触发 - 重构 RN SDK 文档结构,简化安装和使用方式 - 更新统一登录流程,支持 profile 信息传递 - 添加 IM 数据库自动隔离功能 - 修复 Android 群消息聚合问题 - 补充自动化测试验证和错误处理机制
这个提交包含在:
父节点
49796f51ae
当前提交
2efd5d5fc5
@ -1,4 +1,4 @@
|
|||||||
import { ref, shallowRef, onUnmounted } from 'vue'
|
import { ref, shallowRef, onUnmounted, reactive, type Ref } from 'vue'
|
||||||
import { ImClient } from './ImClient'
|
import { ImClient } from './ImClient'
|
||||||
import {
|
import {
|
||||||
deleteConversation,
|
deleteConversation,
|
||||||
@ -28,13 +28,49 @@ import {
|
|||||||
import type {
|
import type {
|
||||||
ConversationView,
|
ConversationView,
|
||||||
HistoryQuery,
|
HistoryQuery,
|
||||||
|
ImGroup,
|
||||||
ImMessage,
|
ImMessage,
|
||||||
PageResult,
|
PageResult,
|
||||||
SendMessageParams,
|
SendMessageParams,
|
||||||
ChatType,
|
ChatType,
|
||||||
|
FriendRequest,
|
||||||
|
GroupJoinRequest,
|
||||||
} from '../types'
|
} from '../types'
|
||||||
|
|
||||||
export function useIm() {
|
export interface UseImReturn {
|
||||||
|
connect: () => void
|
||||||
|
send: (params: SendMessageParams) => ImMessage
|
||||||
|
revoke: (msgId: string) => Promise<ImMessage>
|
||||||
|
edit: (msgId: string, content: string) => Promise<ImMessage>
|
||||||
|
disconnect: () => void
|
||||||
|
messages: Ref<ImMessage[]>
|
||||||
|
conversations: Ref<ConversationView[]>
|
||||||
|
connected: Ref<boolean>
|
||||||
|
error: Ref<Event | null>
|
||||||
|
refreshConversations: () => Promise<void>
|
||||||
|
loadHistory: (toId: string, query?: HistoryQuery) => Promise<PageResult<ImMessage>>
|
||||||
|
loadGroupHistory: (groupId: string, query?: HistoryQuery) => Promise<PageResult<ImMessage>>
|
||||||
|
jumpToMessagePage: (toId: string, messageId: string, pageSize?: number, maxPages?: number) => Promise<ImMessage[] | null>
|
||||||
|
jumpToGroupMessagePage: (groupId: string, messageId: string, pageSize?: number, maxPages?: number) => Promise<ImMessage[] | null>
|
||||||
|
setConversationRead: (targetId: string, chatType?: ChatType) => Promise<void>
|
||||||
|
setConversationPinnedState: (targetId: string, chatType: ChatType, pinned: boolean) => Promise<void>
|
||||||
|
setConversationMutedState: (targetId: string, chatType: ChatType, muted: boolean) => Promise<void>
|
||||||
|
setConversationDraft: (targetId: string, chatType: ChatType, draft: string) => Promise<void>
|
||||||
|
removeConversation: (targetId: string, chatType: ChatType) => Promise<void>
|
||||||
|
getFriends: () => Promise<string[]>
|
||||||
|
getGroups: () => Promise<ImGroup[]>
|
||||||
|
getGroup: (groupId: string) => Promise<ImGroup>
|
||||||
|
sendFriend: (toUserId: string, remark?: string) => Promise<FriendRequest>
|
||||||
|
loadFriendRequests: (direction?: 'incoming' | 'outgoing') => Promise<FriendRequest[]>
|
||||||
|
approveFriendRequest: (requestId: string) => Promise<FriendRequest>
|
||||||
|
declineFriendRequest: (requestId: string) => Promise<FriendRequest>
|
||||||
|
sendGroupJoin: (groupId: string, remark?: string) => Promise<GroupJoinRequest>
|
||||||
|
loadGroupJoinRequests: (groupId: string) => Promise<GroupJoinRequest[]>
|
||||||
|
approveGroupJoinRequest: (groupId: string, requestId: string) => Promise<GroupJoinRequest>
|
||||||
|
declineGroupJoinRequest: (groupId: string, requestId: string) => Promise<GroupJoinRequest>
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useIm(): UseImReturn {
|
||||||
const client = shallowRef<ImClient | null>(null)
|
const client = shallowRef<ImClient | null>(null)
|
||||||
const messages = ref<ImMessage[]>([])
|
const messages = ref<ImMessage[]>([])
|
||||||
const conversations = ref<ConversationView[]>([])
|
const conversations = ref<ConversationView[]>([])
|
||||||
@ -220,7 +256,7 @@ export function useIm() {
|
|||||||
|
|
||||||
onUnmounted(disconnect)
|
onUnmounted(disconnect)
|
||||||
|
|
||||||
return {
|
return reactive({
|
||||||
connect,
|
connect,
|
||||||
send,
|
send,
|
||||||
revoke,
|
revoke,
|
||||||
@ -251,5 +287,5 @@ export function useIm() {
|
|||||||
loadGroupJoinRequests,
|
loadGroupJoinRequests,
|
||||||
approveGroupJoinRequest,
|
approveGroupJoinRequest,
|
||||||
declineGroupJoinRequest,
|
declineGroupJoinRequest,
|
||||||
}
|
}) as UseImReturn
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,8 @@ export type MsgType =
|
|||||||
| 'RICH_TEXT'
|
| 'RICH_TEXT'
|
||||||
| 'CALL_AUDIO'
|
| 'CALL_AUDIO'
|
||||||
| 'CALL_VIDEO'
|
| 'CALL_VIDEO'
|
||||||
|
| 'QUOTE'
|
||||||
|
| 'MERGE'
|
||||||
| 'REVOKED'
|
| 'REVOKED'
|
||||||
| 'FORWARD'
|
| 'FORWARD'
|
||||||
|
|
||||||
@ -39,6 +41,7 @@ export interface ImMessage {
|
|||||||
groupReadCount?: number
|
groupReadCount?: number
|
||||||
revoked?: boolean
|
revoked?: boolean
|
||||||
createdAt: string
|
createdAt: string
|
||||||
|
editedAt?: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConversationView {
|
export interface ConversationView {
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户