feat: show welcome message every time user enters chat page
This commit is contained in:
parent
2040e15d56
commit
b4fea7b34f
@ -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] 在第一条消息前面插入开场白')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user