@tencentcloud/chat-uikit-wechat
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -0,1 +1,8 @@ | ||
## 2.0.2 (2024-02-04) | ||
### 新增 | ||
- 支持接入客服插件 | ||
- 支持音频消息在 iOS 静音模式播放 | ||
### 优化 | ||
- 优化在微信最新版本8.0.45、8.0.46,消息列表和群组样式问题 | ||
## 2.0.1 (2024-01-08) | ||
@@ -2,0 +9,0 @@ ### 优化 |
@@ -5,2 +5,5 @@ import { parseAudio } from '../../../../../utils/message-parse'; | ||
const myaudio = wx.createInnerAudioContext(); | ||
wx.setInnerAudioOption({ | ||
obeyMuteSwitch: false, // (仅在 iOS 生效)是否遵循静音开关,设置为 false 之后,即使是在静音模式下,也能播放声音 | ||
}); | ||
// eslint-disable-next-line no-undef | ||
@@ -7,0 +10,0 @@ Component({ |
@@ -27,2 +27,14 @@ import logger from '../../../../utils/logger'; | ||
}, | ||
currentChatType: { | ||
type: String, | ||
value: '', | ||
observer(currentChatType) { | ||
const { CONVERSATION_TYPE } = constant; | ||
if (currentChatType === CONVERSATION_TYPE.CUSTOMER_SERVICE) { | ||
this.setData({ | ||
showCallExtension: false, | ||
}); | ||
} | ||
}, | ||
}, | ||
}, | ||
@@ -64,2 +76,3 @@ | ||
textareaHeight: 0, | ||
showCallExtension: true, | ||
}, | ||
@@ -141,3 +154,3 @@ | ||
const content = '发送语音消息,需要在设置中对麦克风进行授权允许'; | ||
wx.authorize({ | ||
wx.authorize({ | ||
scope: 'scope.record', | ||
@@ -154,3 +167,3 @@ success: () => { | ||
}); | ||
} | ||
}, | ||
}); | ||
@@ -403,3 +416,3 @@ } else { | ||
}, | ||
handleShowModal(title, content) { | ||
@@ -477,3 +490,3 @@ wx.showModal({ | ||
// 获取 textarea 组件的实际高度 | ||
const height = res[0].height; | ||
const { height } = res[0]; | ||
if (this.data.textareaHeight !== height) { | ||
@@ -483,3 +496,3 @@ this.triggerEvent('inputHeightChange', {}); | ||
textareaHeight: height, | ||
}) | ||
}); | ||
} | ||
@@ -666,8 +679,8 @@ }); | ||
}).catch((error) => { | ||
logger.log(`| TUI-chat | message-input | sendMessageError: ${error.code} `); | ||
this.triggerEvent('showMessageErrorImage', { | ||
showErrorImageFlag: error.code, | ||
message, | ||
}); | ||
logger.log(`| TUI-chat | message-input | sendMessageError: ${error.code} `); | ||
this.triggerEvent('showMessageErrorImage', { | ||
showErrorImageFlag: error.code, | ||
message, | ||
}); | ||
}); | ||
this.setData({ | ||
@@ -674,0 +687,0 @@ displayFlag: '', |
@@ -174,3 +174,3 @@ import dayjs from '../../../../utils/dayjs'; | ||
// 消息ID前拼接字符串为了解决scroll-into-view,无法跳转以数字开头的ID。 | ||
jumpAim: `ID-${this.filterSystemMessageID(currentMessageList[currentMessageList.length - 1].ID)}`, | ||
jumpAim: `ID-${this.filterSystemMessageID(currentMessageList[currentMessageList.length - 1]?.ID)}`, | ||
}, () => { | ||
@@ -198,3 +198,3 @@ }); | ||
updateScrollToBottom() { | ||
const ID = `ID-${this.filterSystemMessageID(this.data.messageList[this.data.messageList.length - 1].ID)}`; | ||
const ID = `ID-${this.filterSystemMessageID(this.data.messageList[this.data.messageList.length - 1]?.ID)}`; | ||
this.setData({ | ||
@@ -316,3 +316,3 @@ jumpAim: '', | ||
messageList: this.data.messageList, | ||
jumpAim: `ID-${this.filterSystemMessageID(this.data.messageList[this.data.messageList.length - 1].ID)}`, | ||
jumpAim: `ID-${this.filterSystemMessageID(this.data.messageList[this.data.messageList.length - 1]?.ID)}`, | ||
}, () => { | ||
@@ -349,2 +349,5 @@ this.setData({ | ||
filterSystemMessageID(messageID) { | ||
if (!messageID) { | ||
return; | ||
} | ||
const index = messageID.indexOf('@TIM#'); | ||
@@ -473,3 +476,3 @@ const groupIndex = messageID.indexOf('@TGS#'); | ||
this.setData({ | ||
jumpAim: `ID-${this.filterSystemMessageID(this.data.messageList[this.data.messageList.length - 1].ID)}`, | ||
jumpAim: `ID-${this.filterSystemMessageID(this.data.messageList[this.data.messageList.length - 1]?.ID)}`, | ||
showUnreadMessageCount: false, | ||
@@ -485,3 +488,3 @@ newMessageCount: [], | ||
this.setData({ | ||
jumpAim: `ID-${this.filterSystemMessageID(this.data.messageList[this.data.messageList.length - this.data.unreadCount].ID)}`, | ||
jumpAim: `ID-${this.filterSystemMessageID(this.data.messageList[this.data.messageList.length - this.data.unreadCount]?.ID)}`, | ||
showUpJump: false, | ||
@@ -492,3 +495,3 @@ }); | ||
this.setData({ | ||
jumpAim: `ID-${this.filterSystemMessageID(this.data.messageList[this.data.messageList.length - this.data.unreadCount].ID)}`, | ||
jumpAim: `ID-${this.filterSystemMessageID(this.data.messageList[this.data.messageList.length - this.data.unreadCount]?.ID)}`, | ||
showUpJump: false, | ||
@@ -501,3 +504,3 @@ }); | ||
this.setData({ | ||
jumpAim: `ID-${this.filterSystemMessageID(this.data.messageList[this.data.messageList.length - 1].ID)}`, | ||
jumpAim: `ID-${this.filterSystemMessageID(this.data.messageList[this.data.messageList.length - 1]?.ID)}`, | ||
showUnreadMessageCount: false, | ||
@@ -667,5 +670,5 @@ newMessageCount: [], | ||
}) | ||
} | ||
}, | ||
}, | ||
}); |
@@ -15,4 +15,5 @@ { | ||
"MergerMessage": "../MessageElements/MergerMessage/index", | ||
"RevokeMessage": "../MessageElements/RevokeMessage/index" | ||
"RevokeMessage": "../MessageElements/RevokeMessage/index", | ||
"PluginMessage": "../../../../plugins/pluginMessage/index" | ||
} | ||
} |
@@ -5,2 +5,4 @@ // TUIKit-WChat/Chat/index.js | ||
import TUIChatServer from './server'; | ||
import TUICore, { TUIConstants } from '@tencentcloud/tui-core'; | ||
import useChatEngine from '../../utils/useChatEngine'; | ||
// eslint-disable-next-line no-undef | ||
@@ -34,5 +36,2 @@ const app = getApp(); | ||
}); | ||
if (this.data.TUIChatServer) { | ||
this.data.TUIChatServer.updateConversationID(currentConversationID); | ||
} | ||
}, | ||
@@ -72,3 +71,13 @@ }, | ||
}); | ||
this.data.TUIChatServer.updateConversationID(this.data.conversationID); | ||
wx.$TUIKit.getConversationProfile(this.data.conversationID).then((res) => { | ||
if (this.data.TUIChatServer) { | ||
this.data.TUIChatServer.updateConversation(res.data.conversation); | ||
} | ||
this.setChatType(res.data.conversation.type); | ||
TUICore.callService({ | ||
serviceName: TUIConstants.TUICustomerServicePlugin.SERVICE.NAME, | ||
method: TUIConstants.TUICustomerServicePlugin.SERVICE.METHOD.ACTIVE_CONVERSATION, | ||
params: { conversationID: this.data.conversationID }, | ||
}); | ||
}); | ||
const query = wx.createSelectorQuery().in(this); | ||
@@ -112,2 +121,3 @@ query.select('.message-list').boundingClientRect((rect) => { | ||
newGroupProfile: {}, | ||
currentChatType: '', | ||
}, | ||
@@ -120,2 +130,3 @@ | ||
init() { | ||
useChatEngine(); | ||
wx.$TUIKit.setMessageRead({ conversationID: this.data.conversationID }).then(() => { | ||
@@ -157,3 +168,8 @@ logger.log('| TUI-chat | setMessageRead | ok'); | ||
}, | ||
sendMessage(event) { | ||
setChatType(type) { | ||
this.setData({ | ||
currentChatType: type, | ||
}); | ||
}, | ||
updateMessageList(event) { | ||
// 将自己发送的消息写进消息列表里面 | ||
@@ -160,0 +176,0 @@ this.selectComponent('#MessageList').updateMessageList(event.detail.message); |
import TUICore, { TUIConstants } from '@tencentcloud/tui-core'; | ||
export default class TUIChatServer { | ||
static instance; | ||
currentConversationID = ''; | ||
currentConversation = {}; | ||
TUIChat = undefined; | ||
constructor(TUIChat) { | ||
constructor() { | ||
// register service | ||
TUICore.registerService(TUIConstants.TUIChat.SERVICE.NAME, this); | ||
this.TUIChat = TUIChat; | ||
} | ||
@@ -15,30 +14,63 @@ | ||
if (!TUIChatServer.instance) { | ||
TUIChatServer.instance = new TUIChatServer(TUIChat); | ||
TUIChatServer.instance = new TUIChatServer(); | ||
} | ||
TUIChatServer.instance.updateChat(TUIChat); | ||
return TUIChatServer.instance; | ||
} | ||
updateConversationID(conversationID) { | ||
this.currentConversationID = conversationID; | ||
updateChat(chat) { | ||
this.TUIChat = chat; | ||
} | ||
updateConversation(conversation) { | ||
this.currentConversation = conversation; | ||
} | ||
onCall(method, params = {}, callback) { | ||
if (method === TUIConstants.TUIChat.SERVICE.METHOD.UPDATE_MESSAGE_LIST) { | ||
const { message } = params; | ||
// 两种上屏情况 | ||
// 1. 如果 call 消息 conversationID 为 currentConversation, | ||
// 需要借助 UPDATE_MESSAGE_LIST 更新 engine 中 TUIStore 的 messageList 进行上屏 | ||
// (因为此时无法获得自己发送的消息) | ||
// 2. 如果 call 消息 conversationID 不是 currentConversation, | ||
// 下次切换到 call 消息所在会话时, getMessageList 可以获得 所有自己发送的 call 消息 | ||
// 无需此处处理 | ||
if (message?.conversationID === this.currentConversationID) { | ||
this.TUIChat.sendMessage({ | ||
let customMessage; | ||
let textMessage; | ||
const currentMessage = { | ||
to: this.currentConversation.conversationID.replace(this.currentConversation.type, ''), | ||
conversationType: this.currentConversation.type, | ||
payload: params?.payload, | ||
}; | ||
switch (method) { | ||
case TUIConstants.TUIChat.SERVICE.METHOD.UPDATE_MESSAGE_LIST: | ||
if (params?.message?.conversationID === this.currentConversation.conversationID) { | ||
this.TUIChat.updateMessageList({ | ||
detail: { | ||
message: params.message, | ||
}, | ||
}); | ||
} | ||
break; | ||
case TUIConstants.TUIChat.SERVICE.METHOD.SEND_CUSTOM_MESSAGE: | ||
customMessage = wx.$TUIKit.createCustomMessage(currentMessage); | ||
this.TUIChat.updateMessageList({ | ||
detail: { | ||
message, | ||
message: customMessage, | ||
}, | ||
}); | ||
} | ||
wx.$TUIKit.sendMessage(customMessage).then((res) => { | ||
callback && callback(res); | ||
}); | ||
break; | ||
case TUIConstants.TUIChat.SERVICE.METHOD.SEND_TEXT_MESSAGE: | ||
textMessage = wx.$TUIKit.createTextMessage(currentMessage); | ||
this.TUIChat.updateMessageList({ | ||
detail: { | ||
message: textMessage, | ||
}, | ||
}); | ||
wx.$TUIKit.sendMessage(textMessage).then((res) => { | ||
callback && callback(res); | ||
}); | ||
break; | ||
case TUIConstants.TUIChat.SERVICE.METHOD.SET_CHAT_TYPE: | ||
this.TUIChat.setChatType(params?.chatType); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} |
@@ -58,3 +58,3 @@ // eslint-disable-next-line no-undef | ||
if (this.data.searchUser.isChoose) { | ||
this.triggerEvent('searchUserID', { searchUserID: `C2C${this.data.searchUser.userID}` }); | ||
this.triggerEvent('createConversation', { currentConversationID: `C2C${this.data.searchUser.userID}` }); | ||
} else { | ||
@@ -61,0 +61,0 @@ wx.showToast({ |
@@ -57,3 +57,3 @@ // miniprogram/pages/TUI-Group/create-group/create.js | ||
}).then((imResponse) => { // 创建成功 | ||
this.triggerEvent('createGroupID', { createGroupID: `GROUP${imResponse.data.group.groupID}` }); | ||
this.triggerEvent('createConversation', { currentConversationID: `GROUP${imResponse.data.group.groupID}` }); | ||
}) | ||
@@ -60,0 +60,0 @@ .catch((imError) => { |
@@ -71,3 +71,3 @@ import logger from '../../../../utils/logger'; | ||
} else { | ||
this.triggerEvent('searchGroupID', { searchGroupID: `GROUP${this.data.searchGroup.groupID}` }); | ||
this.triggerEvent('createConversation', { currentConversationID: `GROUP${this.data.searchGroup.groupID}` }); | ||
} | ||
@@ -74,0 +74,0 @@ } else { |
@@ -1,2 +0,3 @@ | ||
import constant from "../../utils/constant"; | ||
import constant from '../../utils/constant'; | ||
import useChatEngine from '../../utils/useChatEngine'; | ||
@@ -15,5 +16,6 @@ // TUIKitWChat/Conversation/index.js | ||
array: [ | ||
{ id: 1, name: '发起会话' }, | ||
{ id: 2, name: '发起群聊' }, | ||
{ id: 3, name: '加入群聊' }, | ||
{ id: 1, name: '客服号' }, | ||
{ id: 2, name: '发起会话' }, | ||
{ id: 3, name: '发起群聊' }, | ||
{ id: 4, name: '加入群聊' }, | ||
], | ||
@@ -31,2 +33,3 @@ index: Number, | ||
showJoinGroup: false, | ||
showContact: false, | ||
handleChangeStatus: false, | ||
@@ -36,3 +39,3 @@ storageList: [], | ||
isInit: false, | ||
isExistNav: false | ||
isExistNav: false, | ||
}, | ||
@@ -45,3 +48,3 @@ lifetimes: { | ||
isInit: false, | ||
}) | ||
}); | ||
}, | ||
@@ -58,5 +61,6 @@ }, | ||
showConversation: true, | ||
}) | ||
}); | ||
this.initUserStatus(); | ||
this.setBackIcon(); | ||
useChatEngine(); | ||
}, | ||
@@ -68,3 +72,3 @@ | ||
isExistNav: false, | ||
}) | ||
}); | ||
}, | ||
@@ -79,3 +83,3 @@ | ||
isInit: true, | ||
}) | ||
}); | ||
} | ||
@@ -105,7 +109,6 @@ }, | ||
const prevPages = pages[pages.length - 2]; | ||
if (prevPages && prevPages.route) { | ||
this.setData({ | ||
isExistNav: true, | ||
}) | ||
}); | ||
} | ||
@@ -131,3 +134,3 @@ }, | ||
this.handleConversationList(imResponse.data.conversationList); | ||
}) | ||
}); | ||
} | ||
@@ -189,3 +192,3 @@ }, | ||
}); | ||
this.triggerEvent('currentConversationID', { currentConversationID: event.currentTarget.id, | ||
this.triggerEvent('createConversation', { currentConversationID: event.currentTarget.id, | ||
unreadCount: this.data.conversationList[this.data.index].unreadCount }); | ||
@@ -206,3 +209,3 @@ }, | ||
this.setData({ | ||
showCreateConversation: true, | ||
showContact: true, | ||
showConversationList: false, | ||
@@ -213,3 +216,3 @@ }); | ||
this.setData({ | ||
showCreateGroup: true, | ||
showCreateConversation: true, | ||
showConversationList: false, | ||
@@ -220,2 +223,8 @@ }); | ||
this.setData({ | ||
showCreateGroup: true, | ||
showConversationList: false, | ||
}); | ||
break; | ||
case 4: | ||
this.setData({ | ||
showJoinGroup: true, | ||
@@ -236,3 +245,3 @@ showConversationList: false, | ||
}, | ||
toggleConversationList() { | ||
toggleConversation() { | ||
this.setData({ | ||
@@ -243,13 +252,8 @@ showConversationList: true, | ||
showJoinGroup: false, | ||
showContact: false, | ||
}); | ||
}, | ||
searchUserID(event) { | ||
this.triggerEvent('currentConversationID', { currentConversationID: event.detail.searchUserID }); | ||
handleCreateConversation(event) { | ||
this.triggerEvent('createConversation', { currentConversationID: event.detail.currentConversationID }); | ||
}, | ||
searchGroupID(event) { | ||
this.triggerEvent('currentConversationID', { currentConversationID: event.detail.searchGroupID }); | ||
}, | ||
createGroupID(event) { | ||
this.triggerEvent('currentConversationID', { currentConversationID: event.detail.createGroupID }); | ||
}, | ||
// 处理当前登录账号是否开启在线状态 | ||
@@ -256,0 +260,0 @@ handleChangeStatus() { |
@@ -7,5 +7,6 @@ { | ||
"CreateGroup": "./components/CreateGroup/index", | ||
"JoinGroup": "./components/JoinGroup/index" | ||
"JoinGroup": "./components/JoinGroup/index", | ||
"Contact": "../TUIContact/index" | ||
}, | ||
"navigationStyle": "custom" | ||
} |
@@ -6,2 +6,4 @@ // TUIKitWChat/Chat/index.js | ||
} from '@tencentcloud/tui-core'; | ||
import TUICustomerServer from '@tencentcloud/tui-customer-service-plugin-wechat/server'; | ||
const app = getApp(); | ||
@@ -74,2 +76,3 @@ Component({ | ||
); | ||
TUICustomerServer.getInstance(); | ||
}, | ||
@@ -83,3 +86,3 @@ initCallKit() { | ||
}, | ||
currentConversationID(event) { | ||
createConversation(event) { | ||
this.setData( | ||
@@ -86,0 +89,0 @@ { |
{ | ||
"name": "@tencentcloud/chat-uikit-wechat", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "TUIKit 是基于 IM SDK 实现的一套 UI 组件,其包含会话、聊天、群组、个人资料等功能,基于 TUIKit 组件您可以像搭积木一样快速搭建起自己的业务逻辑。", | ||
@@ -32,7 +32,9 @@ "main": "index.js", | ||
"dependencies": { | ||
"@tencentcloud/chat": "latest", | ||
"@tencentcloud/chat-uikit-engine": "latest", | ||
"@tencentcloud/tui-core": "latest", | ||
"tim-profanity-filter-plugin": "latest", | ||
"tim-upload-plugin": "latest", | ||
"tim-profanity-filter-plugin": "latest", | ||
"@tencentcloud/chat": "latest", | ||
"@tencentcloud/tui-core": "latest" | ||
"@tencentcloud/tui-customer-service-plugin-wechat": "latest" | ||
} | ||
} |
@@ -51,3 +51,6 @@ const constant = { | ||
OPERATING_ENVIRONMENT: 'imWxTuikit' | ||
OPERATING_ENVIRONMENT: 'imWxTuikit', | ||
CONVERSATION_TYPE: { | ||
CUSTOMER_SERVICE: 'customerService' | ||
} | ||
}; | ||
@@ -54,0 +57,0 @@ |
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
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
475369
168
6005
0
6
+ Added@tencentcloud/tui-customer-service-plugin-wechat@latest
+ Added@tencentcloud/chat-uikit-engine@2.3.2(transitive)
+ Added@tencentcloud/tui-customer-service-plugin-wechat@2.2.3(transitive)