From 2efd5d5fc5e4a38f67e4bbb4d29679510ec7d3f0 Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Fri, 1 May 2026 21:27:39 +0800 Subject: [PATCH] =?UTF-8?q?feat(sdk):=20=E6=9B=B4=E6=96=B0=20SDK=20?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E6=96=87=E6=A1=A3=E5=92=8C=20API=20=E9=87=8D?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 expiresAt 和 refreshUserSig 参数支持自动续签 - 修改 PushSDK 初始化方式,自动完成设备注册和厂商初始化 - 调整过期续签策略,从提前 15 分钟改为提前 5 分钟触发 - 重构 RN SDK 文档结构,简化安装和使用方式 - 更新统一登录流程,支持 profile 信息传递 - 添加 IM 数据库自动隔离功能 - 修复 Android 群消息聚合问题 - 补充自动化测试验证和错误处理机制 --- src/im/useIm.ts | 44 ++++++++++++++++++++++++++++++++++++++++---- src/types/index.ts | 3 +++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/im/useIm.ts b/src/im/useIm.ts index 512602a..e53a6e7 100644 --- a/src/im/useIm.ts +++ b/src/im/useIm.ts @@ -1,4 +1,4 @@ -import { ref, shallowRef, onUnmounted } from 'vue' +import { ref, shallowRef, onUnmounted, reactive, type Ref } from 'vue' import { ImClient } from './ImClient' import { deleteConversation, @@ -28,13 +28,49 @@ import { import type { ConversationView, HistoryQuery, + ImGroup, ImMessage, PageResult, SendMessageParams, ChatType, + FriendRequest, + GroupJoinRequest, } from '../types' -export function useIm() { +export interface UseImReturn { + connect: () => void + send: (params: SendMessageParams) => ImMessage + revoke: (msgId: string) => Promise + edit: (msgId: string, content: string) => Promise + disconnect: () => void + messages: Ref + conversations: Ref + connected: Ref + error: Ref + refreshConversations: () => Promise + loadHistory: (toId: string, query?: HistoryQuery) => Promise> + loadGroupHistory: (groupId: string, query?: HistoryQuery) => Promise> + jumpToMessagePage: (toId: string, messageId: string, pageSize?: number, maxPages?: number) => Promise + jumpToGroupMessagePage: (groupId: string, messageId: string, pageSize?: number, maxPages?: number) => Promise + setConversationRead: (targetId: string, chatType?: ChatType) => Promise + setConversationPinnedState: (targetId: string, chatType: ChatType, pinned: boolean) => Promise + setConversationMutedState: (targetId: string, chatType: ChatType, muted: boolean) => Promise + setConversationDraft: (targetId: string, chatType: ChatType, draft: string) => Promise + removeConversation: (targetId: string, chatType: ChatType) => Promise + getFriends: () => Promise + getGroups: () => Promise + getGroup: (groupId: string) => Promise + sendFriend: (toUserId: string, remark?: string) => Promise + loadFriendRequests: (direction?: 'incoming' | 'outgoing') => Promise + approveFriendRequest: (requestId: string) => Promise + declineFriendRequest: (requestId: string) => Promise + sendGroupJoin: (groupId: string, remark?: string) => Promise + loadGroupJoinRequests: (groupId: string) => Promise + approveGroupJoinRequest: (groupId: string, requestId: string) => Promise + declineGroupJoinRequest: (groupId: string, requestId: string) => Promise +} + +export function useIm(): UseImReturn { const client = shallowRef(null) const messages = ref([]) const conversations = ref([]) @@ -220,7 +256,7 @@ export function useIm() { onUnmounted(disconnect) - return { + return reactive({ connect, send, revoke, @@ -251,5 +287,5 @@ export function useIm() { loadGroupJoinRequests, approveGroupJoinRequest, declineGroupJoinRequest, - } + }) as UseImReturn } diff --git a/src/types/index.ts b/src/types/index.ts index 2e78a4e..1526599 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -18,6 +18,8 @@ export type MsgType = | 'RICH_TEXT' | 'CALL_AUDIO' | 'CALL_VIDEO' + | 'QUOTE' + | 'MERGE' | 'REVOKED' | 'FORWARD' @@ -39,6 +41,7 @@ export interface ImMessage { groupReadCount?: number revoked?: boolean createdAt: string + editedAt?: string | null } export interface ConversationView {