fix: 对话创建防抖
This commit is contained in:
@@ -6,7 +6,7 @@ import type { BubbleProps } from 'vue-element-plus-x/types/Bubble';
|
||||
import type { BubbleListInstance } from 'vue-element-plus-x/types/BubbleList';
|
||||
import type { FilesCardProps } from 'vue-element-plus-x/types/FilesCard';
|
||||
import type { ThinkingStatus } from 'vue-element-plus-x/types/Thinking';
|
||||
import { ArrowLeftBold, ArrowRightBold } from '@element-plus/icons-vue';
|
||||
import { ArrowLeftBold, ArrowRightBold, Loading } from '@element-plus/icons-vue';
|
||||
import { ElIcon, ElMessage } from 'element-plus';
|
||||
import { useHookFetch } from 'hook-fetch/vue';
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
@@ -164,8 +164,12 @@ function handleDataChunk(chunk: AnyObject) {
|
||||
function handleError(err: any) {
|
||||
console.error('Fetch error:', err);
|
||||
}
|
||||
const isSending = ref(false);
|
||||
|
||||
async function startSSE(chatContent: string) {
|
||||
if (isSending.value)
|
||||
return;
|
||||
|
||||
try {
|
||||
// 清空输入框
|
||||
inputValue.value = '';
|
||||
@@ -199,6 +203,8 @@ async function startSSE(chatContent: string) {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
isSending.value = false;
|
||||
|
||||
// 停止打字器状态
|
||||
if (bubbleItems.value.length) {
|
||||
bubbleItems.value[bubbleItems.value.length - 1].typing = false;
|
||||
@@ -348,6 +354,12 @@ function copy(item: any) {
|
||||
<ModelSelect />
|
||||
</div>
|
||||
</template>
|
||||
<!-- 新增的 #suffix 模板 -->
|
||||
<template #suffix>
|
||||
<ElIcon v-if="isSending" class="is-loading">
|
||||
<Loading />
|
||||
</ElIcon>
|
||||
</template>
|
||||
</Sender>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user