vue-element-ui-x 1.0.41-beta → 1.0.43-beta
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/lib/components/Sender/index.js +1 -1
- package/lib/components/ThoughtChain/index.js +30 -30
- package/lib/index.common.js +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/index.js +774 -774
- package/lib/index.ssr.js +90 -0
- package/lib/index.umd.js +1 -1
- package/package.json +5 -5
- package/src/components/Attachments/index.js +0 -8
- package/src/components/Attachments/src/main.vue +0 -529
- package/src/components/Bubble/index.js +0 -6
- package/src/components/Bubble/src/main.vue +0 -288
- package/src/components/BubbleList/index.js +0 -8
- package/src/components/BubbleList/src/loading.vue +0 -75
- package/src/components/BubbleList/src/main.vue +0 -444
- package/src/components/Conversations/index.js +0 -8
- package/src/components/Conversations/src/components/item.vue +0 -350
- package/src/components/Conversations/src/main.vue +0 -587
- package/src/components/FilesCard/index.js +0 -8
- package/src/components/FilesCard/src/fileSvg/audio.vue +0 -38
- package/src/components/FilesCard/src/fileSvg/changeFileName.bat +0 -18
- package/src/components/FilesCard/src/fileSvg/code.vue +0 -35
- package/src/components/FilesCard/src/fileSvg/database.vue +0 -94
- package/src/components/FilesCard/src/fileSvg/excel.vue +0 -38
- package/src/components/FilesCard/src/fileSvg/file.vue +0 -40
- package/src/components/FilesCard/src/fileSvg/image.vue +0 -40
- package/src/components/FilesCard/src/fileSvg/index.js +0 -46
- package/src/components/FilesCard/src/fileSvg/link.vue +0 -54
- package/src/components/FilesCard/src/fileSvg/mark.vue +0 -38
- package/src/components/FilesCard/src/fileSvg/pdf.vue +0 -38
- package/src/components/FilesCard/src/fileSvg/ppt.vue +0 -38
- package/src/components/FilesCard/src/fileSvg/three.vue +0 -38
- package/src/components/FilesCard/src/fileSvg/txt.vue +0 -38
- package/src/components/FilesCard/src/fileSvg/unknown.vue +0 -54
- package/src/components/FilesCard/src/fileSvg/video.vue +0 -38
- package/src/components/FilesCard/src/fileSvg/word.vue +0 -38
- package/src/components/FilesCard/src/fileSvg/zip.vue +0 -38
- package/src/components/FilesCard/src/main.vue +0 -403
- package/src/components/FilesCard/src/options.js +0 -18
- package/src/components/Prompts/index.js +0 -8
- package/src/components/Prompts/src/main.vue +0 -248
- package/src/components/Sender/index.js +0 -8
- package/src/components/Sender/src/components/ClearButton.vue +0 -28
- package/src/components/Sender/src/components/Loading.vue +0 -53
- package/src/components/Sender/src/components/LoadingButton.vue +0 -37
- package/src/components/Sender/src/components/SendButton.vue +0 -26
- package/src/components/Sender/src/components/SpeechButton.vue +0 -24
- package/src/components/Sender/src/components/SpeechLoading.vue +0 -87
- package/src/components/Sender/src/components/SpeechLoadingButton.vue +0 -41
- package/src/components/Sender/src/main.vue +0 -803
- package/src/components/Thinking/index.js +0 -8
- package/src/components/Thinking/src/main.vue +0 -199
- package/src/components/ThoughtChain/index.js +0 -8
- package/src/components/ThoughtChain/src/main.vue +0 -291
- package/src/components/Typewriter/index.js +0 -8
- package/src/components/Typewriter/src/main.vue +0 -255
- package/src/components/Welcome/index.js +0 -8
- package/src/components/Welcome/src/main.vue +0 -151
- package/src/index.js +0 -104
- package/src/locale/index.js +0 -97
- package/src/locale/lang/ar.js +0 -18
- package/src/locale/lang/de.js +0 -18
- package/src/locale/lang/en.js +0 -18
- package/src/locale/lang/es.js +0 -18
- package/src/locale/lang/fr.js +0 -18
- package/src/locale/lang/index.js +0 -62
- package/src/locale/lang/it.js +0 -18
- package/src/locale/lang/ja.js +0 -18
- package/src/locale/lang/ko.js +0 -18
- package/src/locale/lang/pt-br.js +0 -18
- package/src/locale/lang/ru-RU.js +0 -18
- package/src/locale/lang/zh-CN.js +0 -18
- package/src/locale/lang/zh-TW.js +0 -18
- package/src/locale/mixin.js +0 -9
- package/src/mixins/index.js +0 -49
- package/src/mixins/recordMixin.js +0 -117
- package/src/mixins/sendMixin.js +0 -450
- package/src/mixins/streamMixin.js +0 -497
- package/src/styles/Attachments.scss +0 -236
- package/src/styles/Bubble.scss +0 -158
- package/src/styles/BubbleList.scss +0 -148
- package/src/styles/Conversations.scss +0 -283
- package/src/styles/FilesCard.scss +0 -222
- package/src/styles/Prompts.scss +0 -197
- package/src/styles/Sender.scss +0 -207
- package/src/styles/Thinking.scss +0 -142
- package/src/styles/ThoughtChain.scss +0 -113
- package/src/styles/Typewriter.scss +0 -66
- package/src/styles/Welcome.scss +0 -283
- package/src/theme/var.scss +0 -183
- package/src/utils/index.js +0 -199
- package/src/utils/scrollDetector.js +0 -34
|
@@ -1,444 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
ref="scrollContainer"
|
|
4
|
-
class="el-x-bubble-list"
|
|
5
|
-
:class="{ 'always-scrollbar': alwaysShowScrollbar }"
|
|
6
|
-
:style="{
|
|
7
|
-
'--el-x-bubble-list-max-height': `${maxHeight}`,
|
|
8
|
-
'--el-x-bubble-list-btn-size': `${btnIconSize}px`,
|
|
9
|
-
}"
|
|
10
|
-
@scroll="handleScroll"
|
|
11
|
-
>
|
|
12
|
-
<Bubble
|
|
13
|
-
v-for="(item, index) in list"
|
|
14
|
-
:key="index"
|
|
15
|
-
:content="item.content"
|
|
16
|
-
:placement="defaultPlacement || item.placement"
|
|
17
|
-
:loading="defaultLoading !== undefined ? defaultLoading : item.loading"
|
|
18
|
-
:shape="defaultShape || item.shape"
|
|
19
|
-
:variant="defaultVariant || item.variant"
|
|
20
|
-
:is-markdown="defaultIsMarkdown !== undefined ? defaultIsMarkdown : item.isMarkdown"
|
|
21
|
-
:is-fog="
|
|
22
|
-
defaultPlacement === 'start' || item.placement === 'start'
|
|
23
|
-
? defaultIsFog !== undefined
|
|
24
|
-
? defaultIsFog
|
|
25
|
-
: item.isFog
|
|
26
|
-
: false
|
|
27
|
-
"
|
|
28
|
-
:typing="
|
|
29
|
-
defaultPlacement === 'start' || item.placement === 'start'
|
|
30
|
-
? defaultTyping !== undefined
|
|
31
|
-
? defaultTyping
|
|
32
|
-
: item.typing
|
|
33
|
-
: false
|
|
34
|
-
"
|
|
35
|
-
:max-width="defaultMaxWidth || item.maxWidth"
|
|
36
|
-
:avatar="defaultAvatar || item.avatar"
|
|
37
|
-
:avatar-size="defaultAvatarSize || item.avatarSize"
|
|
38
|
-
:avatar-gap="defaultAvatarGap || item.avatarGap"
|
|
39
|
-
:avatar-shape="defaultAvatarShape || item.avatarShape"
|
|
40
|
-
:avatar-src-set="defaultAvatarSrcSet || item.avatarSrcSet"
|
|
41
|
-
:avatar-alt="defaultAvatarAlt || item.avatarAlt"
|
|
42
|
-
:avatar-fit="defaultAvatarFit || item.avatarFit"
|
|
43
|
-
:no-style="defaultNoStyle !== undefined ? defaultNoStyle : item.noStyle"
|
|
44
|
-
@finish="instance => handleBubbleComplete(index, instance)"
|
|
45
|
-
>
|
|
46
|
-
<template slot="avatar">
|
|
47
|
-
<slot
|
|
48
|
-
name="avatar"
|
|
49
|
-
:item="item"
|
|
50
|
-
></slot>
|
|
51
|
-
</template>
|
|
52
|
-
<template
|
|
53
|
-
v-if="$scopedSlots.header || $slots.header"
|
|
54
|
-
slot="header"
|
|
55
|
-
>
|
|
56
|
-
<slot
|
|
57
|
-
name="header"
|
|
58
|
-
:item="item"
|
|
59
|
-
/>
|
|
60
|
-
</template>
|
|
61
|
-
<template
|
|
62
|
-
v-if="$scopedSlots.content || $slots.content"
|
|
63
|
-
slot="content"
|
|
64
|
-
>
|
|
65
|
-
<slot
|
|
66
|
-
name="content"
|
|
67
|
-
:item="item"
|
|
68
|
-
/>
|
|
69
|
-
</template>
|
|
70
|
-
<template
|
|
71
|
-
v-if="$scopedSlots.footer || $slots.footer"
|
|
72
|
-
slot="footer"
|
|
73
|
-
>
|
|
74
|
-
<slot
|
|
75
|
-
name="footer"
|
|
76
|
-
:item="item"
|
|
77
|
-
/>
|
|
78
|
-
</template>
|
|
79
|
-
<template
|
|
80
|
-
v-if="$scopedSlots.loading || $slots.loading"
|
|
81
|
-
slot="loading"
|
|
82
|
-
>
|
|
83
|
-
<slot
|
|
84
|
-
name="loading"
|
|
85
|
-
:item="item"
|
|
86
|
-
/>
|
|
87
|
-
</template>
|
|
88
|
-
</Bubble>
|
|
89
|
-
|
|
90
|
-
<!-- 保持原有的返回底部按钮代码不变 -->
|
|
91
|
-
<div
|
|
92
|
-
v-if="showBackToBottom && hasVertical"
|
|
93
|
-
class="el-x-bubble-list-default-back-button"
|
|
94
|
-
:class="{
|
|
95
|
-
'el-x-bubble-list-back-to-bottom-solt': $scopedSlots.backToBottom || $slots.backToBottom,
|
|
96
|
-
}"
|
|
97
|
-
:style="{
|
|
98
|
-
bottom: backButtonPosition.bottom,
|
|
99
|
-
left: backButtonPosition.left,
|
|
100
|
-
}"
|
|
101
|
-
@click="scrollToBottom"
|
|
102
|
-
>
|
|
103
|
-
<slot name="backToBottom">
|
|
104
|
-
<i
|
|
105
|
-
class="el-icon-bottom el-x-bubble-list-back-to-bottom-icon"
|
|
106
|
-
:style="{ color: btnColor }"
|
|
107
|
-
></i>
|
|
108
|
-
<loadingBg
|
|
109
|
-
v-if="btnLoading"
|
|
110
|
-
class="back-to-bottom-loading-svg-bg"
|
|
111
|
-
:style="{ color: btnColor }"
|
|
112
|
-
/>
|
|
113
|
-
</slot>
|
|
114
|
-
</div>
|
|
115
|
-
</div>
|
|
116
|
-
</template>
|
|
117
|
-
|
|
118
|
-
<script>
|
|
119
|
-
import createScrollDetector from '../../../utils/scrollDetector';
|
|
120
|
-
import Bubble from '../../Bubble/index.js';
|
|
121
|
-
import loadingBg from './loading.vue';
|
|
122
|
-
|
|
123
|
-
export default {
|
|
124
|
-
name: 'ElXBubbleList',
|
|
125
|
-
components: {
|
|
126
|
-
Bubble,
|
|
127
|
-
loadingBg,
|
|
128
|
-
},
|
|
129
|
-
props: {
|
|
130
|
-
list: {
|
|
131
|
-
type: Array,
|
|
132
|
-
default: () => [],
|
|
133
|
-
},
|
|
134
|
-
maxHeight: {
|
|
135
|
-
type: String,
|
|
136
|
-
default: '500px',
|
|
137
|
-
},
|
|
138
|
-
triggerIndices: {
|
|
139
|
-
type: [String, Array],
|
|
140
|
-
default: 'only-last',
|
|
141
|
-
},
|
|
142
|
-
alwaysShowScrollbar: {
|
|
143
|
-
type: Boolean,
|
|
144
|
-
default: false,
|
|
145
|
-
},
|
|
146
|
-
backButtonThreshold: {
|
|
147
|
-
type: Number,
|
|
148
|
-
default: 80,
|
|
149
|
-
},
|
|
150
|
-
showBackButton: {
|
|
151
|
-
type: Boolean,
|
|
152
|
-
default: true,
|
|
153
|
-
},
|
|
154
|
-
backButtonPosition: {
|
|
155
|
-
type: Object,
|
|
156
|
-
default: () => ({
|
|
157
|
-
bottom: '20px',
|
|
158
|
-
left: 'calc(50% - 19px)',
|
|
159
|
-
}),
|
|
160
|
-
},
|
|
161
|
-
btnLoading: {
|
|
162
|
-
type: Boolean,
|
|
163
|
-
default: true,
|
|
164
|
-
},
|
|
165
|
-
btnColor: {
|
|
166
|
-
type: String,
|
|
167
|
-
default: '#409EFF',
|
|
168
|
-
},
|
|
169
|
-
btnIconSize: {
|
|
170
|
-
type: Number,
|
|
171
|
-
default: 24,
|
|
172
|
-
},
|
|
173
|
-
// 新增全局默认属性
|
|
174
|
-
defaultPlacement: {
|
|
175
|
-
type: String,
|
|
176
|
-
default: '',
|
|
177
|
-
},
|
|
178
|
-
defaultLoading: {
|
|
179
|
-
type: Boolean,
|
|
180
|
-
default: undefined,
|
|
181
|
-
},
|
|
182
|
-
defaultShape: {
|
|
183
|
-
type: String,
|
|
184
|
-
default: '',
|
|
185
|
-
},
|
|
186
|
-
defaultVariant: {
|
|
187
|
-
type: String,
|
|
188
|
-
default: '',
|
|
189
|
-
},
|
|
190
|
-
defaultIsMarkdown: {
|
|
191
|
-
type: Boolean,
|
|
192
|
-
default: true,
|
|
193
|
-
},
|
|
194
|
-
defaultIsFog: {
|
|
195
|
-
type: Boolean,
|
|
196
|
-
default: false,
|
|
197
|
-
},
|
|
198
|
-
defaultTyping: {
|
|
199
|
-
type: [Boolean, Object],
|
|
200
|
-
default: undefined,
|
|
201
|
-
},
|
|
202
|
-
defaultMaxWidth: {
|
|
203
|
-
type: String,
|
|
204
|
-
default: '',
|
|
205
|
-
},
|
|
206
|
-
defaultAvatar: {
|
|
207
|
-
type: String,
|
|
208
|
-
default: '',
|
|
209
|
-
},
|
|
210
|
-
defaultAvatarSize: {
|
|
211
|
-
type: Number,
|
|
212
|
-
default: undefined,
|
|
213
|
-
},
|
|
214
|
-
defaultAvatarGap: {
|
|
215
|
-
type: Number,
|
|
216
|
-
default: undefined,
|
|
217
|
-
},
|
|
218
|
-
defaultAvatarShape: {
|
|
219
|
-
type: String,
|
|
220
|
-
default: '',
|
|
221
|
-
},
|
|
222
|
-
defaultAvatarSrcSet: {
|
|
223
|
-
type: String,
|
|
224
|
-
default: '',
|
|
225
|
-
},
|
|
226
|
-
defaultAvatarAlt: {
|
|
227
|
-
type: String,
|
|
228
|
-
default: '',
|
|
229
|
-
},
|
|
230
|
-
defaultAvatarFit: {
|
|
231
|
-
type: String,
|
|
232
|
-
default: '',
|
|
233
|
-
},
|
|
234
|
-
defaultNoStyle: {
|
|
235
|
-
type: Boolean,
|
|
236
|
-
default: undefined,
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
data() {
|
|
240
|
-
return {
|
|
241
|
-
scrollContainer: null,
|
|
242
|
-
stopAutoScrollToBottom: false,
|
|
243
|
-
lastScrollTop: 0,
|
|
244
|
-
accumulatedScrollUpDistance: 0,
|
|
245
|
-
resizeObserver: null,
|
|
246
|
-
containerResizeObserver: null, // 新增容器尺寸监听器引用
|
|
247
|
-
showBackToBottom: false,
|
|
248
|
-
hasVertical: false,
|
|
249
|
-
backButtonTimer: null, // 新增计时器变量
|
|
250
|
-
};
|
|
251
|
-
},
|
|
252
|
-
computed: {
|
|
253
|
-
effectiveTriggerIndices() {
|
|
254
|
-
if (this.triggerIndices === 'only-last') {
|
|
255
|
-
const triggerIndices = this.list.filter(item => item.typing).map((_, index) => index);
|
|
256
|
-
return triggerIndices.length > 0 ? [triggerIndices[triggerIndices.length - 1]] : [];
|
|
257
|
-
} else if (this.triggerIndices === 'all') {
|
|
258
|
-
return this.list.map((_, index) => index);
|
|
259
|
-
} else if (Array.isArray(this.triggerIndices)) {
|
|
260
|
-
const validIndices = this.getValidIndices(this.list, this.triggerIndices);
|
|
261
|
-
return validIndices.length > 0 ? [validIndices[validIndices.length - 1]] : [];
|
|
262
|
-
}
|
|
263
|
-
return [];
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
watch: {
|
|
267
|
-
list: {
|
|
268
|
-
handler() {
|
|
269
|
-
if (this.list && this.list.length > 0) {
|
|
270
|
-
this.$nextTick(() => {
|
|
271
|
-
this.autoScroll();
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
},
|
|
275
|
-
immediate: true,
|
|
276
|
-
},
|
|
277
|
-
},
|
|
278
|
-
mounted() {
|
|
279
|
-
this.scrollDetector = createScrollDetector(this.$refs.scrollContainer);
|
|
280
|
-
this.scrollDetector.init();
|
|
281
|
-
this.hasVertical = this.scrollDetector.state.hasVertical;
|
|
282
|
-
|
|
283
|
-
// 添加容器尺寸变化监听
|
|
284
|
-
const containerResizeObserver = new ResizeObserver(() => {
|
|
285
|
-
this.hasVertical =
|
|
286
|
-
this.$refs.scrollContainer.scrollHeight > this.$refs.scrollContainer.clientHeight;
|
|
287
|
-
});
|
|
288
|
-
containerResizeObserver.observe(this.$refs.scrollContainer);
|
|
289
|
-
this.containerResizeObserver = containerResizeObserver;
|
|
290
|
-
},
|
|
291
|
-
beforeDestroy() {
|
|
292
|
-
if (this.resizeObserver) {
|
|
293
|
-
this.resizeObserver.disconnect();
|
|
294
|
-
}
|
|
295
|
-
if (this.containerResizeObserver) {
|
|
296
|
-
this.containerResizeObserver.disconnect();
|
|
297
|
-
}
|
|
298
|
-
if (this.scrollDetector) {
|
|
299
|
-
this.scrollDetector.destroy();
|
|
300
|
-
}
|
|
301
|
-
},
|
|
302
|
-
methods: {
|
|
303
|
-
getValidIndices(list, indices) {
|
|
304
|
-
const validIndices = [];
|
|
305
|
-
const invalidIndices = [];
|
|
306
|
-
for (let i = 0; i < indices.length; i++) {
|
|
307
|
-
const index = indices[i];
|
|
308
|
-
if (index < 0 || index >= list.length || !list[index].typing) {
|
|
309
|
-
invalidIndices.push(index);
|
|
310
|
-
} else {
|
|
311
|
-
validIndices.push(index);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
if (invalidIndices.length > 0) {
|
|
315
|
-
console.warn(`无效索引 ${invalidIndices}`);
|
|
316
|
-
}
|
|
317
|
-
return validIndices;
|
|
318
|
-
},
|
|
319
|
-
scrollToTop() {
|
|
320
|
-
this.stopAutoScrollToBottom = true;
|
|
321
|
-
this.$nextTick(() => {
|
|
322
|
-
this.$refs.scrollContainer.scrollTop = 0;
|
|
323
|
-
});
|
|
324
|
-
},
|
|
325
|
-
scrollToBottom() {
|
|
326
|
-
try {
|
|
327
|
-
if (this.$refs.scrollContainer && this.$refs.scrollContainer.scrollHeight) {
|
|
328
|
-
this.$nextTick(() => {
|
|
329
|
-
this.$refs.scrollContainer.scrollTop = this.$refs.scrollContainer.scrollHeight;
|
|
330
|
-
this.stopAutoScrollToBottom = false;
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
} catch (error) {
|
|
334
|
-
console.warn('[BubbleList error]: ', error);
|
|
335
|
-
}
|
|
336
|
-
},
|
|
337
|
-
scrollToBubble(index) {
|
|
338
|
-
const container = this.$refs.scrollContainer;
|
|
339
|
-
if (!container) return;
|
|
340
|
-
|
|
341
|
-
const bubbles = container.querySelectorAll('.el-x-bubble');
|
|
342
|
-
if (index >= bubbles.length) return;
|
|
343
|
-
|
|
344
|
-
this.stopAutoScrollToBottom = true;
|
|
345
|
-
const targetBubble = bubbles[index];
|
|
346
|
-
|
|
347
|
-
const containerRect = container.getBoundingClientRect();
|
|
348
|
-
const bubbleRect = targetBubble.getBoundingClientRect();
|
|
349
|
-
|
|
350
|
-
const scrollPosition = bubbleRect.top - containerRect.top + container.scrollTop;
|
|
351
|
-
|
|
352
|
-
container.scrollTo({
|
|
353
|
-
top: scrollPosition,
|
|
354
|
-
behavior: 'smooth',
|
|
355
|
-
});
|
|
356
|
-
},
|
|
357
|
-
autoScroll() {
|
|
358
|
-
if (this.$refs.scrollContainer) {
|
|
359
|
-
const listBubbles = this.$refs.scrollContainer.querySelectorAll(
|
|
360
|
-
'.el-x-bubble-content-wrapper',
|
|
361
|
-
);
|
|
362
|
-
if (this.resizeObserver) {
|
|
363
|
-
this.resizeObserver.disconnect();
|
|
364
|
-
}
|
|
365
|
-
const lastItem = listBubbles[listBubbles.length - 1];
|
|
366
|
-
if (lastItem) {
|
|
367
|
-
this.resizeObserver = new ResizeObserver(() => {
|
|
368
|
-
if (!this.stopAutoScrollToBottom) {
|
|
369
|
-
this.scrollToBottom();
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
this.resizeObserver.observe(lastItem);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
},
|
|
376
|
-
handleBubbleComplete(index, instance) {
|
|
377
|
-
if (this.effectiveTriggerIndices.includes(index)) {
|
|
378
|
-
this.$emit('complete', instance, index);
|
|
379
|
-
}
|
|
380
|
-
},
|
|
381
|
-
handleScroll() {
|
|
382
|
-
if (this.$refs.scrollContainer) {
|
|
383
|
-
const { scrollTop, scrollHeight, clientHeight } = this.$refs.scrollContainer;
|
|
384
|
-
|
|
385
|
-
const distanceToBottom = scrollHeight - (scrollTop + clientHeight);
|
|
386
|
-
|
|
387
|
-
// 更新 hasVertical 状态
|
|
388
|
-
this.hasVertical = scrollHeight > clientHeight;
|
|
389
|
-
|
|
390
|
-
// 使用延迟逻辑处理按钮显示
|
|
391
|
-
if (this.showBackButton && distanceToBottom > this.backButtonThreshold) {
|
|
392
|
-
// 如果应该显示按钮,但还没有设置计时器
|
|
393
|
-
if (!this.backButtonTimer) {
|
|
394
|
-
this.backButtonTimer = setTimeout(() => {
|
|
395
|
-
// 再次检查条件,确保 500ms 后仍然需要显示按钮
|
|
396
|
-
const { scrollTop, scrollHeight, clientHeight } = this.$refs.scrollContainer;
|
|
397
|
-
const newDistanceToBottom = scrollHeight - (scrollTop + clientHeight);
|
|
398
|
-
if (newDistanceToBottom > this.backButtonThreshold) {
|
|
399
|
-
this.showBackToBottom = true;
|
|
400
|
-
}
|
|
401
|
-
this.backButtonTimer = null;
|
|
402
|
-
}, 200); // 200ms 延迟
|
|
403
|
-
}
|
|
404
|
-
} else {
|
|
405
|
-
// 如果不应该显示按钮
|
|
406
|
-
if (this.backButtonTimer) {
|
|
407
|
-
clearTimeout(this.backButtonTimer);
|
|
408
|
-
this.backButtonTimer = null;
|
|
409
|
-
}
|
|
410
|
-
this.showBackToBottom = false;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
const isCloseToBottom = scrollTop + clientHeight >= scrollHeight - 30;
|
|
414
|
-
const isScrollingUp = this.lastScrollTop > scrollTop;
|
|
415
|
-
const isScrollingDown = this.lastScrollTop < scrollTop;
|
|
416
|
-
const scrollDelta = this.lastScrollTop - scrollTop;
|
|
417
|
-
this.lastScrollTop = scrollTop;
|
|
418
|
-
|
|
419
|
-
if (isScrollingUp) {
|
|
420
|
-
this.accumulatedScrollUpDistance += scrollDelta;
|
|
421
|
-
if (this.accumulatedScrollUpDistance >= 20) {
|
|
422
|
-
if (!this.stopAutoScrollToBottom) {
|
|
423
|
-
this.stopAutoScrollToBottom = true;
|
|
424
|
-
}
|
|
425
|
-
this.accumulatedScrollUpDistance = 0;
|
|
426
|
-
}
|
|
427
|
-
} else {
|
|
428
|
-
this.accumulatedScrollUpDistance = 0;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
if (isScrollingDown && isCloseToBottom) {
|
|
432
|
-
if (this.stopAutoScrollToBottom) {
|
|
433
|
-
this.stopAutoScrollToBottom = false;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
},
|
|
438
|
-
},
|
|
439
|
-
};
|
|
440
|
-
</script>
|
|
441
|
-
|
|
442
|
-
<style lang="scss" scoped>
|
|
443
|
-
@import '../../../styles/BubbleList.scss';
|
|
444
|
-
</style>
|