浏览器插件接入工作台
介绍
浏览器接入不需要采用 postMessage 的方式,而是考虑直接使用 document.body 节点上挂载自定义方法的方式,简单而又方便,
返回数据都会放在 event.detail 上,便于使用。
监听当前激活会话信息变动事件 quan-active-chat-msg-change
返回的数据结构 e.detail
返回的数据结构 e.detail 内部的字段结构说明:
| 值 | 描述 |
| event_type | 对应消息变动的事件类型 Qmsg_WsMsgWrapper_MsgType |
| robot_uid | 机器人 id |
| chat_ext_id | 会话 id |
| chat_type | 会话类型: 1 私聊/2 群聊 |
Qmsg_WsMsgWrapper_MsgType 消息事情 类型说明:
| 值 | 描述 |
| 3 | 消息发送失败 |
| 12 | 新消息内容 |
| 20 | 撤回消息 |
查询当前激活会话窗口已经拉取到的所有消息 quan-query-active-chat-msg-list
获取已经拉取到的所有消息 quan-get-active-chat-msg-list
quan-query-active-chat-msg-list 与 quan-get-active-chat-msg-list 需要组合使用,前者派发一个事件,后者监听这个事件,拿到数据。
示例代码:
quan-get-active-chat-msg-list 返回的数据结构 e.detail
quan-get-active-chat-msg-list 返回的数据结构 e.detail 内部的字段结构说明
| 值 | 描述 |
| msg_list | 消息体内容 RobotModelMsgBox 数组 |
| robot_uid | 机器人 id |
| chat_ext_id | 会话 id |
| chat_type | 会话类型: 1 私聊/2 群聊 |
RobotModelMsgBox 字段结构说明
| 值 | 类型 | 描述 |
| robot_uid | string | 机器人 id |
| robot_uid_msg_id | string | 机器人 id 拼接消息 id |
| msg_id | string | 消息 id |
| ruid_chid_chtype | string | 本地会话标识 id |
| error_info | object | 发送错误原因 errorInfo |
| recall_at | number | 撤回时间 |
| being_at | boolean | 是否被 @ |
| last_seq | string | 上一条 chat 维度的消息序号 |
| last_receive_at | number | 上一条 chat 维度的消息时间 |
| seq_id | number | 请求 id |
| created_at | number | 创建时间 |
| updated_at | number | 更新时间 |
| uid | string | 消息归属人 |
| msg_seq | string | 消息序号 |
| chat_type | number | 会话类型: 1 私聊/2 群聊 |
| chat_id | string | 会话 id |
| chat_msg_type | number | 会话消息类型 ChatMsgType |
| msg | string | 消息内容 |
| sent_at | number | 发送时间 |
| sender_account_id | string | 发送者 |
errorInfo 消息类型说明
| 值 | 类型 | 描述 |
| type | number | 0:前端错误、1:发送消息报错 2:错误消息 |
| msg | string | 错误消息内容 |
| code | number | 错误码 |
ChatMsgType 消息类型说明
| 值 | 描述 |
| 0 | 未定义 |
| 1 | 文本消息 |
| 2 | 链接 |
| 3 | 图片消息 |
| 4 | 发送视频 |
| 5 | 发送文件 |
| 6 | 发送好友名片 |
| 7 | 发送语音 |
| 8 | 发送微信小程序 |
| 9 | 多条消息的聚合 |
| 10 | 富文本信息 |
| 11 | 图片消息(异步下载的) |
| 12 | 视频号消息 |
| 13 | 位置消息 |
| 14 | 系统消息 |
| 15 | 撤回消息 |
| 16 | 商品库消息 |
| 17 | 视频号直播 |
| 18 | 发起通话 |
| 19 | 转发的聊天记录 |
| 20 | 语音/视频通话结束 |
| 21 | 会话转介备注信息 |
监听退登事件 quan-chat-login-out