Socket
Socket
Sign inDemoInstall

@tencentcloud/chat-uikit-vue

Package Overview
Dependencies
Maintainers
8
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tencentcloud/chat-uikit-vue - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

2

package.json
{
"name": "@tencentcloud/chat-uikit-vue",
"version": "1.0.8",
"version": "1.0.9",
"dependencies": {

@@ -5,0 +5,0 @@ "@vueuse/core": "^8.2.6",

@@ -1,5 +0,4 @@

import IComponentServer from '../IComponentServer';
const store:any = {};
const store: any = {};

@@ -12,7 +11,7 @@ /**

export default class TUIContactServer extends IComponentServer {
public TUICore:any;
public store:any;
public TUICore: any;
public store: any;
public currentStore: any = {};
public storeCallback: any;
constructor(TUICore:any) {
constructor(TUICore: any) {
super();

@@ -26,2 +25,3 @@ this.TUICore = TUICore;

* 组件销毁
* destroy
*/

@@ -33,8 +33,9 @@ public destroyed() {

/**
* 数据监听回调
*
* @param {any} newValue 新数据
* @param {any} oldValue 旧数据
*/
updateStore(newValue:any, oldValue:any) {
* 数据监听回调
* data listener callback
*
* @param {any} newValue 新数据/new value
* @param {any} oldValue 旧数据/old value
*/
updateStore(newValue: any, oldValue: any) {
this.currentStore.groupList = newValue.groupList;

@@ -50,2 +51,3 @@ this.currentStore.searchGroup = newValue.searchGroup;

* // TIM 事件监听注册接口
* // TIM Event listener registration interface
* //

@@ -60,2 +62,3 @@ * /////////////////////////////////////////////////////////////////////////////////

this.TUICore.tim.on(this.TUICore.TIM.EVENT.FRIEND_LIST_UPDATED, this.handleFriendListUpdated, this);
this.TUICore.tim.on(this.TUICore.TIM.EVENT.USER_STATUS_UPDATED, this.handleUserStatusUpdated, this);
}

@@ -68,21 +71,31 @@

this.TUICore.tim.off(this.TUICore.TIM.EVENT.FRIEND_LIST_UPDATED, this.handleFriendListUpdated);
this.TUICore.tim.off(this.TUICore.TIM.EVENT.USER_STATUS_UPDATED, this.handleUserStatusUpdated);
}
private handleGroupListUpdated(event:any) {
private handleGroupListUpdated(event: any) {
this.store.groupList = event.data;
}
private handleGroupAttributesUpdated(event:any) {
const { groupID, groupAttributes } = event.data; // 群组ID // 更新后的群属性
private handleGroupAttributesUpdated(event: any) {
const { groupID, groupAttributes } = event.data;
console.log(groupID, groupAttributes);
}
private handleConversationListUpdate(res:any) {
private handleConversationListUpdate(res: any) {
this.handleFilterSystem(res.data);
}
private handleFriendListUpdated(event:any) {
private handleFriendListUpdated(event: any) {
this.currentStore.friendList = event.data;
this.currentStore.userIDList = this.currentStore.friendList.map((item: any) => item.userID);
}
private handleUserStatusUpdated(event: any) {
const userStatusList = event.data;
userStatusList.forEach((item: { userID?: string; statusType?: number; customStatus?: any }) => {
const { userID, statusType, customStatus } = item;
this.currentStore?.userStatusList?.set(userID, { statusType, customStatus });
});
}
/**

@@ -92,2 +105,3 @@ * /////////////////////////////////////////////////////////////////////////////////

* // 处理 TIM 接口参数及回调
* // Handling TIM interface parameters and callbacks
* //

@@ -99,7 +113,8 @@ * /////////////////////////////////////////////////////////////////////////////////

* 处理异步函数
* Handling asynchronous functions
*
* @param {callback} callback 回调函数
* @returns {Promise} 返回异步函数
* @param {callback} callback 回调函数/callback
* @returns {Promise} 返回异步函数/return callback
*/
public handlePromiseCallback(callback:any) {
public handlePromiseCallback(callback: any) {
return new Promise<void>((resolve, reject) => {

@@ -118,2 +133,3 @@ const config = {

* 处理conversationList
* Handle conversation list
*

@@ -123,3 +139,3 @@ * @param {Array} list conversationList

*/
private handleFilterSystem(list:any) {
private handleFilterSystem(list: any) {
const options = {

@@ -129,3 +145,3 @@ allConversationList: list,

};
options.systemConversationList = list.filter((item:any) => item.type === this.TUICore.TIM.TYPES.CONV_SYSTEM);
options.systemConversationList = list.filter((item: any) => item.type === this.TUICore.TIM.TYPES.CONV_SYSTEM);
this.store.allConversationList = options.allConversationList;

@@ -138,18 +154,19 @@ this.store.systemConversationList = options.systemConversationList;

/**
* /////////////////////////////////////////////////////////////////////////////////
* //
* // 对外方法
* //
* /////////////////////////////////////////////////////////////////////////////////
*/
* /////////////////////////////////////////////////////////////////////////////////
* //
* // 对外方法
* // TIM methods
* //
* /////////////////////////////////////////////////////////////////////////////////
*/
/*
* 获取 conversationList
*
* @returns {Promise}
*/
* 获取 conversationList
* Get conversation list
*
* @returns {Promise}
*/
public async getConversationList() {
return this.handlePromiseCallback(async (resolve:any, reject:any) => {
return this.handlePromiseCallback(async (resolve: any, reject: any) => {
try {

@@ -166,6 +183,7 @@ const imResponse = await this.TUICore.tim.getConversationList();

/**
* 获取系统通知 messageList
*
* @returns {Promise}
*/
* 获取系统通知 messageList
* Get system messages
*
* @returns {Promise}
*/
public async getSystemMessageList() {

@@ -176,3 +194,3 @@ const options = {

};
return this.handlePromiseCallback(async (resolve:any, reject:any) => {
return this.handlePromiseCallback(async (resolve: any, reject: any) => {
try {

@@ -189,11 +207,14 @@ const imResponse = await this.TUICore.tim.getMessageList(options);

/**
* 设置已读
*
* @param {string} conversationID 会话ID
* @returns {Promise}
*/
* 设置已读
* Set message read
*
* @param {string} conversationID 会话ID/ conversation's ID
* @returns {Promise}
*/
public async setMessageRead() {
return this.handlePromiseCallback(async (resolve:any, reject:any) => {
return this.handlePromiseCallback(async (resolve: any, reject: any) => {
try {
const imResponse:any = await this.TUICore.tim.setMessageRead({ conversationID: this.store.systemConversation.conversationID });
const imResponse: any = await this.TUICore.tim.setMessageRead({
conversationID: this.store.systemConversation.conversationID,
});
resolve(imResponse);

@@ -207,12 +228,13 @@ } catch (error) {

/**
* 获取群组列表
*
* @param {any} options 参数
* @param {Array.<String>} options.groupProfileFilter 群资料过滤器
* @returns {Promise}
*/
public async getGroupList(options?:any) {
return this.handlePromiseCallback(async (resolve:any, reject:any) => {
* 获取群组列表
* Get group list
*
* @param {any} options 参数/options
* @param {Array.<String>} options.groupProfileFilter 群资料过滤器/group profile filter
* @returns {Promise}
*/
public async getGroupList(options?: any) {
return this.handlePromiseCallback(async (resolve: any, reject: any) => {
try {
let imResponse:any = {};
let imResponse: any = {};
if (!options) {

@@ -232,11 +254,12 @@ imResponse = await this.TUICore.tim.getGroupList();

/**
* 获取群组属性
*
* @param {any} options 参数
* @param {String} options.groupID 群组ID
* @param {Array.<String>} options.groupProfileFilter 群资料过滤器
* @returns {Promise}
*/
public getGroupProfile(options:any): Promise<any> {
return this.handlePromiseCallback(async (resolve:any, reject:any) => {
* 获取群组属性
* Get group profile
*
* @param {any} options 参数/options
* @param {String} options.groupID 群组ID/group's ID
* @param {Array.<String>} options.groupProfileFilter 群资料过滤器/group profile filter
* @returns {Promise}
*/
public getGroupProfile(options: any): Promise<any> {
return this.handlePromiseCallback(async (resolve: any, reject: any) => {
try {

@@ -253,9 +276,10 @@ const imResponse = await this.TUICore.tim.getGroupProfile(options);

/**
* 删除群组
*
* @param {String} groupID 群组ID
* @returns {Promise}
*/
public dismissGroup(groupID:string): Promise<any> {
return this.handlePromiseCallback(async (resolve:any, reject:any) => {
* 删除群组
* Dismiss group
*
* @param {String} groupID 群组ID/group's ID
* @returns {Promise}
*/
public dismissGroup(groupID: string): Promise<any> {
return this.handlePromiseCallback(async (resolve: any, reject: any) => {
try {

@@ -272,17 +296,18 @@ const imResponse = await this.TUICore.tim.dismissGroup(groupID);

/**
* 修改群组资料
*
* @param {any} options 参数
* @param {String} options.groupID 群组ID
* @param {String} options.name 群组名称
* @param {String} options.introduction 群简介
* @param {String} options.notification 群公告
* @param {String} options.avatar 群头像 URL
* @param {Number} options.maxMemberNum 最大群成员数量
* @param {Number} options.joinOption 申请加群处理方式
* @param {Array.<Object>} options.groupCustomField 群组维度的自定义字段
* @returns {Promise}
*/
public updateGroupProfile(options:any): Promise<any> {
return this.handlePromiseCallback(async (resolve:any, reject:any) => {
* 修改群组资料
* Update group profile
*
* @param {any} options 参数/params options
* @param {String} options.groupID 群组ID/group's ID
* @param {String} options.name 群组名称/group's name
* @param {String} options.introduction 群简介/group's introduction
* @param {String} options.notification 群公告/group's notification
* @param {String} options.avatar 群头像 URL/group's avatar url
* @param {Number} options.maxMemberNum 最大群成员数量/the max number of group's member
* @param {Number} options.joinOption 申请加群处理方式/group's join options
* @param {Array.<Object>} options.groupCustomField 群组维度的自定义字段/custom fields for group dimensions
* @returns {Promise}
*/
public updateGroupProfile(options: any): Promise<any> {
return this.handlePromiseCallback(async (resolve: any, reject: any) => {
try {

@@ -299,12 +324,13 @@ const imResponse = await this.TUICore.tim.updateGroupProfile(options);

/**
* 申请加群
*
* @param {any} options 参数
* @param {String} options.groupID 群组ID
* @param {String} options.applyMessage 附言
* @param {String} options.type 群组类型
* @returns {Promise}
*/
public joinGroup(options:any): Promise<any> {
return this.handlePromiseCallback(async (resolve:any, reject:any) => {
* 申请加群
* Join group
*
* @param {any} options 参数/options
* @param {String} options.groupID 群组ID/group's ID
* @param {String} options.applyMessage 附言/apply message
* @param {String} options.type 群组类型/group's type
* @returns {Promise}
*/
public joinGroup(options: any): Promise<any> {
return this.handlePromiseCallback(async (resolve: any, reject: any) => {
try {

@@ -320,9 +346,10 @@ const imResponse = await this.TUICore.tim.joinGroup(options);

/**
* 退出群组
*
* @param {String} groupID 群组ID
* @returns {Promise}
*/
public quitGroup(groupID:string): Promise<any> {
return this.handlePromiseCallback(async (resolve:any, reject:any) => {
* 退出群组
* Quit group
*
* @param {String} groupID 群组ID/group's ID
* @returns {Promise}
*/
public quitGroup(groupID: string): Promise<any> {
return this.handlePromiseCallback(async (resolve: any, reject: any) => {
try {

@@ -338,9 +365,10 @@ const imResponse = await this.TUICore.tim.quitGroup(groupID);

/**
* 通过 groupID 搜索群组
*
* @param {String} groupID 群组ID
* @returns {Promise}
*/
public searchGroupByID(groupID:string): Promise<any> {
return this.handlePromiseCallback(async (resolve:any, reject:any) => {
* 通过 groupID 搜索群组
* Search group by group's ID
*
* @param {String} groupID 群组ID/group's ID
* @returns {Promise}
*/
public searchGroupByID(groupID: string): Promise<any> {
return this.handlePromiseCallback(async (resolve: any, reject: any) => {
try {

@@ -358,13 +386,14 @@ const imResponse = await this.TUICore.tim.searchGroupByID(groupID);

/**
* 处理申请加群
* - 管理员
*
* @param {any} options 参数
* @param {String} options.handleAction 处理结果 Agree(同意) / Reject(拒绝)
* @param {String} options.handleMessage 附言
* @param {Message} options.message 对应【群系统通知】的消息实例
* @returns {Promise}
*/
public handleGroupApplication(options:any): Promise<any> {
return this.handlePromiseCallback(async (resolve:any, reject:any) => {
* 处理申请加群
* Handle group application
* - 管理员/administrator
*
* @param {any} options 参数/options
* @param {String} options.handleAction 处理结果 Agree(同意) / Reject(拒绝)
* @param {String} options.handleMessage 附言/apply message
* @param {Message} options.message 对应【群系统通知】的消息实例/the message corresponding to 【group system notification】
* @returns {Promise}
*/
public handleGroupApplication(options: any): Promise<any> {
return this.handlePromiseCallback(async (resolve: any, reject: any) => {
try {

@@ -380,12 +409,14 @@ const imResponse = await this.TUICore.tim.handleGroupApplication(options);

/**
* 获取 SDK 缓存的好友列表
*
* @param {Array<string>} userIDList 用户的账号列表
* @returns {Promise}
*/
public async getFriendList():Promise<void> {
return this.handlePromiseCallback(async (resolve:any, reject:any) => {
* 获取 SDK 缓存的好友列表
* Get friend list from SDK
*
* @param {Array<string>} userIDList 用户的账号列表/userID list
* @returns {Promise}
*/
public async getFriendList(): Promise<void> {
return this.handlePromiseCallback(async (resolve: any, reject: any) => {
try {
const imResponse = await this.TUICore.tim.getFriendList();
this.currentStore.friendList = imResponse.data;
this.currentStore.userIDList = this.currentStore.friendList.map((item: any) => item.userID) || [];
resolve(imResponse);

@@ -399,8 +430,100 @@ } catch (error) {

/**
* 赋值
*
* @param {Object} params 使用的数据
* @returns {Object} 数据
*/
public async bind(params:any) {
* 获取 用户状态
* Get users’ status
*
* @param {Array<string>} userIDList 用户 userID 列表 / userID list
* @returns {Promise}
*/
public async getUserStatus(userIDList: Array<string>): Promise<void> {
return this.handlePromiseCallback(async (resolve: any, reject: any) => {
try {
if (!userIDList.length) return;
const imResponse = await this.TUICore.tim.getUserStatus({ userIDList });
imResponse?.data?.successUserList?.forEach((item: any) => {
if (item && item?.userID) {
this.currentStore?.userStatusList?.set(item?.userID, {
statusType: item?.statusType,
customStatus: item?.customStatus,
});
}
});
resolve(imResponse);
} catch (error) {
reject(error);
}
});
}
/**
* 订阅 用户状态
* Subscribe users' status
*
* @param {Array<string>} userIDList 用户 userID 列表 / userID list
* @returns {Promise}
*/
public async subscribeUserStatus(userIDList: Array<string>): Promise<void> {
return this.handlePromiseCallback(async (resolve: any, reject: any) => {
try {
if (!userIDList.length) return;
const imResponse = await this.TUICore.tim.subscribeUserStatus({ userIDList });
resolve(imResponse);
} catch (error) {
reject(error);
}
});
}
/**
* 取消订阅 用户状态
* Unscribe users' status
*
* @param {Array<string>} userIDList 用户 userID 列表 / userID list
* @returns {Promise}
*/
public async unsubscribeUserStatus(userIDList?: Array<string>): Promise<void> {
return this.handlePromiseCallback(async (resolve: any, reject: any) => {
try {
if (userIDList && !userIDList.length) return;
const imResponse = await this.TUICore.tim.unsubscribeUserStatus({ userIDList });
this.currentStore?.userStatusList?.clear();
resolve(imResponse);
} catch (error) {
reject(error);
}
});
}
/**
* 处理 用户状态(订阅并获取用户状态 / 取消订阅用户状态)
* Handle users' status ( subscribe and get user status / unsubscribe user status )
*
* @param {boolean} displayOnlineStatus 是否展示用户在线状态 / whether to display the user's online status
* @param {Array<string>} userIDList 用户 userID 列表 / userID list
* @returns {Promise}
*/
public async handleUserStatus(displayOnlineStatus: boolean, userIDList: Array<string>): Promise<void> {
return this.handlePromiseCallback(async (resolve: any, reject: any) => {
try {
setTimeout(async () => {
if (displayOnlineStatus) {
await this.subscribeUserStatus(userIDList);
await this.getUserStatus(userIDList);
} else {
await this.unsubscribeUserStatus(userIDList);
}
}, 1000);
} catch (error) {
reject(error);
}
});
}
/**
* 赋值
* Bind
*
* @param {Object} params 使用的数据/params data
* @returns {Object} 数据/data
*/
public async bind(params: any) {
this.currentStore = params;

@@ -413,3 +536,1 @@ await this.getGroupList();

}

@@ -39,2 +39,8 @@ import IComponentServer from '../IComponentServer';

this.currentStore.conversationData.list = newValue.conversationList;
newValue.conversationList.filter((item: any) => {
if (item?.userProfile?.userID) {
this.currentStore.userIDList.add(item?.userProfile?.userID);
}
});
this.currentStore.userStatusList = this.TUICore.TUIServer.TUIContact.currentStore?.userStatusList;
}

@@ -251,2 +257,3 @@

await this.getConversationList();
this.currentStore.userStatusList = this.TUICore.TUIServer.TUIContact.currentStore?.userStatusList;
return this.currentStore;

@@ -253,0 +260,0 @@ }

import TUIMessage from '../components/message/index';
import Error from './error';
export function caculateTimeago(dateTimeStamp:number) {
export function caculateTimeago(dateTimeStamp: number) {
const { t } = (window as any).TUIKitTUICore.config.i18n.useI18n();
const minute = 1000 * 60; // 把分,时,天,周,半个月,一个月用毫秒表示
const minute = 1000 * 60;
const hour = minute * 60;
const day = hour * 24;
const week = day * 7;
const now = new Date().getTime(); // 获取当前时间毫秒
const diffValue = now - dateTimeStamp;// 时间差
const now = new Date().getTime();
const diffValue = now - dateTimeStamp;
let result = '';

@@ -17,3 +17,3 @@

}
const minC = diffValue / minute; // 计算时间差的分,时,天,周,月
const minC = diffValue / minute;
const hourC = diffValue / hour;

@@ -44,3 +44,4 @@ const dayC = diffValue / day;

// 解析处理系统消息
export function translateGroupSystemNotice(message:any) {
// Handle the system messages
export function translateGroupSystemNotice(message: any) {
const { t } = (window as any).TUIKitTUICore.config.i18n.useI18n();

@@ -58,3 +59,5 @@ const groupName = message.payload.groupProfile.name || message.payload.groupProfile.groupID;

case 5:
return `${t('message.tip.群')}:${groupName} ${t('message.tip.被')} ${message.payload.operatorID} ${t('message.tip.解散')}`;
return `${t('message.tip.群')}:${groupName} ${t('message.tip.被')} ${message.payload.operatorID} ${t(
'message.tip.解散'
)}`;
case 6:

@@ -67,5 +70,9 @@ return `${message.payload.operatorID} ${t('message.tip.创建群')}:${groupName}`;

case 9:
return `${t('message.tip.你被')}${message.payload.operatorID} ${t('message.tip.设置为群')}:${groupName} ${t('message.tip.的管理员')}`;
return `${t('message.tip.你被')}${message.payload.operatorID} ${t('message.tip.设置为群')}:${groupName} ${t(
'message.tip.的管理员'
)}`;
case 10:
return `${t('message.tip.你被')}${message.payload.operatorID} ${t('message.tip.撤销群')}:${groupName} ${t('message.tip.的管理员身份')}`;
return `${t('message.tip.你被')}${message.payload.operatorID} ${t('message.tip.撤销群')}:${groupName} ${t(
'message.tip.的管理员身份'
)}`;
case 12:

@@ -82,5 +89,4 @@ return `${message.payload.operatorID} ${t('message.tip.邀请你加群')}:${groupName}`;

// Different styles of handling H5 and web error prompts
export function handleErrorPrompts(error: any, type:any) {
export function handleErrorPrompts(error: any, type: any) {
console.log(error);

@@ -93,1 +99,13 @@ if (type.isH5) {

}
export function isArrayEqual(a: Array<any>, b: Array<any>) {
if (a.length !== b.length) {
return false;
}
for (let i = 0; i < a.length; i++) {
if (b.indexOf(a[i]) === -1) {
return false;
}
}
return true;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc