feat(im): 添加群组管理 API 和群历史消息接口

- types.ts:新增 ImGroup 类型
- imSDK.ts:新增 createGroup / listGroups / fetchGroupHistory
- index.ts:导出 ImGroup 类型

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
这个提交包含在:
XuqmGroup 2026-04-24 11:14:41 +08:00
父节点 b747901cfe
当前提交 97150538bc
共有 3 个文件被更改,包括 44 次插入2 次删除

查看文件

@ -1,7 +1,7 @@
import { getConfig } from '../core/config' import { getConfig } from '../core/config'
import { apiRequest, getToken, saveToken } from '../core/http' import { apiRequest, getToken, saveToken } from '../core/http'
import { ImClient } from './imClient' import { ImClient } from './imClient'
import type { ChatType, ImEventListener, ImMessage, MsgType } from './types' import type { ChatType, ImEventListener, ImGroup, ImMessage, MsgType } from './types'
let client: ImClient | null = null let client: ImClient | null = null
@ -91,4 +91,36 @@ export const ImSDK = {
isConnected() { isConnected() {
return client?.isConnected() ?? false return client?.isConnected() ?? false
}, },
async createGroup(name: string, memberIds: string[]): Promise<ImGroup> {
const config = getConfig()
return apiRequest<ImGroup>('/api/im/groups', {
method: 'POST',
params: { appId: config.appId },
body: { name, memberIds },
})
},
async listGroups(): Promise<ImGroup[]> {
const config = getConfig()
const res = await apiRequest<ImGroup[] | { content?: ImGroup[] }>('/api/im/groups', {
params: { appId: config.appId },
})
return Array.isArray(res) ? res : (res.content ?? [])
},
async fetchGroupHistory(groupId: string, page = 0, size = 50): Promise<ImMessage[]> {
const config = getConfig()
const res = await apiRequest<{ content?: ImMessage[] } | ImMessage[]>(
`/api/im/messages/history/${encodeURIComponent(groupId)}`,
{
params: {
appId: config.appId,
page: String(page),
size: String(size),
},
},
)
return Array.isArray(res) ? res : (res.content ?? [])
},
} }

查看文件

@ -45,3 +45,13 @@ export interface SendMessageParams {
content: string content: string
mentionedUserIds?: string mentionedUserIds?: string
} }
export interface ImGroup {
id: string
appId: string
name: string
creatorId: string
memberIds: string
adminIds: string
createdAt: string
}

查看文件

@ -5,7 +5,7 @@ export { XuqmSDK } from './core/sdk'
export { ImSDK } from './im/imSDK' export { ImSDK } from './im/imSDK'
export { ImClient } from './im/imClient' export { ImClient } from './im/imClient'
export type { ImMessage, ChatType, MsgType, MsgStatus, ImEventListener, SendMessageParams } from './im/types' export type { ImMessage, ChatType, MsgType, MsgStatus, ImEventListener, SendMessageParams, ImGroup } from './im/types'
export { PushSDK } from './push/pushSDK' export { PushSDK } from './push/pushSDK'
export type { PushVendor } from './push/pushSDK' export type { PushVendor } from './push/pushSDK'