diff --git a/src/pages/ai/chat.vue b/src/pages/ai/chat.vue index f56c46a..cef14b7 100644 --- a/src/pages/ai/chat.vue +++ b/src/pages/ai/chat.vue @@ -1260,20 +1260,21 @@ onLoad(async (op) => { // 获取历史记录 getHistoryMessages(1) - // 每次进入页面都新插入一条开场白信息 - setTimeout(() => { - if (quickQuestionsData.value.length > 0) { - const welcomeMessage: Message = { - role: 'ai', - content: '您好!我是物业客服,有什么可以帮助您的吗?', - quickQuestions: quickQuestionsData.value, - created_at: new Date().toISOString() - } - messages.value.unshift(welcomeMessage) - console.log('[Customer] 每次进入页面都插入开场白消息') - scrollToBottom() + // 每次进入页面都在最前方插入一条新的开场白信息 + if (quickQuestionsData.value.length > 0) { + const welcomeMessage: Message = { + role: 'ai', + content: '您好!我是物业客服,有什么可以帮助您的吗?', + quickQuestions: quickQuestionsData.value, + created_at: new Date().toISOString() } - }, 100) + // 等待历史记录加载完成后插入到最前方 + nextTick(() => { + messages.value.unshift(welcomeMessage) + console.log('[Customer] 每次进入页面都在最前方插入新开场白消息') + scrollToBottom() + }) + } if(op?.message){ handleQuickAction(op as QuickAction)