mirror of
http://112.124.100.131/ebiz-ai/ebiz-base-ai.git
synced 2025-12-07 01:46:48 +08:00
feat(AI): 实现产品对比功能
- 在聊天组件中添加产品对比参数 - 在消息组件中支持 HTML 渲染 - 在 AI 入口组件中处理产品对比结果 - 在首页组件中清除产品对比结果 - 在对比表格组件中保存对比结果到 sessionStorage
This commit is contained in:
@@ -212,10 +212,10 @@ export default {
|
||||
think: '',
|
||||
isLike: false,
|
||||
isDisLike: false,
|
||||
}),
|
||||
})
|
||||
)
|
||||
this.messages.push(this.currentMessage)
|
||||
const params = {
|
||||
let params = {
|
||||
query: this.newMessage,
|
||||
isDeep: this.isDeep ? 1 : 0,
|
||||
isOnline: this.isSearching ? 1 : 0,
|
||||
@@ -223,6 +223,11 @@ export default {
|
||||
conversationId: this.conversationId,
|
||||
productName: this.productName,
|
||||
}
|
||||
|
||||
if (this.$route.query.compareId) {
|
||||
params.compareResult = JSON.parse(sessionStorage.getItem('results'))
|
||||
}
|
||||
|
||||
fetch(chat(), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -307,6 +312,8 @@ export default {
|
||||
sendMessage() {
|
||||
if (this.messageStatus === 'send') return
|
||||
if (this.newMessage.trim() === '') return
|
||||
// 防止xss
|
||||
this.newMessage = this.newMessage.replace(/<[^>]+>/g, '')
|
||||
this.messages.push({ type: 'user', text: this.newMessage })
|
||||
this.$emit('update:messageStatus', 'send')
|
||||
// this.messageStatus = 'send'
|
||||
@@ -315,10 +322,10 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.newMessage.includes('产品对比')) {
|
||||
// this.hasTreasureBox()
|
||||
return
|
||||
}
|
||||
// if (this.newMessage.includes('产品对比')) {
|
||||
// // this.hasTreasureBox()
|
||||
// return
|
||||
// }
|
||||
|
||||
// this.autoScrollEnabled = true
|
||||
this.$emit('update:autoScrollEnabled', true)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div v-for="(message, index) in messagesList" :key="index" class="message-item">
|
||||
<!--用户消息-->
|
||||
<div v-if="message.type === 'user'" class="user-message mb10">
|
||||
<p>{{ message.text }}</p>
|
||||
<p v-html="message.text"></p>
|
||||
</div>
|
||||
<!--机器人消息-->
|
||||
<div v-else-if="message.type === 'bot'" class="bot-message mb10">
|
||||
|
||||
@@ -82,15 +82,25 @@ export default {
|
||||
}
|
||||
|
||||
if (!compareId) {
|
||||
sessionStorage.removeItem('results')
|
||||
this.messages.push({
|
||||
type: 'bot',
|
||||
text: '欢迎使用AI智能助手,请输入问题开始对话或输入关键词 "xxx工具箱","产品对比"。',
|
||||
})
|
||||
} else {
|
||||
// 可以调用接口展示 名字 或者存在session里
|
||||
|
||||
let sesstions = JSON.parse(sessionStorage.getItem('results')).productResults
|
||||
console.log(sesstions)
|
||||
let text = sesstions.map((item) => {
|
||||
return item.productName + '<br/>'
|
||||
})
|
||||
console.log(text)
|
||||
let other = '对比产品 <br/>' + text.join('')
|
||||
|
||||
this.messages.push({
|
||||
type: 'user',
|
||||
text: compareId,
|
||||
text: other,
|
||||
})
|
||||
}
|
||||
this.getHotProducts()
|
||||
|
||||
@@ -34,6 +34,9 @@ export default {
|
||||
[Swipe.name]: Swipe,
|
||||
[SwipeItem.name]: SwipeItem,
|
||||
},
|
||||
created() {
|
||||
sessionStorage.removeItem('results')
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
navigationItems: [
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</el-table>
|
||||
<div class="flex align-items-c justify-content-b">
|
||||
<van-button class="fs14 fw600" style="background: #fff; color: #000; flex: 1; border-radius: 8px" @click="emits">返回</van-button>
|
||||
<!-- <van-button class="fs14 fw600" style="color: #fff; background: #1989fa; flex: 1; border-radius: 8px" @click="question">提问</van-button>-->
|
||||
<van-button class="fs14 fw600" style="color: #fff; background: #1989fa; flex: 1; border-radius: 8px" @click="question">提问</van-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -83,7 +83,7 @@ export default {
|
||||
obj[item.productId] = item.knowledge[keys]
|
||||
}
|
||||
})
|
||||
console.log(this.tableData)
|
||||
sessionStorage.setItem('results', JSON.stringify(res.content))
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user