@aochuang/client-sdk 1.0.299 → 1.0.301
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/avatar/avatar.vue +1 -1
- package/components/account-select/account-select.vue +12 -5
- package/components/session-select/session-select-item.vue +4 -4
- package/package.json +1 -1
- package/services/client-chat/client-chat-wechat/client-chat-session.js +3 -0
- package/services/client-chat/client-chat-wechat/client-chat.js +36 -0
- package/services/client-chat/client-chat-wechat/utils.js +2 -1
package/common/avatar/avatar.vue
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<template v-else>
|
|
7
7
|
<template v-if="allowAllAccount">
|
|
8
8
|
<div
|
|
9
|
-
class="sdk-account-select__item is-all" :class="{'is-active': !value}"
|
|
9
|
+
class="sdk-account-select__item is-all" :class="{'is-active': !value, 'is-online': true}"
|
|
10
10
|
@click="handleAccountItemClick(null)"
|
|
11
11
|
>
|
|
12
12
|
<div class="sdk-account-select__item-avatar">
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
<template v-if="data && data.length">
|
|
24
24
|
<div
|
|
25
25
|
class="sdk-account-select__item"
|
|
26
|
-
:class="{'is-active': value === item.id}"
|
|
26
|
+
:class="{'is-active': value === item.id, 'is-online': item[aliveField]}"
|
|
27
27
|
v-for="item in data"
|
|
28
28
|
:key="item.id"
|
|
29
29
|
@click="handleAccountItemClick(item)"
|
|
@@ -147,6 +147,13 @@ export default {
|
|
|
147
147
|
transition: all .25s;
|
|
148
148
|
position: relative;
|
|
149
149
|
}
|
|
150
|
+
.sdk-account-select__item:not(.is-online) {
|
|
151
|
+
color: #666;
|
|
152
|
+
}
|
|
153
|
+
.sdk-account-select__item:not(.is-online) .sdk-account-select__item-avatar{
|
|
154
|
+
filter: grayscale(100%);
|
|
155
|
+
opacity: .8;
|
|
156
|
+
}
|
|
150
157
|
.sdk-account-select__item:not(:last-child) {
|
|
151
158
|
margin-bottom: 2px;
|
|
152
159
|
}
|
|
@@ -178,9 +185,9 @@ export default {
|
|
|
178
185
|
color: #666;
|
|
179
186
|
}
|
|
180
187
|
.sdk-account-select__item-avatar{
|
|
181
|
-
width:
|
|
182
|
-
height:
|
|
183
|
-
min-width:
|
|
188
|
+
width: 36px;
|
|
189
|
+
height: 36px;
|
|
190
|
+
min-width: 36px;
|
|
184
191
|
border-radius: 3px;
|
|
185
192
|
margin-right: 6px;
|
|
186
193
|
position: relative;
|
|
@@ -135,9 +135,9 @@ export default {
|
|
|
135
135
|
.sdk-session-item__avatar{
|
|
136
136
|
margin-right: 12px;
|
|
137
137
|
position: relative;
|
|
138
|
-
min-width:
|
|
139
|
-
width:
|
|
140
|
-
height:
|
|
138
|
+
min-width: 36px;
|
|
139
|
+
width: 36px;
|
|
140
|
+
height: 36px;
|
|
141
141
|
background-color: #eee;
|
|
142
142
|
border-radius: 3px;
|
|
143
143
|
}
|
|
@@ -149,7 +149,7 @@ export default {
|
|
|
149
149
|
}
|
|
150
150
|
&:not(.is-mute) {
|
|
151
151
|
left: calc(~'100% - 12px');
|
|
152
|
-
top: -
|
|
152
|
+
top: -8px;
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
.sdk-session-item__main{
|
package/package.json
CHANGED
|
@@ -394,6 +394,9 @@ export default class ClientChatSession {
|
|
|
394
394
|
if (!data.wechatAccountId) {
|
|
395
395
|
throw new Error('缺少必须参数wechatAccountId')
|
|
396
396
|
}
|
|
397
|
+
if (!Array.isArray(data.lastAtMsgContent)) {
|
|
398
|
+
data.lastAtMsgContent = []
|
|
399
|
+
}
|
|
397
400
|
if (this.onBeforeAddSession && this.onBeforeAddSession({
|
|
398
401
|
data
|
|
399
402
|
}) === false) {
|
|
@@ -46,6 +46,32 @@ function isAutoReadMessage (data) {
|
|
|
46
46
|
return !!(data && data.id && data.id.indexOf('AUTO-READ-') === 0)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
function getAtMessageContent (data) {
|
|
50
|
+
if (!data || data.isSend || !data.content) {
|
|
51
|
+
return null
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const content = JSON.parse(data.content)
|
|
55
|
+
if (!content || (!Array.isArray(content.atIds) || !content.atIds.length) && (!content.text || content.text.indexOf('@所有人') < 0)) {
|
|
56
|
+
return null
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
id: data.id,
|
|
60
|
+
content: data.content
|
|
61
|
+
}
|
|
62
|
+
} catch (e) {
|
|
63
|
+
return null
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function appendLastAtMsgContent (lastAtMsgContent, atMessage) {
|
|
68
|
+
const messages = Array.isArray(lastAtMsgContent) ? lastAtMsgContent : []
|
|
69
|
+
if (!atMessage || messages.some(item => item && item.id === atMessage.id)) {
|
|
70
|
+
return messages
|
|
71
|
+
}
|
|
72
|
+
return messages.concat(atMessage)
|
|
73
|
+
}
|
|
74
|
+
|
|
49
75
|
class ClientChat {
|
|
50
76
|
data = Vue.observable({
|
|
51
77
|
connectStatus: CONNECT_STATUS.Normal
|
|
@@ -252,6 +278,9 @@ class ClientChat {
|
|
|
252
278
|
// 还要更新未读消息数量
|
|
253
279
|
}
|
|
254
280
|
options.onSessionReadChange = ({ session, oldUnreadMsgCount }) => {
|
|
281
|
+
instance.updateSession(session.conversationId, {
|
|
282
|
+
lastAtMsgContent: []
|
|
283
|
+
})
|
|
255
284
|
const isMute = session.mute
|
|
256
285
|
this.account.updateAccountUnreadMessageNum(session.wechatAccountId, ({ unreadMesasgeNum, unreadMessageMuteNum }) => {
|
|
257
286
|
// 如果是免打扰的会话
|
|
@@ -514,6 +543,7 @@ class ClientChat {
|
|
|
514
543
|
onAddMessageSuccess: ({ data }) => {
|
|
515
544
|
const accountId = options.getLoginAccountIdMethod ? options.getLoginAccountIdMethod() : data.accountId
|
|
516
545
|
let sessionId = createSessionId(accountId, data.wechatChatroomId)
|
|
546
|
+
const atMessage = getAtMessageContent(data)
|
|
517
547
|
// 更新会话
|
|
518
548
|
if (!sessionId) {
|
|
519
549
|
return
|
|
@@ -550,6 +580,9 @@ class ClientChat {
|
|
|
550
580
|
rs.data.lastMsgId = data.id
|
|
551
581
|
rs.data.lastUpdateTime = data.updateDate
|
|
552
582
|
}
|
|
583
|
+
if (rs && rs.data && atMessage && !(this.sessionManage.currentSession && this.sessionManage.currentSession.conversationId === sessionId)) {
|
|
584
|
+
rs.data.lastAtMsgContent = appendLastAtMsgContent(rs.data.lastAtMsgContent, atMessage)
|
|
585
|
+
}
|
|
553
586
|
return rs
|
|
554
587
|
}).then((rs) => {
|
|
555
588
|
// 更新账号未读消息数量
|
|
@@ -596,6 +629,9 @@ class ClientChat {
|
|
|
596
629
|
this.session.setSessionRead(sessionId)
|
|
597
630
|
} else {
|
|
598
631
|
nextSession.unreadMsgCount = session.unreadMsgCount + 1
|
|
632
|
+
if (atMessage) {
|
|
633
|
+
nextSession.lastAtMsgContent = appendLastAtMsgContent(session.lastAtMsgContent, atMessage)
|
|
634
|
+
}
|
|
599
635
|
// 更新账号未读消息数量
|
|
600
636
|
this.account.updateAccountUnreadMessageNum(session.wechatAccountId, ({ unreadMesasgeNum, unreadMessageMuteNum }) => {
|
|
601
637
|
if (session.mute) {
|
|
@@ -75,8 +75,9 @@ export function createSessionData (message) {
|
|
|
75
75
|
lastMsgType: message.msgType,
|
|
76
76
|
lastUpdateTime: message.wechatTime,
|
|
77
77
|
targetId,
|
|
78
|
+
lastAtMsgContent: [],
|
|
78
79
|
unreadMsgCount: 0,
|
|
79
80
|
wechatAccountId: message.wechatAccountId
|
|
80
81
|
}
|
|
81
82
|
return nextSession
|
|
82
|
-
}
|
|
83
|
+
}
|