diff --git a/core/core-frontend/src/views/copilot/index.vue b/core/core-frontend/src/views/copilot/index.vue index 6535d1628c..1b572ee930 100644 --- a/core/core-frontend/src/views/copilot/index.vue +++ b/core/core-frontend/src/views/copilot/index.vue @@ -151,20 +151,22 @@ const handleShowLeft = val => { } const copilotChatLoading = ref(false) const inputRef = ref() -let time = null -const queryAnswer = () => { +const queryAnswer = (event?: KeyboardEvent) => { + if (event.keyCode === 13) { + event.preventDefault() + } let copyAuestionInput = questionInput.value if (!isActive.value || copilotChatLoading.value) return - clearTimeout(time) - time = setTimeout(() => { - questionInput.value = copyAuestionInput - inputRef.value.blur() - }, 0) + questionInput.value = '' + inputRef.value.blur() + nextTick(() => { + overHeight.value = false + }) historyArr.value.push({ msgType: 'user', chart: {}, id: `${+new Date()}`, - question: questionInput.value, + question: copyAuestionInput, chartData: { data: {}, title: '' @@ -174,7 +176,7 @@ const queryAnswer = () => { copilotChatLoading.value = true copilotChat({ datasetGroupId: datasetId.value, - question: questionInput.value, + question: copyAuestionInput, history: historyBack }) .then(res => { @@ -185,9 +187,6 @@ const queryAnswer = () => { copilotChatLoading.value = false }) } -onBeforeUnmount(() => { - clearTimeout(time) -})