@aochuang/client-sdk 1.0.375 → 1.0.376-wework
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.
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
></span>
|
|
24
24
|
</div>
|
|
25
25
|
</div>
|
|
26
|
-
<div class="sdk-chat-editor-suggestions__body" ref="body"
|
|
26
|
+
<div class="sdk-chat-editor-suggestions__body" ref="body">
|
|
27
27
|
<template v-if="data && data.length">
|
|
28
28
|
<div class="sdk-chat-editor-suggestions__list">
|
|
29
29
|
<div
|
|
@@ -38,9 +38,6 @@
|
|
|
38
38
|
<slot name="item" :data="item"></slot>
|
|
39
39
|
</div>
|
|
40
40
|
</div>
|
|
41
|
-
<div class="sdk-chat-editor-suggestions__more" v-if="loadingMore">
|
|
42
|
-
<ui-loading size="mini"></ui-loading>
|
|
43
|
-
</div>
|
|
44
41
|
</template>
|
|
45
42
|
</div>
|
|
46
43
|
<div class="sdk-chat-editor-suggestions__foot">
|
|
@@ -71,14 +68,6 @@ export default {
|
|
|
71
68
|
type: Boolean,
|
|
72
69
|
default: false
|
|
73
70
|
},
|
|
74
|
-
loadingMore: {
|
|
75
|
-
type: Boolean,
|
|
76
|
-
default: false
|
|
77
|
-
},
|
|
78
|
-
hasMore: {
|
|
79
|
-
type: Boolean,
|
|
80
|
-
default: false
|
|
81
|
-
},
|
|
82
71
|
confirmMethod: {
|
|
83
72
|
type: Function
|
|
84
73
|
}
|
|
@@ -117,18 +106,8 @@ export default {
|
|
|
117
106
|
},
|
|
118
107
|
methods: {
|
|
119
108
|
handleCloseClick () {
|
|
120
|
-
this.$emit('close')
|
|
121
109
|
this.closed = true
|
|
122
110
|
},
|
|
123
|
-
handleBodyScroll (evt) {
|
|
124
|
-
if (!this.hasMore || this.loadingMore) {
|
|
125
|
-
return
|
|
126
|
-
}
|
|
127
|
-
const target = evt.target
|
|
128
|
-
if (target.scrollHeight - target.scrollTop - target.clientHeight <= 20) {
|
|
129
|
-
this.$emit('load-more')
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
111
|
handleItemMouseEnter (item) {
|
|
133
112
|
this.focusId = item.id
|
|
134
113
|
},
|
|
@@ -184,12 +163,6 @@ export default {
|
|
|
184
163
|
// 向下
|
|
185
164
|
if (evt.keyCode === 40) {
|
|
186
165
|
evt.preventDefault()
|
|
187
|
-
if (this.hasMore && !this.loadingMore && index >= this.data.length - 2) {
|
|
188
|
-
this.$emit('load-more')
|
|
189
|
-
}
|
|
190
|
-
if (this.hasMore && index === this.data.length - 1) {
|
|
191
|
-
return
|
|
192
|
-
}
|
|
193
166
|
const nextIndex = index + 1 > this.data.length - 1 ? 0 : index + 1
|
|
194
167
|
this.focusId = this.data[nextIndex].id
|
|
195
168
|
this.scrollTo(this.focusId)
|
|
@@ -207,7 +180,7 @@ export default {
|
|
|
207
180
|
checkAutoFocus () {
|
|
208
181
|
if (!this.data || !this.data.length) {
|
|
209
182
|
this.focusId = null
|
|
210
|
-
} else
|
|
183
|
+
} else {
|
|
211
184
|
this.focusId = this.data[0].id
|
|
212
185
|
}
|
|
213
186
|
},
|
|
@@ -368,10 +341,4 @@ export default {
|
|
|
368
341
|
.sdk-chat-editor-suggestions__item.is-focus:after {
|
|
369
342
|
opacity: 1;
|
|
370
343
|
}
|
|
371
|
-
.sdk-chat-editor-suggestions__more {
|
|
372
|
-
height: 32px;
|
|
373
|
-
display: flex;
|
|
374
|
-
align-items: center;
|
|
375
|
-
justify-content: center;
|
|
376
|
-
}
|
|
377
344
|
</style>
|
|
@@ -46,13 +46,9 @@
|
|
|
46
46
|
ref="suggestions"
|
|
47
47
|
:keyword="suggestionsKeyword"
|
|
48
48
|
:loading="suggestioning"
|
|
49
|
-
:loading-more="suggestionsLoadingMore"
|
|
50
|
-
:has-more="suggestionsHasMore"
|
|
51
49
|
:data="suggestionsData"
|
|
52
50
|
:confirm-method="handleSuggestionsConfirmMethod"
|
|
53
51
|
@closed="handleSuggestionsClosed"
|
|
54
|
-
@close="handleSuggestionsClose"
|
|
55
|
-
@load-more="handleSuggestionsLoadMore"
|
|
56
52
|
>
|
|
57
53
|
<template slot="item" slot-scope="scope">
|
|
58
54
|
<slot name="suggestions-item" v-bind="scope"></slot>
|
|
@@ -87,9 +83,6 @@ export default {
|
|
|
87
83
|
fetchSuggestionsMethod: {
|
|
88
84
|
type: Function
|
|
89
85
|
},
|
|
90
|
-
fetchMoreSuggestionsMethod: {
|
|
91
|
-
type: Function
|
|
92
|
-
},
|
|
93
86
|
confirmSuggestionsMethod: {
|
|
94
87
|
type: Function
|
|
95
88
|
},
|
|
@@ -106,8 +99,6 @@ export default {
|
|
|
106
99
|
sending: false,
|
|
107
100
|
popoverActive: false,
|
|
108
101
|
suggestioning: false,
|
|
109
|
-
suggestionsLoadingMore: false,
|
|
110
|
-
suggestionsHasMore: false,
|
|
111
102
|
suggestionsData: [],
|
|
112
103
|
suggestionsKeyword: null,
|
|
113
104
|
inputValue: this.value || ''
|
|
@@ -136,14 +127,6 @@ export default {
|
|
|
136
127
|
},
|
|
137
128
|
handleSuggestionsClosed () {
|
|
138
129
|
this.suggestionsData = []
|
|
139
|
-
this.suggestionsHasMore = false
|
|
140
|
-
this.suggestionsLoadingMore = false
|
|
141
|
-
},
|
|
142
|
-
handleSuggestionsClose () {
|
|
143
|
-
this.closeSuggestions()
|
|
144
|
-
this.suggestionsNearsetInfo = null
|
|
145
|
-
this.suggestionsData = []
|
|
146
|
-
this.suggestionsKeyword = null
|
|
147
130
|
},
|
|
148
131
|
handleSuggestionsConfirmMethod ({ item }) {
|
|
149
132
|
const next = () => {
|
|
@@ -280,9 +263,6 @@ export default {
|
|
|
280
263
|
const requestId = (this._suggestionsRequestId || 0) + 1
|
|
281
264
|
this._suggestionsRequestId = requestId
|
|
282
265
|
this.suggestioning = true
|
|
283
|
-
this.suggestionsLoadingMore = false
|
|
284
|
-
this.suggestionsHasMore = false
|
|
285
|
-
this.suggestionsData = []
|
|
286
266
|
this.suggestionsKeyword = keyword
|
|
287
267
|
this.popoverActive = true
|
|
288
268
|
clearTimeout(this._loadSuggestionsTimer)
|
|
@@ -294,60 +274,13 @@ export default {
|
|
|
294
274
|
if (requestId !== this._suggestionsRequestId) {
|
|
295
275
|
return
|
|
296
276
|
}
|
|
297
|
-
|
|
298
|
-
this.suggestionsData = result.items
|
|
299
|
-
this.suggestionsHasMore = result.hasMore
|
|
277
|
+
this.suggestionsData = rs || []
|
|
300
278
|
}).finally(() => {
|
|
301
279
|
if (requestId === this._suggestionsRequestId) {
|
|
302
280
|
this.suggestioning = false
|
|
303
281
|
}
|
|
304
282
|
})
|
|
305
283
|
},
|
|
306
|
-
handleSuggestionsLoadMore () {
|
|
307
|
-
if (!this.fetchMoreSuggestionsMethod || !this.suggestionsHasMore || this.suggestionsLoadingMore) {
|
|
308
|
-
return
|
|
309
|
-
}
|
|
310
|
-
const requestId = this._suggestionsRequestId
|
|
311
|
-
const keyword = this.suggestionsKeyword
|
|
312
|
-
const nearestInfo = this.suggestionsNearsetInfo
|
|
313
|
-
this.suggestionsLoadingMore = true
|
|
314
|
-
return Promise.resolve(this.fetchMoreSuggestionsMethod({
|
|
315
|
-
keyword,
|
|
316
|
-
nearestInfo,
|
|
317
|
-
isAtContext: !!(nearestInfo && nearestInfo.isAtContext),
|
|
318
|
-
data: this.suggestionsData.slice()
|
|
319
|
-
})).then(rs => {
|
|
320
|
-
if (requestId !== this._suggestionsRequestId || keyword !== this.suggestionsKeyword) {
|
|
321
|
-
return
|
|
322
|
-
}
|
|
323
|
-
const result = this.normalizeSuggestionsResult(rs)
|
|
324
|
-
const ids = new Set(this.suggestionsData.map(item => item && item.id))
|
|
325
|
-
this.suggestionsData = this.suggestionsData.concat(result.items.filter(item => {
|
|
326
|
-
if (!item || ids.has(item.id)) {
|
|
327
|
-
return false
|
|
328
|
-
}
|
|
329
|
-
ids.add(item.id)
|
|
330
|
-
return true
|
|
331
|
-
}))
|
|
332
|
-
this.suggestionsHasMore = result.hasMore
|
|
333
|
-
}).finally(() => {
|
|
334
|
-
if (requestId === this._suggestionsRequestId) {
|
|
335
|
-
this.suggestionsLoadingMore = false
|
|
336
|
-
}
|
|
337
|
-
})
|
|
338
|
-
},
|
|
339
|
-
normalizeSuggestionsResult (result) {
|
|
340
|
-
if (Array.isArray(result)) {
|
|
341
|
-
return {
|
|
342
|
-
items: result,
|
|
343
|
-
hasMore: false
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
return {
|
|
347
|
-
items: result && Array.isArray(result.items) ? result.items : [],
|
|
348
|
-
hasMore: !!(result && result.hasMore)
|
|
349
|
-
}
|
|
350
|
-
},
|
|
351
284
|
normalizeSuggestionsKeyword (nearestInfo, keyword) {
|
|
352
285
|
const nearest = keyword === undefined
|
|
353
286
|
? (nearestInfo && nearestInfo.nearest) || ''
|
|
@@ -361,8 +294,6 @@ export default {
|
|
|
361
294
|
this._suggestionsRequestId = (this._suggestionsRequestId || 0) + 1
|
|
362
295
|
this.$refs.suggestions && this.$refs.suggestions.close()
|
|
363
296
|
this.suggestioning = false
|
|
364
|
-
this.suggestionsLoadingMore = false
|
|
365
|
-
this.suggestionsHasMore = false
|
|
366
297
|
this.popoverActive = false
|
|
367
298
|
},
|
|
368
299
|
hasCurrentSuggestionsContext () {
|