更新
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
export interface ITasks {
|
||||
sendMessage: boolean; // 发送一条消息
|
||||
revokeMessage: boolean; // 撤回一条消息
|
||||
modifyNickName: boolean; // 修改一次我的昵称
|
||||
groupChat: boolean; // 发起一个群聊
|
||||
muteGroup: boolean; // 开启一次群禁言
|
||||
dismissGroup: boolean; // 解散一个群聊
|
||||
call: boolean; // 发起一次通话
|
||||
searchCloudMessage: boolean; // 进行一次消息云端搜索
|
||||
customerService: boolean; // 进行一次客服会话
|
||||
translateTextMessage: boolean; // 进行一次文本消息翻译
|
||||
}
|
||||
export interface IAppStore {
|
||||
store: {
|
||||
enabledMessageReadReceipt: boolean; // 消息已读回执功能是否已开启
|
||||
enabledEmojiPlugin: boolean; // 表情回复插件能力是否已开启
|
||||
enabledOnlineStatus: boolean; // 用户在线状态能力是否已开启
|
||||
enabledCustomerServicePlugin: boolean; // 客服插件能力是否已开启
|
||||
enabledTranslationPlugin: boolean; // 文本消息翻译能力是否已开启
|
||||
enabledVoiceToText: boolean; // 语音转文字能力是否已开启
|
||||
enableTyping: boolean; // 正在输入能力开关
|
||||
enableConversationDraft: boolean; // 会话草稿能力开关
|
||||
enableAutoMessageRead: boolean; // 接收消息自动已读上报能力开关
|
||||
isOfficial: boolean; // 是否是官网 SDKAppID
|
||||
SDKVersion: string; // Chat SDK 版本号
|
||||
tasks: ITasks; // sample demo 任务列表
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新 store
|
||||
* @param {Sting} key 待更新的 key
|
||||
* @param {any} data 更新的数据
|
||||
*/
|
||||
update(key: string, data: any): void;
|
||||
|
||||
/**
|
||||
* 从 store 中获取数据
|
||||
* @param {Sting} key 需要获取的 key
|
||||
*/
|
||||
getData(key: string): any;
|
||||
|
||||
/**
|
||||
* reset Store 内数据
|
||||
* @param { Array<string>} keyList 需要 reset 的 keyList
|
||||
*/
|
||||
reset(keyList?: string[]): void;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import type { Message } from '@tencentcloud/lite-chat/basic';
|
||||
import type { IMessageModel } from '../model';
|
||||
|
||||
interface ITextInfo {
|
||||
messageID: string;
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
export interface IChatStore {
|
||||
store: {
|
||||
messageList: IMessageModel[];
|
||||
isCompleted: boolean;
|
||||
nextReqMessageID: string;
|
||||
quoteMessage: Message | any;
|
||||
typingStatus: boolean;
|
||||
messageSource: IMessageModel | undefined;
|
||||
newMessageList: Message[];
|
||||
translateTextInfo: Map<string, ITextInfo[]> | undefined;
|
||||
voiceToTextInfo: Map<string, ITextInfo[]> | undefined;
|
||||
userInfo: Record<string, any>;
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新 store
|
||||
* @param {Sting} key 待更新的 key
|
||||
* @param {any} data 更新的数据
|
||||
*/
|
||||
update(key: string, data: any): void;
|
||||
|
||||
/**
|
||||
* 从 store 中获取数据
|
||||
* @param {Sting} key 需要获取的 key
|
||||
*/
|
||||
getData(key: string): any;
|
||||
|
||||
/**
|
||||
* 从 messageList 中获取 messageModel
|
||||
* @param {Sting} id 需要获取的 messageID
|
||||
*/
|
||||
getModel(id: string): any;
|
||||
|
||||
/**
|
||||
* reset Store 内数据
|
||||
* @param { Array<string>} keyList 需要 reset 的 keyList
|
||||
*/
|
||||
reset(keyList?: string[]): void;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { IConversationModel } from '../model';
|
||||
|
||||
export interface IConversationStore {
|
||||
store: {
|
||||
currentConversationID: string;
|
||||
currentConversation: IConversationModel | null;
|
||||
totalUnreadCount: number;
|
||||
conversationList: IConversationModel[];
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新 store
|
||||
* @param {Sting} key 待更新的 key
|
||||
* @param {any} data 更新的数据
|
||||
*/
|
||||
update(key: string, data: any): void;
|
||||
|
||||
/**
|
||||
* 从 store 中获取数据
|
||||
* @param {Sting} key 需要获取的 key
|
||||
*/
|
||||
getData(key: string): any;
|
||||
|
||||
/**
|
||||
* 从 conversationList 中获取 conversationModel
|
||||
* @param {Sting} conversationID 需要获取的会话 ID
|
||||
*/
|
||||
getModel(id: string): any;
|
||||
|
||||
/**
|
||||
* reset Store 内数据
|
||||
* @param { Array<string>} keyList 需要 reset 的 keyList
|
||||
*/
|
||||
reset(keyList?: string[]): void;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
export interface ICustomStore {
|
||||
store: any; // 自定义 store,属性可根据需要进行自定义
|
||||
|
||||
/**
|
||||
* 更新自定义 store
|
||||
* @param {Sting} key 待更新的 key,没有则写入
|
||||
* @param {any} value 待更新的数据
|
||||
*/
|
||||
update(key: string, value: any): void;
|
||||
|
||||
/**
|
||||
* 从自定义 store 中获取数据
|
||||
* @param {Sting} store store 的名称
|
||||
* @param {Sting} key 待获取的 key
|
||||
*/
|
||||
getData(key: string): any;
|
||||
|
||||
/**
|
||||
* reset Store 内数据
|
||||
* @param { Array<string>} keyList 需要 reset 的 keyList
|
||||
*/
|
||||
reset(keyList?: string[]): void;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { Friend, FriendApplication, FriendGroup } from '../../type';
|
||||
|
||||
export interface IFriendStore {
|
||||
store: {
|
||||
friendList: Friend[];
|
||||
friendApplicationList: FriendApplication[];
|
||||
friendApplicationUnreadCount: number; // 好友申请的未读数
|
||||
friendGroupList: FriendGroup[];
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新 store
|
||||
* @param {Sting} key 待更新的 key
|
||||
* @param {any} data 更新的数据
|
||||
*/
|
||||
update(key: string, data: any): void;
|
||||
|
||||
/**
|
||||
* 从 store 中获取数据
|
||||
* @param {Sting} key 需要获取的 key
|
||||
*/
|
||||
getData(key: string): any;
|
||||
|
||||
/**
|
||||
* reset Store 内数据
|
||||
* @param { Array<string>} keyList 需要 reset 的 keyList
|
||||
*/
|
||||
reset(keyList?: string[]): void;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import type { Message } from '@tencentcloud/lite-chat/basic';
|
||||
import type { IGroupModel } from '../model';
|
||||
|
||||
export interface GroupMember {
|
||||
userID: string;
|
||||
avatar: string;
|
||||
nick: string;
|
||||
role: string;
|
||||
joinTime: number;
|
||||
nameCard: string;
|
||||
muteUntil: number;
|
||||
memberCustomField: Record<string, any>[];
|
||||
}
|
||||
|
||||
export interface IGroupStore {
|
||||
store: {
|
||||
currentGroupID: string;
|
||||
currentGroup: IGroupModel | undefined;
|
||||
currentGroupMemberList: GroupMember[];
|
||||
currentGroupAttributes: Record<string, any>;
|
||||
currentGroupCounters: Record<string, number>;
|
||||
groupList: IGroupModel[];
|
||||
groupSystemNoticeList: Message[];
|
||||
isCompleted: boolean;
|
||||
offset: number | string;
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新 store
|
||||
* @param {Sting} key 待更新的 key
|
||||
* @param {any} data 更新的数据
|
||||
*/
|
||||
update(key: string, data: any): void;
|
||||
|
||||
/**
|
||||
* 从 store 中获取数据
|
||||
* @param {Sting} key 需要获取的 key
|
||||
*/
|
||||
getData(key: string): any;
|
||||
|
||||
/**
|
||||
* reset Store 内数据
|
||||
* @param { Array<string>} keyList 需要 reset 的 keyList
|
||||
*/
|
||||
reset(keyList?: string[]): void;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
export * from './tui-store';
|
||||
export * from './user';
|
||||
export * from './conversation';
|
||||
export * from './chat';
|
||||
export * from './group';
|
||||
export * from './custom';
|
||||
export * from './friend';
|
||||
export * from './app';
|
||||
export * from './search';
|
||||
@@ -0,0 +1,37 @@
|
||||
import type { ISearchParamsMap, ISearchResult, ISearchType } from '../../type';
|
||||
|
||||
export interface ISearchStoreStore {
|
||||
searchMessagesResult: ISearchResult<ISearchType.MESSAGE>;
|
||||
searchChatMessagesResult: ISearchResult<ISearchType.MESSAGE>;
|
||||
searchUserResult: ISearchResult<ISearchType.USER>;
|
||||
searchGroupResult: ISearchResult<ISearchType.GROUP>;
|
||||
searchMessageParams: ISearchParamsMap[ISearchType.MESSAGE];
|
||||
searchChatMessageParams: ISearchParamsMap[ISearchType.MESSAGE];
|
||||
searchUserParams: ISearchParamsMap[ISearchType.USER];
|
||||
searchGroupParams: ISearchParamsMap[ISearchType.GROUP];
|
||||
error: Error | null;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface ISearchStore {
|
||||
store: ISearchStoreStore;
|
||||
|
||||
/**
|
||||
* 更新 store
|
||||
* @param {Sting} key 待更新的 key
|
||||
* @param {any} data 更新的数据
|
||||
*/
|
||||
update(key: string, data: any): void;
|
||||
|
||||
/**
|
||||
* 从 store 中获取数据
|
||||
* @param {Sting} key 需要获取的 key
|
||||
*/
|
||||
getData(key: string): any;
|
||||
|
||||
/**
|
||||
* reset Store 内数据
|
||||
* @param { Array<string>} keyList 需要 reset 的 keyList
|
||||
*/
|
||||
reset(keyList?: string[]): void;
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* @property {Boolean} enableTyping 正在输入功能是否开启,默认开启 true
|
||||
* @property {Boolean} enabledMessageReadReceipt 消息已读回执功能是否已开启,默认 false,购买旗舰版套餐后开启
|
||||
* @property {Boolean} enabledEmojiPlugin 表情回复插件能力是否已开启,默认 false,购买旗舰版套餐后开启
|
||||
* @property {Boolean} enabledOnlineStatus 用户在线状态能力是否已开启,默认 false,购买旗舰版套餐后开启
|
||||
* @property {Boolean} enabledCustomerServicePlugin 客服插件能力是否已开启,默认 false,购买客服插件后开启
|
||||
* @property {Boolean} enabledTranslationPlugin 文本消息翻译能力是否已开启,默认 false,购买翻译插件后开启
|
||||
* @property {Boolean} enableConversationDraft 会话草稿功能是否开启,默认开启 true
|
||||
* @example
|
||||
* // UI 层调用以下逻辑关闭正在输入功能
|
||||
* TUIStore.update(StoreName.APP, 'enableTyping', false);
|
||||
* @example
|
||||
* // UI 层调用以下逻辑关闭会话草稿功能
|
||||
* TUIStore.update(StoreName.APP, 'enableConversationDraft', false);
|
||||
*/
|
||||
export enum AppStore {}
|
||||
|
||||
/**
|
||||
* @property {String} currentConversationID 当前会话ID
|
||||
* @property {Array<IConversationModel>} conversationList 会话列表
|
||||
* @property {Number} totalUnreadCount 会话未读总数
|
||||
* @example
|
||||
* // UI 层监听会话列表更新通知
|
||||
* let onConversationListUpdated = function(conversationList) {
|
||||
* console.warn(conversationList);
|
||||
* }
|
||||
* TUIStore.watch(StoreName.CONV, {
|
||||
* conversationList: onConversationListUpdated,
|
||||
* })
|
||||
*/
|
||||
export enum ConversationStore {}
|
||||
|
||||
/**
|
||||
* @property {Array<IMessageModel>} messageList 消息列表
|
||||
* @property {Boolean} isCompleted 漫游是否拉完(用于控制‘查看更多’按钮显示)
|
||||
* @property {Message | any} quoteMessage 被引用的消息信息,引用消息时会触发更新
|
||||
* @property {Boolean} typingStatus 正在输入的状态标识, 默认 false,开启正在输入状态后,输入消息时会触发更新
|
||||
* @property {IMessageModel} messageSource 用于消息云端搜索结果跳转至指定消息标识
|
||||
* @property {Array<Message>} newMessageList 新消息通知列表,提供给 TUINotification 组件使用
|
||||
* @property {Record<string, string | undefined | boolean>} translateTextInfo 文本消息翻译信息
|
||||
* @example
|
||||
* // UI 层监听当前会话消息列表更新通知
|
||||
* let onMessageListUpdated = function(messageList) {
|
||||
* console.warn(messageList);
|
||||
* }
|
||||
* TUIStore.watch(StoreName.CHAT, {
|
||||
* messageList: onMessageListUpdated,
|
||||
* })
|
||||
* @example
|
||||
* // UI 层更新消息云端搜索结果跳转至指定消息标识
|
||||
* TUIStore.update(StoreName.CHAT, 'messageSource', message);
|
||||
* // UI 层监听消息云端搜索结果跳转至指定消息标识
|
||||
* let onMessageSourceUpdated = function(message) {
|
||||
* console.warn(message);
|
||||
* }
|
||||
* TUIStore.watch(StoreName.CHAT, {
|
||||
* messageSource: onMessageSourceUpdated,
|
||||
* })
|
||||
* @example
|
||||
* // UI 层更新文本消息翻译信息
|
||||
* TUIStore.update(StoreName.CHAT, 'translateTextInfo', {
|
||||
* conversationID: 'xxx',
|
||||
* messageID: 'xxx',
|
||||
* visible: false,
|
||||
* });
|
||||
* // UI 层监听文本消息翻译更新通知
|
||||
* let onTranslateTextInfoUpdated = function(info) {
|
||||
* // info 返回的是 map 或 undefined
|
||||
* if (info) {
|
||||
* const list = info.get('conversationID') || [];
|
||||
* list.forEach(item => {
|
||||
* const { messageID, visible } = item;
|
||||
* // messageID - 当前操作的消息的 ID
|
||||
* // visible - 是否显示翻译文本
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* TUIStore.watch(StoreName.CHAT, {
|
||||
* translateTextInfo: onTranslateTextInfoUpdated,
|
||||
* })
|
||||
*/
|
||||
export enum ChatStore {}
|
||||
|
||||
/**
|
||||
* @property {String} currentGroupID 当前群组ID
|
||||
* @property {Group} currentGroup 当前群组信息
|
||||
* @property {Array} currentGroupMemberList 当前群组群成员列表
|
||||
* @property {Object} currentGroupAttributes 当前群组群属性信息
|
||||
* @property {Object} currentGroupCounters 当前群组计数器信息
|
||||
* @property {Array<Group>} groupList 群组列表
|
||||
* @property {Array<Message>} groupSystemNoticeList 群组系统通知列表(注意:Store 中不会存储群系统通知,即时通知)
|
||||
* @example
|
||||
* // UI 层监听群组列表更新通知
|
||||
* let onGroupListUpdated = function(groupList) {
|
||||
* console.warn(groupList);
|
||||
* }
|
||||
* TUIStore.watch(StoreName.GRP, {
|
||||
* groupList: onGroupListUpdated,
|
||||
* })
|
||||
*/
|
||||
export enum GroupStore {}
|
||||
|
||||
/**
|
||||
* @property {Object} userProfile 当前登录用户的资料信息
|
||||
* @property {Boolean} displayOnlineStatus 是否开启用户状态显示,默认 false:关闭
|
||||
* @property {Boolean} displayMessageReadReceipt 是否开启消息阅读状态显示,默认 true:开启
|
||||
* @property {String} kickedOut 用户被踢的类型信息
|
||||
* @property {String} netStateChange 网络状态变更信息
|
||||
* @property {Map<key, statusInfo>} userStatusList 订阅用户的状态信息的列表
|
||||
* - key 用户 userID
|
||||
* - statusInfo.statusType 用户当前状态
|
||||
* - statusInfo.customStatus 用户自定义状态
|
||||
* @property {Array<string>} userBlacklist 用户黑名单列表,UI 组件层可以通过监听该属性来获取用户黑名单列表
|
||||
* @example
|
||||
* // UI 层监听网络变更通知
|
||||
* let onNetStateChange = function(state) {
|
||||
* console.warn(state);
|
||||
* }
|
||||
* TUIStore.watch(StoreName.USER, {
|
||||
* netStateChange: onNetStateChange,
|
||||
* })
|
||||
*/
|
||||
export enum UserStore {}
|
||||
|
||||
/**
|
||||
* @property {Array<Friend>} friendList 好友列表,UI 组件层可以通过监听该属性来获取好友列表
|
||||
* @property {Array<FriendApplication>} friendApplicationList 好友申请列表,UI 组件层可以通过监听该属性来获取好友申请列表
|
||||
* @property {number} friendApplicationUnreadCount 好友申请未读数,UI 组件层可以通过监听该属性来获取好友申请未读数
|
||||
* @example
|
||||
* // UI 层监听好友列表更新变更通知
|
||||
* let onFriendListUpdated = function(friendList) {
|
||||
* console.warn(friendList);
|
||||
* }
|
||||
* TUIStore.watch(StoreName.FRIEND, {
|
||||
* friendList: onFriendListUpdated ,
|
||||
* })
|
||||
*/
|
||||
export enum FriendStore {}
|
||||
@@ -0,0 +1,102 @@
|
||||
import type { StoreName } from '../../const';
|
||||
import type { IConversationModel, IMessageModel } from '../model';
|
||||
|
||||
// 此处 Map 的 value = 1 为占位作用
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export type Task = Record<StoreName, Record<string, Map<(data?: unknown) => void, 1>>>;
|
||||
|
||||
export interface IOptions {
|
||||
[key: string]: (newData?: any) => void;
|
||||
}
|
||||
// 自定义 store 暂不支持
|
||||
// @property {ICustomStore} customStore 自定义 store,可根据业务需要通过以下 API 进行数据操作。
|
||||
/**
|
||||
* @class TUIStore
|
||||
*/
|
||||
export interface ITUIStore {
|
||||
task: Task;
|
||||
/**
|
||||
* UI 组件注册监听
|
||||
* @function
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {IOptions} options UI 组件注册的监听信息
|
||||
* @example
|
||||
* // UI 层监听会话列表更新通知
|
||||
* let onConversationListUpdated = function(conversationList) {
|
||||
* console.warn(conversationList);
|
||||
* }
|
||||
* TUIStore.watch(StoreName.CONV, {
|
||||
* conversationList: onConversationListUpdated,
|
||||
* })
|
||||
*/
|
||||
watch(storeName: StoreName, options: IOptions): void;
|
||||
|
||||
/**
|
||||
* UI 组件取消监听回调
|
||||
* 注意:取消监听时传入的回调函数和注册监听的回调函数是同一个
|
||||
* @function
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {IOptions} options 监听信息,包含需要取消的回调等
|
||||
* @example
|
||||
* // UI 层取消监听会话列表更新通知
|
||||
* TUIStore.unwatch(StoreName.CONV, {
|
||||
* conversationList: onConversationListUpdated,
|
||||
* })
|
||||
*/
|
||||
unwatch(storeName: StoreName, options: IOptions): void;
|
||||
|
||||
/**
|
||||
* 更新 store
|
||||
* - 使用自定义 store 时,可以用此 API 更新自定义数据
|
||||
* @function
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {String} key 需要更新的 key
|
||||
* @param {any} data 待更新的数据
|
||||
* @example
|
||||
* // UI 层更新自定义 Store 数据
|
||||
* const data: string = '自定义数据'
|
||||
* TUIStore.update(StoreName.CUSTOM, 'customKey', data)
|
||||
*/
|
||||
update(storeName: StoreName, key: string, data: any): void;
|
||||
|
||||
/**
|
||||
* 获取 store 中的数据
|
||||
* @function
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {String} key 需要获取的 key
|
||||
* @private
|
||||
*/
|
||||
getData(storeName: StoreName, key: string): any;
|
||||
|
||||
/**
|
||||
* 获取 conversationModel
|
||||
* @function
|
||||
* @param {string} conversationID 会话 ID
|
||||
* @example
|
||||
* // 获取 conversationModel
|
||||
* const conversationID = 'C2C9241'
|
||||
* const conversationModel = TUIStore.getConversationModel(conversationID);
|
||||
*/
|
||||
getConversationModel(conversationID: string): IConversationModel;
|
||||
|
||||
/**
|
||||
* 获取 messageModel
|
||||
* @function
|
||||
* @param {string} messageID 消息 ID
|
||||
* @example
|
||||
* // 获取 messageModel
|
||||
* const messageID = '144115225790497300-1686557023-31267600'
|
||||
* const messageModel = TUIStore.getMessageModel(messageID);
|
||||
*/
|
||||
getMessageModel(messageID: string): IMessageModel;
|
||||
|
||||
/**
|
||||
* 重置 store 内数据
|
||||
* @function
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {Array<string>} keyList 需要 reset 的 keyList
|
||||
* @param {boolean} isNotificationNeeded 是否需要触发更新
|
||||
* @private
|
||||
*/
|
||||
reset(storeName: StoreName, keyList?: string[], isNotificationNeeded?: boolean): void;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
export interface IUserStore {
|
||||
store: {
|
||||
userProfile: object;
|
||||
displayOnlineStatus: boolean; // 是否开启用户状态显示
|
||||
displayMessageReadReceipt: boolean; // 是否开启消息阅读状态显示
|
||||
userStatusList: Map<string, {
|
||||
statusType: number;
|
||||
customStatus: string;
|
||||
}>; // 订阅用户的状态信息的列表
|
||||
kickedOut: string; // 用户被踢的类型信息
|
||||
netStateChange: string; // 网络状态变更信息
|
||||
userBlacklist: any[]; // 用户黑名单列表
|
||||
targetLanguage: string; // 文本消息翻译目标语言,内部使用
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新 store
|
||||
* @param {Sting} key 待更新的 key
|
||||
* @param {any} data 更新的数据
|
||||
*/
|
||||
update(key: string, data: any): void;
|
||||
|
||||
/**
|
||||
* 从 store 中获取数据
|
||||
* @param {Sting} key 需要获取的 key
|
||||
*/
|
||||
getData(key: string): any;
|
||||
|
||||
/**
|
||||
* reset Store 内数据
|
||||
* @param { Array<string>} keyList 需要 reset 的 keyList
|
||||
*/
|
||||
reset(keyList?: any[]): void;
|
||||
}
|
||||
Reference in New Issue
Block a user