From b4fea7b34fcaa673a7e0a66c2ed4e75273f8d3c5 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 1 Apr 2026 14:35:19 +0800 Subject: [PATCH] feat: show welcome message every time user enters chat page --- src/pages/ai/chat.vue | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/src/pages/ai/chat.vue b/src/pages/ai/chat.vue index 128187e..b22e1f5 100644 --- a/src/pages/ai/chat.vue +++ b/src/pages/ai/chat.vue @@ -877,21 +877,8 @@ const processTypingIndicator = (typingData: any) => { // 检查是否应该展示开场白 const checkShouldShowQuickQuestions = (isLastPage: boolean = false) => { - if (quickQuestionsData.value.length === 0) { - return false - } - - // 第一次进入会话聊天(没有历史记录) - if (messages.value.length === 0) { - return true - } - - // 当分页加载到最后一页时,展示开场白 - if (isLastPage && messages.value.length > 0) { - return true - } - - return false + // 只要有开场白数据,就展示开场白 + return quickQuestionsData.value.length > 0 } // 找到第一条AI消息并添加开场白 @@ -905,16 +892,6 @@ const addQuickQuestionsToFirstAIMessage = (isLastPage: boolean = false) => { return } - // 检查是否已经存在开场白消息 - const existingWelcomeMessage = messages.value.find( - msg => msg.role === 'ai' && msg.quickQuestions && msg.quickQuestions.length > 0 - ) - - if (existingWelcomeMessage) { - console.log('[Customer] 开场白已存在,跳过添加') - return - } - // 创建开场白消息 const welcomeMessage: Message = { role: 'ai', @@ -930,10 +907,10 @@ const addQuickQuestionsToFirstAIMessage = (isLastPage: boolean = false) => { messages.value = [welcomeMessage] console.log('[Customer] 设置开场白为第一条消息') } - // 如果是最后一页,在第一条消息前面插入开场白 - else if (isLastPage) { + // 如果有历史记录,在第一条消息前面插入开场白 + else { messages.value.unshift(welcomeMessage) - console.log('[Customer] 已加载到最后一页,在第一条消息前面插入开场白') + console.log('[Customer] 在第一条消息前面插入开场白') } }