@aochuang/client-sdk 1.0.382 → 1.0.400
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/components/chat-editor/chat-editor-suggestions/chat-editor-suggestions.vue +4 -40
- package/components/chat-editor/chat-editor.vue +5 -75
- package/components/index.js +6 -1
- package/components/session-select/session-select-item.vue +8 -9
- package/components/wechat-chat-control/location/location.vue +6 -14
- package/components/wework-chat-control/channel-card/channel-card.vue +144 -0
- package/components/wework-chat-control/channel-live/channel-live.vue +7 -2
- package/components/wework-chat-control/company-card/company-card.vue +1 -1
- package/components/wework-chat-control/custom-expression/custom-expression.vue +2 -1
- package/components/wework-chat-control/file-url/file-url.vue +34 -16
- package/components/wework-chat-control/image/image.vue +137 -2
- package/components/wework-chat-control/index.js +15 -7
- package/components/wework-chat-control/location/location.vue +3 -3
- package/components/wework-chat-control/merge-message/merge-message-panel.vue +63 -0
- package/components/wework-chat-control/merge-message/merge-message.vue +84 -0
- package/components/wework-chat-control/merge-message/util.js +59 -0
- package/components/wework-chat-control/metting/enterprise-wechat.png +0 -0
- package/components/wework-chat-control/metting/meeting-video.svg +4 -0
- package/components/wework-chat-control/metting/metting.vue +181 -0
- package/components/wework-chat-control/red-envelopes/red-envelopes.vue +3 -2
- package/components/wework-chat-control/text/text-default.vue +99 -0
- package/components/wework-chat-control/text/text-quote.vue +138 -0
- package/components/wework-chat-control/text/text.vue +27 -143
- package/components/wework-chat-control/url/url-channel-live.vue +53 -0
- package/components/wework-chat-control/url/url-miniprogram.vue +6 -7
- package/components/wework-chat-control/url/url.vue +26 -2
- package/components/wework-chat-control/util.js +30 -17
- package/components/wework-chat-control/video/video.vue +11 -3
- package/components/wework-chat-control/voice/voice.vue +14 -3
- package/components/wework-chat-control/wework-chat-control-config-item.vue +24 -0
- package/components/wework-chat-control/wework-chat-control-config-msg.vue +25 -0
- package/{uni-components/chat-control/chat-control-config.vue → components/wework-chat-control/wework-chat-control-config.vue} +16 -13
- package/components/wework-chat-panel/chat-panel-chat-status/chat-panel-chat-status.vue +120 -0
- package/components/wework-chat-panel/chat-panel-item.vue +70 -39
- package/components/wework-chat-panel/chat-panel.vue +96 -13
- package/package.json +10 -3
- package/services/client-chat/client-chat-wechat/client-chat-session.js +2 -8
- package/services/client-chat/client-chat-wework/client-chat-account.js +93 -1
- package/services/client-chat/client-chat-wework/client-chat-concats.js +104 -18
- package/services/client-chat/client-chat-wework/client-chat-message.js +268 -11
- package/services/client-chat/client-chat-wework/client-chat-session.js +271 -191
- package/services/client-chat/client-chat-wework/client-chat-socket.js +18 -2
- package/services/client-chat/client-chat-wework/client-chat.js +470 -85
- package/services/client-chat/client-chat-wework/docs/README.md +308 -0
- package/services/client-chat/client-chat-wework/utils.js +5 -5
- package/components/wework-chat-panel/chat-panel-controls/company-card/company-card.vue +0 -35
- package/components/wework-chat-panel/chat-panel-controls/expression/expression.vue +0 -36
- package/components/wework-chat-panel/chat-panel-controls/file-url/file-url.vue +0 -35
- package/components/wework-chat-panel/chat-panel-controls/image/image.vue +0 -36
- package/components/wework-chat-panel/chat-panel-controls/index.js +0 -35
- package/components/wework-chat-panel/chat-panel-controls/jx-sys-text/jx-sys-text.vue +0 -28
- package/components/wework-chat-panel/chat-panel-controls/link/link.vue +0 -35
- package/components/wework-chat-panel/chat-panel-controls/location/location.vue +0 -35
- package/components/wework-chat-panel/chat-panel-controls/text/text.vue +0 -43
- package/components/wework-chat-panel/chat-panel-controls/unkonw/unkonw.vue +0 -39
- package/components/wework-chat-panel/chat-panel-controls/video/video.vue +0 -37
- package/components/wework-chat-panel/chat-panel-controls/voice/voice.vue +0 -35
- package/uni-common/account-portray/account-portray.vue +0 -51
- package/uni-common/account-select/account-select-item.vue +0 -172
- package/uni-common/account-select/account-select.vue +0 -252
- package/uni-common/all-friend-avatar/all-friend-avatar.vue +0 -49
- package/uni-common/friend-avatar/default.svg +0 -1
- package/uni-common/friend-avatar/friend-avatar.vue +0 -27
- package/uni-common/friend-avatar/index.js +0 -3
- package/uni-common/friend-loader/friend-loader.vue +0 -53
- package/uni-common/friend-portray/friend-portray.vue +0 -56
- package/uni-common/group-avatar/default.svg +0 -1
- package/uni-common/group-avatar/group-avatar.vue +0 -18
- package/uni-common/group-avatar/index.js +0 -3
- package/uni-common/room-avatar/default.svg +0 -6
- package/uni-common/room-avatar/index.js +0 -3
- package/uni-common/room-avatar/room-avatar.vue +0 -27
- package/uni-common/room-loader/room-loader.vue +0 -53
- package/uni-common/room-portray/room-portray.vue +0 -56
- package/uni-components/chat-control/calling/calling.vue +0 -91
- package/uni-components/chat-control/calling/phone-fill.svg +0 -1
- package/uni-components/chat-control/calling/vidicon-fill.svg +0 -1
- package/uni-components/chat-control/channel-video/channel-video.vue +0 -89
- package/uni-components/chat-control/channel-video-card/channel-video-card.vue +0 -105
- package/uni-components/chat-control/channel-video-live/channel-video-live.vue +0 -92
- package/uni-components/chat-control/chat-control-config-item/chat-control-config-item.vue +0 -20
- package/uni-components/chat-control/chat-control-config-item/index.js +0 -3
- package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-app.vue +0 -25
- package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-h5.vue +0 -21
- package/uni-components/chat-control/chat-control.vue +0 -218
- package/uni-components/chat-control/company-card/company-card.vue +0 -123
- package/uni-components/chat-control/const.js +0 -28
- package/uni-components/chat-control/expression/expression.vue +0 -41
- package/uni-components/chat-control/image/image.vue +0 -68
- package/uni-components/chat-control/index.js +0 -89
- package/uni-components/chat-control/location/location.vue +0 -110
- package/uni-components/chat-control/member-change/member-change.vue +0 -32
- package/uni-components/chat-control/quote-message/quote-message.vue +0 -216
- package/uni-components/chat-control/real-time-position/real-time-position.vue +0 -62
- package/uni-components/chat-control/redpacket/red-envelope.svg +0 -1
- package/uni-components/chat-control/redpacket/redpacket.vue +0 -75
- package/uni-components/chat-control/share-card/share-card.vue +0 -101
- package/uni-components/chat-control/system/system.vue +0 -69
- package/uni-components/chat-control/system-batch-message/system-batch-message.vue +0 -30
- package/uni-components/chat-control/system-text/system-text.vue +0 -32
- package/uni-components/chat-control/text/text.vue +0 -67
- package/uni-components/chat-control/text-with-at/text-with-at.vue +0 -51
- package/uni-components/chat-control/transfer/red-transfer.svg +0 -1
- package/uni-components/chat-control/transfer/transfer.vue +0 -80
- package/uni-components/chat-control/unkonw/unkonw.vue +0 -37
- package/uni-components/chat-control/url/icons/file-excel-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-info-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-music-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-pdf-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-ppt-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-settings-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-text-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-unknow-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-word-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-zip-line.svg +0 -1
- package/uni-components/chat-control/url/icons/index.js +0 -24
- package/uni-components/chat-control/url/miniprogram.svg +0 -1
- package/uni-components/chat-control/url/url-miniprogram.vue +0 -116
- package/uni-components/chat-control/url/url.vue +0 -306
- package/uni-components/chat-control/url-new/icons/file-excel-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-info-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-music-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-pdf-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-ppt-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-settings-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-text-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-unknow-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-word-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-zip-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/index.js +0 -24
- package/uni-components/chat-control/url-new/url-new.vue +0 -110
- package/uni-components/chat-control/utils.js +0 -12
- package/uni-components/chat-control/video/video.vue +0 -156
- package/uni-components/chat-control/voice/voice.vue +0 -166
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-collect.vue +0 -84
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-system.vue +0 -28
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet.vue +0 -85
- package/uni-components/chat-editor/chat-editor-func/chat-editor-func.vue +0 -157
- package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at-panel.vue +0 -158
- package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at.vue +0 -61
- package/uni-components/chat-editor/chat-editor-func-button/chat-editor-func-button.vue +0 -58
- package/uni-components/chat-editor/chat-editor-func-file/chat-editor-func-file.vue +0 -54
- package/uni-components/chat-editor/chat-editor-func-image/chat-editor-func-image.vue +0 -42
- package/uni-components/chat-editor/chat-editor-func-video/chat-editor-func-video.vue +0 -42
- package/uni-components/chat-editor/chat-editor-func-voice/chat-editor-func-voice.vue +0 -25
- package/uni-components/chat-editor/chat-editor-message-send/chat-editor-message-send.vue +0 -158
- package/uni-components/chat-editor/chat-editor-quote/chat-editor-quote.vue +0 -75
- package/uni-components/chat-editor/chat-editor.vue +0 -257
- package/uni-components/chat-editor/index.js +0 -10
- package/uni-components/chat-editor/util.js +0 -65
- package/uni-components/chat-panel/chat-panel-chats-box.vue +0 -238
- package/uni-components/chat-panel/chat-panel-chats-forward/chat-panel-chats-forward.vue +0 -273
- package/uni-components/chat-panel/chat-panel-chats-item.vue +0 -578
- package/uni-components/chat-panel/chat-panel-chats-status/chat-panel-chats-status.vue +0 -71
- package/uni-components/chat-panel/chat-panel-chats.vue +0 -368
- package/uni-components/chat-panel/chat-panel.vue +0 -227
- package/uni-components/contacts-group-select/contacts-group-select-item.vue +0 -85
- package/uni-components/contacts-group-select/contacts-group-select-panel.vue +0 -119
- package/uni-components/contacts-group-select/contacts-group-select.vue +0 -150
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<sdk-chat-panel
|
|
3
3
|
ref="panel"
|
|
4
|
-
v-bind="
|
|
4
|
+
v-bind="props"
|
|
5
5
|
:is-sender-method="handleIsSenderMethod"
|
|
6
6
|
@initloaded="handleChatsInitLoaded"
|
|
7
7
|
@chat-contextmenu="handleChatContext"
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
:fetch-user-method="fetchUserMethod"
|
|
18
18
|
:config="config"
|
|
19
19
|
>
|
|
20
|
-
|
|
20
|
+
<template slot="chat-append" slot-scope="{ item, updateProp }">
|
|
21
21
|
<chat-panel-chat-status
|
|
22
22
|
:data="item"
|
|
23
23
|
:update-chat-box-prop="updateProp"
|
|
24
24
|
></chat-panel-chat-status>
|
|
25
|
-
</template>
|
|
25
|
+
</template>
|
|
26
26
|
<template slot="chat-prefix" slot-scope="{ item }">
|
|
27
27
|
<template v-if="selectable && handleFilterSelectMessageMethod(item)">
|
|
28
28
|
<div class="sdk-wechat-chat-panel__checkbox">
|
|
@@ -37,18 +37,23 @@
|
|
|
37
37
|
</template>
|
|
38
38
|
<template slot="main">
|
|
39
39
|
<slot name="main"></slot>
|
|
40
|
+
<template v-if="selectable">
|
|
41
|
+
<slot name="selection" :total="checkTotal"></slot>
|
|
42
|
+
</template>
|
|
40
43
|
</template>
|
|
41
44
|
</sdk-chat-panel>
|
|
42
45
|
</template>
|
|
43
46
|
<script>
|
|
44
47
|
import SdkChatPanel from '../chat-panel'
|
|
45
48
|
import ChatPanelItem from './chat-panel-item.vue'
|
|
49
|
+
import ChatPanelChatStatus from './chat-panel-chat-status/chat-panel-chat-status.vue'
|
|
46
50
|
|
|
47
51
|
export default {
|
|
48
52
|
name: 'SdkWeworkChatPanel',
|
|
49
53
|
components: {
|
|
50
54
|
SdkChatPanel,
|
|
51
|
-
ChatPanelItem
|
|
55
|
+
ChatPanelItem,
|
|
56
|
+
ChatPanelChatStatus
|
|
52
57
|
},
|
|
53
58
|
props: {
|
|
54
59
|
mode: {
|
|
@@ -59,7 +64,8 @@ export default {
|
|
|
59
64
|
}
|
|
60
65
|
},
|
|
61
66
|
keyField: {
|
|
62
|
-
type: String
|
|
67
|
+
type: String,
|
|
68
|
+
default: 'id'
|
|
63
69
|
},
|
|
64
70
|
startDate: {
|
|
65
71
|
type: Number
|
|
@@ -88,9 +94,6 @@ export default {
|
|
|
88
94
|
type: Boolean,
|
|
89
95
|
default: true
|
|
90
96
|
},
|
|
91
|
-
renderControl: {
|
|
92
|
-
type: Function
|
|
93
|
-
},
|
|
94
97
|
fetchUserMethod: {
|
|
95
98
|
type: Function
|
|
96
99
|
},
|
|
@@ -126,14 +129,35 @@ export default {
|
|
|
126
129
|
},
|
|
127
130
|
contextChatId: {
|
|
128
131
|
type: String
|
|
132
|
+
},
|
|
133
|
+
onBeforeSelectionChange: {
|
|
134
|
+
type: Function
|
|
129
135
|
}
|
|
130
136
|
},
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
137
|
+
data () {
|
|
138
|
+
return {
|
|
139
|
+
checkMsgMap: {}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
computed: {
|
|
143
|
+
props () {
|
|
144
|
+
const { config, ...nextProps } = this.$props
|
|
145
|
+
return nextProps
|
|
134
146
|
},
|
|
147
|
+
checkTotal () {
|
|
148
|
+
return Object.keys(this.checkMsgMap).length
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
watch: {
|
|
152
|
+
selectable () {
|
|
153
|
+
if (!this.selectable) {
|
|
154
|
+
this.checkMsgMap = {}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
methods: {
|
|
135
159
|
handleIsSenderMethod ({ item }) {
|
|
136
|
-
return !!item.
|
|
160
|
+
return !!item.isSend
|
|
137
161
|
},
|
|
138
162
|
handleChatsInitLoaded () {
|
|
139
163
|
this.$emit('initloaded')
|
|
@@ -148,8 +172,67 @@ export default {
|
|
|
148
172
|
this.currentContextChat = null
|
|
149
173
|
return this.$refs.panel && this.$refs.panel.reload()
|
|
150
174
|
},
|
|
175
|
+
handleFilterSelectMessageMethod (msg) {
|
|
176
|
+
if (!this.filterSelectMessageMethod) {
|
|
177
|
+
return true
|
|
178
|
+
}
|
|
179
|
+
return this.filterSelectMessageMethod({
|
|
180
|
+
item: msg
|
|
181
|
+
})
|
|
182
|
+
},
|
|
183
|
+
handleMsgCheckboxChange (msg, value) {
|
|
184
|
+
if (value) {
|
|
185
|
+
this.selectChat(msg)
|
|
186
|
+
} else {
|
|
187
|
+
this.unselectChat(msg)
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
selectChat (chat) {
|
|
191
|
+
if (!chat) {
|
|
192
|
+
return
|
|
193
|
+
}
|
|
194
|
+
if (!this.selectable) {
|
|
195
|
+
console.warn('未开启选择')
|
|
196
|
+
return
|
|
197
|
+
}
|
|
198
|
+
if (this.onBeforeSelectionChange && this.onBeforeSelectionChange({
|
|
199
|
+
chat,
|
|
200
|
+
value: true
|
|
201
|
+
}) === false) {
|
|
202
|
+
return
|
|
203
|
+
}
|
|
204
|
+
this.$set(this.checkMsgMap, chat[this.keyField], chat)
|
|
205
|
+
},
|
|
206
|
+
unselectChat (chat) {
|
|
207
|
+
if (!chat) {
|
|
208
|
+
return
|
|
209
|
+
}
|
|
210
|
+
if (!this.selectable) {
|
|
211
|
+
console.warn('未开启选择')
|
|
212
|
+
return
|
|
213
|
+
}
|
|
214
|
+
if (this.onBeforeSelectionChange && this.onBeforeSelectionChange({
|
|
215
|
+
chat,
|
|
216
|
+
value: false
|
|
217
|
+
}) === false) {
|
|
218
|
+
return
|
|
219
|
+
}
|
|
220
|
+
this.$delete(this.checkMsgMap, chat[this.keyField])
|
|
221
|
+
},
|
|
222
|
+
unselectAllChat () {
|
|
223
|
+
return Object.keys(this.checkMsgMap).map(key => {
|
|
224
|
+
return this.unselectChat(this.checkMsgMap[key])
|
|
225
|
+
})
|
|
226
|
+
},
|
|
227
|
+
getSelectChats () {
|
|
228
|
+
return Object.keys(this.checkMsgMap).map(key => {
|
|
229
|
+
return this.checkMsgMap[key]
|
|
230
|
+
})
|
|
231
|
+
},
|
|
151
232
|
handleChatContext (item, evt) {
|
|
152
|
-
this.$emit('chat-contextmenu',
|
|
233
|
+
this.$emit('chat-contextmenu', {
|
|
234
|
+
item
|
|
235
|
+
}, evt)
|
|
153
236
|
},
|
|
154
237
|
handleChatViewContext ({ item }) {
|
|
155
238
|
this.$emit('chat-view-context', {
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aochuang/client-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.400",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"files": [
|
|
6
|
+
"common",
|
|
7
|
+
"components",
|
|
8
|
+
"services",
|
|
9
|
+
"utils",
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./components/index.js"
|
|
7
14
|
},
|
|
8
15
|
"repository": {
|
|
9
16
|
"type": "git",
|
|
@@ -4,8 +4,6 @@ import { createSessionId } from './utils.js'
|
|
|
4
4
|
import { createPollRequest } from '../../../utils/util.js'
|
|
5
5
|
|
|
6
6
|
const ALL_WECHAT_ACCOUNT_ID = 'all'
|
|
7
|
-
const GET_SESSION_POLL_SPAN_TIME = 5 * 1000
|
|
8
|
-
const GET_SESSION_POLL_TIMEOUT = 10 * 60 * 1000
|
|
9
7
|
|
|
10
8
|
const loopLoadAssignSessionData = (fetchFn, params) => {
|
|
11
9
|
let lastPs = null
|
|
@@ -275,7 +273,7 @@ export default class ClientChatSession {
|
|
|
275
273
|
pollRequest.lastRequestError = error && (error.message || error.errMsg || error.toString && error.toString()) || error
|
|
276
274
|
return Promise.reject(error)
|
|
277
275
|
})
|
|
278
|
-
}
|
|
276
|
+
})
|
|
279
277
|
pollRequest.serializeMethods = serializeMethod ? [serializeMethod] : []
|
|
280
278
|
pollRequest.requestCount = 0
|
|
281
279
|
pollRequest.emptyResponseCount = 0
|
|
@@ -284,9 +282,7 @@ export default class ClientChatSession {
|
|
|
284
282
|
pollRequest.startedAt = Date.now()
|
|
285
283
|
this.pollRequestMap[sessionId] = pollRequest
|
|
286
284
|
this._addGetSessionLog('创建会话轮询', {
|
|
287
|
-
sessionId
|
|
288
|
-
spanTime: GET_SESSION_POLL_SPAN_TIME,
|
|
289
|
-
timeout: GET_SESSION_POLL_TIMEOUT
|
|
285
|
+
sessionId
|
|
290
286
|
})
|
|
291
287
|
pollRequest.ps = pollRequest.start().then(rs => {
|
|
292
288
|
if (!rs.data) {
|
|
@@ -332,8 +328,6 @@ export default class ClientChatSession {
|
|
|
332
328
|
}).catch((error) => {
|
|
333
329
|
this._addGetSessionLog('会话轮询失败', {
|
|
334
330
|
sessionId,
|
|
335
|
-
isTimeout: error === 'timeout',
|
|
336
|
-
timeout: GET_SESSION_POLL_TIMEOUT,
|
|
337
331
|
requestCount: pollRequest.requestCount,
|
|
338
332
|
emptyResponseCount: pollRequest.emptyResponseCount,
|
|
339
333
|
requestErrorCount: pollRequest.requestErrorCount,
|
|
@@ -5,14 +5,20 @@ export default class ClientChatAccount {
|
|
|
5
5
|
data = Vue.observable({
|
|
6
6
|
accountData: [],
|
|
7
7
|
accountUnreadMessageNumData: [],
|
|
8
|
+
accountGreetingUnreadMsgCountData: {},
|
|
8
9
|
currentAccount: null
|
|
9
10
|
})
|
|
10
11
|
|
|
11
12
|
loadAccountDataMethod = null
|
|
12
13
|
|
|
13
14
|
getAccountUnreadMessageNumMethod = null
|
|
15
|
+
|
|
16
|
+
getAccountGreetingUnreadMsgCountMethod = null
|
|
14
17
|
|
|
15
18
|
accountMap = {}
|
|
19
|
+
|
|
20
|
+
// 好友请求数量请求合并,key为账号id列表
|
|
21
|
+
greetingUnreadRequestMap = {}
|
|
16
22
|
|
|
17
23
|
constructor (options) {
|
|
18
24
|
options = Object.assign({
|
|
@@ -21,11 +27,13 @@ export default class ClientChatAccount {
|
|
|
21
27
|
getAccountUnreadMessageNumMethod: null,
|
|
22
28
|
updateAccountMessageReadMethod: null,
|
|
23
29
|
deleteAccountSessionMethod: null,
|
|
30
|
+
getAccountGreetingUnreadMsgCountMethod: null,
|
|
24
31
|
onCurrentAccountChange: null,
|
|
25
32
|
onAccountAdded: null,
|
|
26
33
|
onAccountRemoved: null,
|
|
27
34
|
onUnreadMessageNumChange: null,
|
|
28
|
-
onDeleteAccountSession: null
|
|
35
|
+
onDeleteAccountSession: null,
|
|
36
|
+
onAccountLoaded: null
|
|
29
37
|
}, options)
|
|
30
38
|
if (!options.loadAccountDataMethod) {
|
|
31
39
|
throw new Error('缺少loadAccountDataMethod配置')
|
|
@@ -38,10 +46,12 @@ export default class ClientChatAccount {
|
|
|
38
46
|
this.getAccountUnreadMessageNumMethod = options.getAccountUnreadMessageNumMethod
|
|
39
47
|
this.updateAccountMessageReadMethod = options.updateAccountMessageReadMethod
|
|
40
48
|
this.deleteAccountSessionMethod = options.deleteAccountSessionMethod
|
|
49
|
+
this.getAccountGreetingUnreadMsgCountMethod = options.getAccountGreetingUnreadMsgCountMethod
|
|
41
50
|
this.onAccountAdded = options.onAccountAdded
|
|
42
51
|
this.onAccountRemoved = options.onAccountRemoved,
|
|
43
52
|
this.onUnreadMessageNumChange = options.onUnreadMessageNumChange
|
|
44
53
|
this.onDeleteAccountSession = options.onDeleteAccountSession
|
|
54
|
+
this.onAccountLoaded = options.onAccountLoaded
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
get accountData () {
|
|
@@ -55,6 +65,10 @@ export default class ClientChatAccount {
|
|
|
55
65
|
get currentAccount () {
|
|
56
66
|
return this.data.currentAccount
|
|
57
67
|
}
|
|
68
|
+
|
|
69
|
+
get accountGreetingUnreadMsgCountData () {
|
|
70
|
+
return this.data.accountGreetingUnreadMsgCountData
|
|
71
|
+
}
|
|
58
72
|
|
|
59
73
|
setCurrentAccount (accountId) {
|
|
60
74
|
let account = null
|
|
@@ -81,6 +95,15 @@ export default class ClientChatAccount {
|
|
|
81
95
|
this.addAccount(item)
|
|
82
96
|
})
|
|
83
97
|
}
|
|
98
|
+
// 重新加载后账号对象都被替换了,当前账号需要指向新对象,账号已经不存在了就置为null(界面上选择全部企微号)
|
|
99
|
+
const currentAccount = this.data.currentAccount
|
|
100
|
+
if (currentAccount) {
|
|
101
|
+
if (this.accountMap[currentAccount.id]) {
|
|
102
|
+
this.data.currentAccount = this.accountMap[currentAccount.id]
|
|
103
|
+
} else {
|
|
104
|
+
this.setCurrentAccount(null)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
84
107
|
}
|
|
85
108
|
|
|
86
109
|
getAccountData () {
|
|
@@ -282,6 +305,9 @@ export default class ClientChatAccount {
|
|
|
282
305
|
this._cacheLoadPromise = this.loadAccountDataMethod()
|
|
283
306
|
this._cacheLoadPromise.then(rs => {
|
|
284
307
|
this.setAccountData(rs.data)
|
|
308
|
+
this.onAccountLoaded && this.onAccountLoaded({
|
|
309
|
+
data: rs.data
|
|
310
|
+
})
|
|
285
311
|
})
|
|
286
312
|
this.cancelConnectRequest = () => {
|
|
287
313
|
this._cacheLoadPromise.abort()
|
|
@@ -298,9 +324,75 @@ export default class ClientChatAccount {
|
|
|
298
324
|
return this.loadData()
|
|
299
325
|
}
|
|
300
326
|
|
|
327
|
+
/**
|
|
328
|
+
* 设置指定企微账号的待处理好友请求数量,并重算all
|
|
329
|
+
*/
|
|
330
|
+
setAccountGreetingUnreadMsgCount (params) {
|
|
331
|
+
if (!params || !params.qwAccountId) {
|
|
332
|
+
throw new Error('缺少必须参数')
|
|
333
|
+
}
|
|
334
|
+
Vue.set(this.data.accountGreetingUnreadMsgCountData, params.qwAccountId, params.count || 0)
|
|
335
|
+
this.updateAllAccountGreetingUnreadMsgCount()
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
updateAllAccountGreetingUnreadMsgCount () {
|
|
339
|
+
const allCount = Object.keys(this.data.accountGreetingUnreadMsgCountData).reduce((rs, key) => {
|
|
340
|
+
return key === 'all' ? rs : rs + (this.data.accountGreetingUnreadMsgCountData[key] || 0)
|
|
341
|
+
}, 0)
|
|
342
|
+
Vue.set(this.data.accountGreetingUnreadMsgCountData, 'all', allCount)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* 获取待处理好友请求数量
|
|
347
|
+
* qwAccountIds不传则刷新所有账号;后端数量为0的账号不返回,所以先置0再覆盖
|
|
348
|
+
*/
|
|
349
|
+
getAccountGreetingUnreadMsgCount (params) {
|
|
350
|
+
if (!this.getAccountGreetingUnreadMsgCountMethod) {
|
|
351
|
+
return Promise.reject(new Error('getAccountGreetingUnreadMsgCountMethod未定义'))
|
|
352
|
+
}
|
|
353
|
+
let qwAccountIds = (params || {}).qwAccountIds
|
|
354
|
+
if (qwAccountIds && !Array.isArray(qwAccountIds)) {
|
|
355
|
+
qwAccountIds = [qwAccountIds]
|
|
356
|
+
}
|
|
357
|
+
qwAccountIds = (qwAccountIds || []).filter((id, index, data) => id && data.indexOf(id) === index).map(String)
|
|
358
|
+
const isAll = !qwAccountIds.length
|
|
359
|
+
const requestKey = isAll ? 'all' : qwAccountIds.slice().sort().join(',')
|
|
360
|
+
if (this.greetingUnreadRequestMap[requestKey]) {
|
|
361
|
+
return this.greetingUnreadRequestMap[requestKey]
|
|
362
|
+
}
|
|
363
|
+
const request = this.getAccountGreetingUnreadMsgCountMethod({
|
|
364
|
+
qwAccountIds: isAll ? undefined : qwAccountIds
|
|
365
|
+
}).then(rs => {
|
|
366
|
+
const targetIds = isAll ? Object.keys(this.accountMap) : qwAccountIds
|
|
367
|
+
targetIds.forEach(id => {
|
|
368
|
+
Vue.set(this.data.accountGreetingUnreadMsgCountData, id, 0)
|
|
369
|
+
})
|
|
370
|
+
;((rs && rs.data) || []).forEach(item => {
|
|
371
|
+
if (item && item.qwAccountId) {
|
|
372
|
+
Vue.set(this.data.accountGreetingUnreadMsgCountData, String(item.qwAccountId), item.count || 0)
|
|
373
|
+
}
|
|
374
|
+
})
|
|
375
|
+
this.updateAllAccountGreetingUnreadMsgCount()
|
|
376
|
+
return this.data.accountGreetingUnreadMsgCountData
|
|
377
|
+
}).finally(() => {
|
|
378
|
+
delete this.greetingUnreadRequestMap[requestKey]
|
|
379
|
+
})
|
|
380
|
+
this.greetingUnreadRequestMap[requestKey] = request
|
|
381
|
+
return request
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* 刷新所有账号的待处理好友请求数量
|
|
386
|
+
*/
|
|
387
|
+
refreshAllAccountGreetingUnreadMsgCount () {
|
|
388
|
+
return this.getAccountGreetingUnreadMsgCount()
|
|
389
|
+
}
|
|
390
|
+
|
|
301
391
|
reset () {
|
|
302
392
|
this.data.accountData = []
|
|
303
393
|
this.data.accountUnreadMessageNumData = []
|
|
394
|
+
this.data.accountGreetingUnreadMsgCountData = {}
|
|
395
|
+
this.greetingUnreadRequestMap = {}
|
|
304
396
|
if (this.cancelConnectRequest) {
|
|
305
397
|
this.cancelConnectRequest()
|
|
306
398
|
}
|
|
@@ -126,11 +126,7 @@ export default class ClientChatContacts {
|
|
|
126
126
|
*/
|
|
127
127
|
roomBindMemberMap: {},
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
* 标记通讯录是否修改了
|
|
131
|
-
* 如果修改了,比如接收到了分配好友的会话时,一定通讯录变了,变了的时候界面需要根据这个状态刷新通讯录
|
|
132
|
-
*/
|
|
133
|
-
isModify: false
|
|
129
|
+
modifiedAccountMap: {}
|
|
134
130
|
})
|
|
135
131
|
|
|
136
132
|
friendMap = {}
|
|
@@ -237,10 +233,6 @@ export default class ClientChatContacts {
|
|
|
237
233
|
return this.data.roomGroupData
|
|
238
234
|
}
|
|
239
235
|
|
|
240
|
-
get isModify () {
|
|
241
|
-
return this.data.isModify
|
|
242
|
-
}
|
|
243
|
-
|
|
244
236
|
setRoomGroup (data) {
|
|
245
237
|
this.data.roomGroupData = []
|
|
246
238
|
if (data && data.length) {
|
|
@@ -491,10 +483,10 @@ export default class ClientChatContacts {
|
|
|
491
483
|
}
|
|
492
484
|
}
|
|
493
485
|
const qwAccountId = this.roomMap[id].qwAccountId
|
|
494
|
-
if (qwAccountId && this.data.
|
|
495
|
-
const bindIndex = this.data.
|
|
486
|
+
if (qwAccountId && this.data.accountBindRoomMap[qwAccountId] && this.data.accountBindRoomMap[qwAccountId][groupId]) {
|
|
487
|
+
const bindIndex = this.data.accountBindRoomMap[qwAccountId][groupId].indexOf(this.roomMap[id])
|
|
496
488
|
if (bindIndex >= 0) {
|
|
497
|
-
this.data.
|
|
489
|
+
this.data.accountBindRoomMap[qwAccountId][groupId].splice(bindIndex, 1)
|
|
498
490
|
}
|
|
499
491
|
}
|
|
500
492
|
})
|
|
@@ -611,7 +603,29 @@ export default class ClientChatContacts {
|
|
|
611
603
|
})
|
|
612
604
|
return this._cacheRoomGroupCountMap[qwAccountId]
|
|
613
605
|
}
|
|
614
|
-
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* 清理企微号好友分组数量缓存,同时清理全部企微号的缓存,下次refreshAllFriendGroupCount会重新请求
|
|
609
|
+
*/
|
|
610
|
+
clearAllFriendGroupCountCache (qwAccountId) {
|
|
611
|
+
if (!this._cacheFriendGroupCountMap) {
|
|
612
|
+
return
|
|
613
|
+
}
|
|
614
|
+
delete this._cacheFriendGroupCountMap[qwAccountId]
|
|
615
|
+
delete this._cacheFriendGroupCountMap[null]
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* 清理企微号群聊分组数量缓存,同时清理全部企微号的缓存,下次refreshAllRoomGroupCount会重新请求
|
|
620
|
+
*/
|
|
621
|
+
clearAllRoomGroupCountCache (qwAccountId) {
|
|
622
|
+
if (!this._cacheRoomGroupCountMap) {
|
|
623
|
+
return
|
|
624
|
+
}
|
|
625
|
+
delete this._cacheRoomGroupCountMap[qwAccountId]
|
|
626
|
+
delete this._cacheRoomGroupCountMap[null]
|
|
627
|
+
}
|
|
628
|
+
|
|
615
629
|
getFriend (friendId) {
|
|
616
630
|
if (!this.getContactsFriendMethod) {
|
|
617
631
|
return Promise.reject(new Error('getContactsFriendMethod未定义'))
|
|
@@ -628,6 +642,37 @@ export default class ClientChatContacts {
|
|
|
628
642
|
return rs
|
|
629
643
|
})
|
|
630
644
|
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* 强制从服务端刷新好友资料,绕过本地缓存。
|
|
648
|
+
*/
|
|
649
|
+
refreshFriend (friendId) {
|
|
650
|
+
if (!friendId) {
|
|
651
|
+
return Promise.reject('缺少好友id')
|
|
652
|
+
}
|
|
653
|
+
if (!this.getContactsFriendMethod) {
|
|
654
|
+
return Promise.reject(new Error('getContactsFriendMethod未定义'))
|
|
655
|
+
}
|
|
656
|
+
return this.getContactsFriendMethod({
|
|
657
|
+
id: friendId
|
|
658
|
+
}).then(rs => {
|
|
659
|
+
if (!rs || !rs.data) {
|
|
660
|
+
return Promise.reject('未找到好友' + friendId)
|
|
661
|
+
}
|
|
662
|
+
if (this.friendMap[friendId]) {
|
|
663
|
+
const nextKeys = Object.keys(rs.data)
|
|
664
|
+
Object.keys(this.friendMap[friendId]).forEach(key => {
|
|
665
|
+
if (!nextKeys.includes(key)) {
|
|
666
|
+
Vue.delete(this.friendMap[friendId], key)
|
|
667
|
+
}
|
|
668
|
+
})
|
|
669
|
+
this.updateFriend(friendId, rs.data)
|
|
670
|
+
} else {
|
|
671
|
+
this.addFriend(rs.data)
|
|
672
|
+
}
|
|
673
|
+
return rs
|
|
674
|
+
})
|
|
675
|
+
}
|
|
631
676
|
|
|
632
677
|
setRoomMemberData (roomId, data) {
|
|
633
678
|
if (!roomId) {
|
|
@@ -738,12 +783,52 @@ export default class ClientChatContacts {
|
|
|
738
783
|
})
|
|
739
784
|
}
|
|
740
785
|
|
|
741
|
-
|
|
742
|
-
|
|
786
|
+
refreshRoom (id) {
|
|
787
|
+
if (!id) {
|
|
788
|
+
return Promise.reject('缺少群id')
|
|
789
|
+
}
|
|
790
|
+
if (!this.getContactsRoomMethod) {
|
|
791
|
+
return Promise.reject(new Error('getContactsRoomMethod未定义'))
|
|
792
|
+
}
|
|
793
|
+
return this.getContactsRoomMethod({
|
|
794
|
+
id
|
|
795
|
+
}).then(rs => {
|
|
796
|
+
if (!rs || !rs.data) {
|
|
797
|
+
return Promise.reject('未找到群' + id)
|
|
798
|
+
}
|
|
799
|
+
const localRoom = this.roomMap[id]
|
|
800
|
+
if (localRoom) {
|
|
801
|
+
this.removeRoom(id)
|
|
802
|
+
const nextKeys = Object.keys(rs.data)
|
|
803
|
+
Object.keys(localRoom).forEach(key => {
|
|
804
|
+
if (!nextKeys.includes(key)) {
|
|
805
|
+
Vue.delete(localRoom, key)
|
|
806
|
+
}
|
|
807
|
+
})
|
|
808
|
+
Object.keys(rs.data).forEach(key => {
|
|
809
|
+
Vue.set(localRoom, key, rs.data[key])
|
|
810
|
+
})
|
|
811
|
+
}
|
|
812
|
+
this.addRoom(localRoom || rs.data)
|
|
813
|
+
return rs
|
|
814
|
+
})
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
isModify (qwAccountId) {
|
|
818
|
+
return !!(qwAccountId && this.data.modifiedAccountMap[qwAccountId])
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
markModify (qwAccountIds) {
|
|
822
|
+
const ids = Array.isArray(qwAccountIds) ? qwAccountIds : [qwAccountIds]
|
|
823
|
+
ids.filter(Boolean).forEach(id => {
|
|
824
|
+
Vue.set(this.data.modifiedAccountMap, id, true)
|
|
825
|
+
})
|
|
743
826
|
}
|
|
744
827
|
|
|
745
|
-
unmarkModify () {
|
|
746
|
-
|
|
828
|
+
unmarkModify (qwAccountId) {
|
|
829
|
+
if (qwAccountId) {
|
|
830
|
+
Vue.delete(this.data.modifiedAccountMap, qwAccountId)
|
|
831
|
+
}
|
|
747
832
|
}
|
|
748
833
|
|
|
749
834
|
reset () {
|
|
@@ -758,6 +843,7 @@ export default class ClientChatContacts {
|
|
|
758
843
|
this.data.groupBindRoomMap = {}
|
|
759
844
|
this.data.accountBindFriendMap = {}
|
|
760
845
|
this.data.accountBindRoomMap = {}
|
|
846
|
+
this.data.modifiedAccountMap = {}
|
|
761
847
|
this._cacheFriendGroupCountMap = null
|
|
762
848
|
this._cacheRoomGroupCountMap = null
|
|
763
849
|
if (this.cancelConnectRequest) {
|
|
@@ -769,4 +855,4 @@ export default class ClientChatContacts {
|
|
|
769
855
|
this.cancelRefreshRequest = null
|
|
770
856
|
}
|
|
771
857
|
}
|
|
772
|
-
}
|
|
858
|
+
}
|