fix(chat): 修复固资管理首轮问答残留中断与历史会话异常

This commit is contained in:
runny committed 2026-06-28 13:11:13 +08:00
1 parent 25876f94bd
commit 3b771fc0b6
16 files changed
+1042 -35

No files matched your search

@@ -3,7 +3,7 @@
* 聊天输入栏:文本框、附件、语音、知识库选择与发送按钮。
*/
<script setup lang="ts">
import { nextTick, onBeforeUnmount, onMounted, ref } from 'vue';
import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import type { Ref } from 'vue';
import {
Check,
@@ -56,6 +56,7 @@ const emit = defineEmits<{
}>();
const filePickerRef = ref<HTMLInputElement | null>(null);
const textareaRef = ref<HTMLTextAreaElement | null>(null);
const attachmentMenuRef = ref<HTMLElement | null>(null);
const kbMenuRef = ref<HTMLElement | null>(null);
const attachmentUrlInputRef = ref<HTMLInputElement | null>(null);
@@ -63,7 +64,6 @@ const showAttachmentMenu = ref(false);
const showAttachmentUrlPanel = ref(false);
const showKbDropdown = ref(false);
const attachmentUrlInput = ref('');
const closeAttachmentMenu = () => {
showAttachmentMenu.value = false;
showAttachmentUrlPanel.value = false;
@@ -138,6 +138,26 @@ onBeforeUnmount(() => {
document.removeEventListener('mousedown', handleDocumentPointerDown);
document.removeEventListener('touchstart', handleDocumentPointerDown);
});
watch(
() => props.isThinking,
async (thinking, prevThinking) => {
if (thinking || !prevThinking || props.isVoiceTranscribing) return;
await nextTick();
textareaRef.value?.focus();
},
);
watch(
() => inputValue.value,
async (value) => {
if (value) return;
await nextTick();
if (textareaRef.value && textareaRef.value.value !== '') {
textareaRef.value.value = '';
}
},
);
</script>
<template>
@@ -145,12 +165,13 @@ onBeforeUnmount(() => {
<div class="relative mx-auto max-w-4xl">
<div class="flex flex-col rounded-2xl bg-surface p-2 shadow-[0_0_15px_rgba(0,0,0,0.05)] transition-all">
<textarea
ref="textareaRef"
v-model="inputValue"
rows="1"
:placeholder="isVoiceTranscribing ? $t('chat.voiceTranscribing') : isVoiceRecording ? $t('chat.voiceListening') : $t('chat.askAnything')"
class="w-full resize-none border-none bg-transparent px-3 py-2 text-[15px] leading-relaxed text-primary placeholder-slate-400 focus:border-transparent focus:outline-none focus:ring-0"
style="min-height: 44px; max-height: 220px;"
:disabled="isThinking || isVoiceTranscribing"
:disabled="isVoiceTranscribing"
spellcheck="false"
autocorrect="off"
autocapitalize="off"
@@ -320,13 +341,14 @@ onBeforeUnmount(() => {
: 'border-brand-500 bg-brand-500 text-white shadow-[0_0_0_4px_rgba(59,130,246,0.18)] hover:scale-105 hover:bg-brand-600 hover:shadow-[0_0_0_6px_rgba(59,130,246,0.24)] active:scale-95'"
@click="emit('send')"
>
<Loader2 v-if="isUploadingAttachments" class="h-4 w-4 animate-spin" />
<Loader2 v-if="isUploadingAttachments || isThinking" class="h-4 w-4 animate-spin" />
<Send v-else class="h-4 w-4" />
</button>
</div>
</div>
<div class="mt-3 text-center text-[11px] text-muted">
{{ $t('chat.disclaimer') }}
<span v-if="isThinking">{{ $t('chat.thinking') }}</span>
<span v-else>{{ $t('chat.disclaimer') }}</span>
</div>
</div>
</footer>