@aochuang/client-sdk 1.0.303 → 1.0.305

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.
@@ -256,17 +256,25 @@ export default {
256
256
  return
257
257
  }
258
258
  keyword = this.normalizeSuggestionsKeyword(nearestInfo, keyword)
259
+ const requestId = (this._suggestionsRequestId || 0) + 1
260
+ this._suggestionsRequestId = requestId
259
261
  this.suggestioning = true
260
262
  this.suggestionsKeyword = keyword
263
+ this.popoverActive = true
261
264
  clearTimeout(this._loadSuggestionsTimer)
262
265
  return this.fetchSuggestionsMethod({
263
266
  keyword,
264
267
  nearestInfo,
265
268
  isAtContext: !!(nearestInfo && nearestInfo.isAtContext)
266
269
  }).then(rs => {
270
+ if (requestId !== this._suggestionsRequestId) {
271
+ return
272
+ }
267
273
  this.suggestionsData = rs || []
268
274
  }).finally(() => {
269
- this.suggestioning = false
275
+ if (requestId === this._suggestionsRequestId) {
276
+ this.suggestioning = false
277
+ }
270
278
  })
271
279
  },
272
280
  normalizeSuggestionsKeyword (nearestInfo, keyword) {
@@ -278,7 +286,17 @@ export default {
278
286
  : nearest.replace(/^\s+/, '')
279
287
  },
280
288
  closeSuggestions () {
289
+ clearTimeout(this._loadSuggestionsTimer)
290
+ this._suggestionsRequestId = (this._suggestionsRequestId || 0) + 1
281
291
  this.$refs.suggestions && this.$refs.suggestions.close()
292
+ this.suggestioning = false
293
+ this.popoverActive = false
294
+ },
295
+ hasCurrentSuggestionsContext () {
296
+ const inputValue = this.getInputText()
297
+ const range = this.cacheInputRange || this.getSelectionTextRange()
298
+ const nearestInfo = getNearestString(inputValue, range.start)
299
+ return !!this.normalizeSuggestionsKeyword(nearestInfo)
282
300
  },
283
301
  closeSuggestionsAfterConfirm () {
284
302
  this.closeSuggestions()
@@ -846,8 +864,13 @@ export default {
846
864
  if (this._skipNextSuggestionsLoad) {
847
865
  this._skipNextSuggestionsLoad = false
848
866
  } else {
849
- this.popoverActive = true
850
- this.delayLoadSuggestions(this.inputValue)
867
+ if (this.hasCurrentSuggestionsContext()) {
868
+ this.popoverActive = false
869
+ this.delayLoadSuggestions(this.inputValue)
870
+ } else {
871
+ this.suggestionsNearsetInfo = null
872
+ this.closeSuggestions()
873
+ }
851
874
  }
852
875
  this.$emit('change', {
853
876
  value: this.inputValue,
@@ -861,14 +884,14 @@ export default {
861
884
  if (this.disabled) {
862
885
  return
863
886
  }
864
- this.popoverActive = true
887
+ this.popoverActive = this.hasCurrentSuggestionsContext()
865
888
  this.focus()
866
889
  },
867
890
  handleInputFocus () {
868
891
  if (this.disabled) {
869
892
  return
870
893
  }
871
- this.popoverActive = true
894
+ this.popoverActive = this.hasCurrentSuggestionsContext()
872
895
  this.focus()
873
896
  },
874
897
  clearInput () {
@@ -11,6 +11,20 @@
11
11
  <div class="sdk-contacts-group-select__group-head-col is-full">
12
12
  <div class="sdk-contacts-group-select__group-title">好友分组({{ friendGroupData ? friendGroupData.length : 0 }})</div>
13
13
  </div>
14
+ <template v-if="showRefresh">
15
+ <div class="sdk-contacts-group-select__group-head-col">
16
+ <ui-tooltip content="刷新数据">
17
+ <div class="sdk-contacts-group-select__group-addon" @click="handleFriendRefreshClick">
18
+ <template v-if="friendRefreshing">
19
+ <ui-loading size="mini"></ui-loading>
20
+ </template>
21
+ <template v-else>
22
+ <ui-icon name="refresh-line"></ui-icon>
23
+ </template>
24
+ </div>
25
+ </ui-tooltip>
26
+ </div>
27
+ </template>
14
28
  <div class="sdk-contacts-group-select__group-head-col">
15
29
  <ui-tooltip :content="showFriendFilterPanel ? '关闭筛选' : '展开筛选'">
16
30
  <div class="sdk-contacts-group-select__group-addon" @click="handleFriendAddonClick">
@@ -71,6 +85,20 @@
71
85
  <div class="sdk-contacts-group-select__group-head-col is-full">
72
86
  <div class="sdk-contacts-group-select__group-title">群聊分组({{ roomGroupData ? roomGroupData.length : 0 }})</div>
73
87
  </div>
88
+ <template v-if="showRefresh">
89
+ <div class="sdk-contacts-group-select__group-head-col">
90
+ <ui-tooltip content="刷新数据">
91
+ <div class="sdk-contacts-group-select__group-addon" @click="handleRoomRefreshClick">
92
+ <template v-if="roomRefreshing">
93
+ <ui-loading size="mini"></ui-loading>
94
+ </template>
95
+ <template v-else>
96
+ <ui-icon name="refresh-line"></ui-icon>
97
+ </template>
98
+ </div>
99
+ </ui-tooltip>
100
+ </div>
101
+ </template>
74
102
  <div class="sdk-contacts-group-select__group-head-col">
75
103
  <ui-tooltip :content="showRoomFilterPanel ? '关闭筛选' : '展开筛选'">
76
104
  <div class="sdk-contacts-group-select__group-addon" @click="handleRoomAddonClick">
@@ -143,6 +171,9 @@ export default {
143
171
  ContactsGroupSelectItem
144
172
  },
145
173
  props: {
174
+ showRefresh: {
175
+ type: Boolean
176
+ },
146
177
  friendGroupData: {
147
178
  type: Array
148
179
  },
@@ -151,9 +182,6 @@ export default {
151
182
  },
152
183
  queryGroupDataMethod: {
153
184
  type: Function
154
- },
155
- queryGroupCountMethod: {
156
- type: Function
157
185
  },
158
186
  checkGroupLoadingMethod: {
159
187
  type: Function
@@ -168,6 +196,8 @@ export default {
168
196
  roomGroupEmpty: null
169
197
  },
170
198
  loading: false,
199
+ friendRefreshing: false,
200
+ roomRefreshing: false,
171
201
  showRoomFilterPanel: false,
172
202
  showFriendFilterPanel: false
173
203
  }
@@ -209,18 +239,30 @@ export default {
209
239
  }
210
240
  },
211
241
  created () {
212
- this.loadData()
242
+ this.loading = true
243
+ this.loadData().finally(() => {
244
+ this.loading = false
245
+ })
213
246
  },
214
247
  methods: {
215
248
  loadData () {
216
- this.loading = true
217
- this.queryGroupDataMethod().finally(() => {
218
- this.loading = false
219
- })
249
+ return this.queryGroupDataMethod()
220
250
  },
221
251
  handleFriendToggleEmptyClick () {
222
252
  this.filters.friendGroupEmpty = !this.filters.friendGroupEmpty
223
253
  },
254
+ handleFriendRefreshClick () {
255
+ this.friendRefreshing = true
256
+ this.loadData().finally(() => {
257
+ this.friendRefreshing = false
258
+ })
259
+ },
260
+ handleRoomRefreshClick () {
261
+ this.roomRefreshing = true
262
+ this.loadData().finally(() => {
263
+ this.roomRefreshing = false
264
+ })
265
+ },
224
266
  handleFriendAddonClick () {
225
267
  this.showFriendFilterPanel = !this.showFriendFilterPanel
226
268
  this.$nextTick(() => {
@@ -354,6 +396,10 @@ export default {
354
396
  text-align: center;
355
397
  line-height: 24px;
356
398
  border-radius: 3px;
399
+ display: flex;
400
+ flex-direction: column;
401
+ align-items: center;
402
+ justify-content: center;
357
403
  cursor: pointer;
358
404
  transition: all .25s;
359
405
  color: #999;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aochuang/client-sdk",
3
- "version": "1.0.303",
3
+ "version": "1.0.305",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -14,9 +14,9 @@
14
14
  "access": "public"
15
15
  },
16
16
  "peerDependencies": {
17
- "axios": "^1.3.1",
18
- "@aochuang/common": "1.0.126",
19
- "x2js": "^3.4.4"
17
+ "axios": "*",
18
+ "@aochuang/common": "*",
19
+ "x2js": "*"
20
20
  },
21
21
  "author": "",
22
22
  "license": "ISC"
@@ -839,10 +839,18 @@ export default class ClientChatContacts {
839
839
  throw new Error('群少群id')
840
840
  }
841
841
  if (data && data.length) {
842
- Vue.set(this.data.roomBindMemberMap, roomId, data)
842
+ if (!this.data.roomBindMemberMap[roomId]) {
843
+ Vue.set(this.data.roomBindMemberMap, roomId, [])
844
+ } else {
845
+ this.data.roomBindMemberMap[roomId].length = 0
846
+ }
847
+ data.forEach(v => {
848
+ this.data.roomBindMemberMap[roomId].push(v)
849
+ })
843
850
  } else {
844
851
  Vue.delete(this.data.roomBindMemberMap, roomId)
845
852
  }
853
+ return this.data.roomBindMemberMap[roomId]
846
854
  }
847
855
 
848
856
  loadRoomMemberData (roomId, params, refresh) {
@@ -851,8 +859,7 @@ export default class ClientChatContacts {
851
859
  }
852
860
  if (!this.loadRoomMemberDataPromiseMap[roomId] || refresh) {
853
861
  this.loadRoomMemberDataPromiseMap[roomId] = this.loadContactsRoomMemberDataMethod(params).then((rs) => {
854
- this.setRoomMemberData(roomId, rs.data)
855
- return rs.data
862
+ return this.setRoomMemberData(roomId, rs.data)
856
863
  })
857
864
  }
858
865
  return this.loadRoomMemberDataPromiseMap[roomId]