mirror of
http://112.124.100.131/ebiz-ai/ebiz-base-ai.git
synced 2025-12-07 01:46:48 +08:00
@@ -18,7 +18,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@better-scroll/core": "^2.5.1",
|
"@better-scroll/core": "^2.5.1",
|
||||||
"@gerhobbelt/markdown-it-container": "^3.0.0-10",
|
|
||||||
"@isaacs/cliui": "^8.0.2",
|
"@isaacs/cliui": "^8.0.2",
|
||||||
"axios": "^0.19.0",
|
"axios": "^0.19.0",
|
||||||
"core-js": "^3.43.0",
|
"core-js": "^3.43.0",
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: "card",
|
|
||||||
props: {
|
|
||||||
content: {
|
|
||||||
type: Object,
|
|
||||||
default: () => ({})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
cardContent() {
|
|
||||||
const markup = this.content.markup.replace(/(\w+)\s?:/gmi, '"$1":')
|
|
||||||
|
|
||||||
try {
|
|
||||||
const content = JSON.parse(markup)
|
|
||||||
return content
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
return {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
console.log(`------`, this.content.markup);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="card">
|
|
||||||
<div><img :src="cardContent.img" alt=""></div>
|
|
||||||
<section>
|
|
||||||
<div>{{ cardContent.title }}</div>
|
|
||||||
<div>
|
|
||||||
<div v-for="tag in cardContent.tags">
|
|
||||||
{{ tag }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="css" scoped></style>
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
import container from "@gerhobbelt/markdown-it-container"
|
|
||||||
import Vue from "vue";
|
|
||||||
import KnowledgeCard from "../card/index.vue"
|
|
||||||
|
|
||||||
export function markdownContainer(markdownIt) {
|
|
||||||
console.log(markdownIt);
|
|
||||||
console.log(container);
|
|
||||||
|
|
||||||
container(markdownIt, "card", {
|
|
||||||
validate: function (params) {
|
|
||||||
console.log(params.trim(), "title line");
|
|
||||||
return "card"
|
|
||||||
// return params.trim().match(/^card\b/);
|
|
||||||
},
|
|
||||||
render: function (tokens, idx) {
|
|
||||||
// console.log(`tokens, idx`, tokens, idx);
|
|
||||||
return tokens[idx].content
|
|
||||||
},
|
|
||||||
content: function (tokens, idx, options, env, self) {
|
|
||||||
|
|
||||||
|
|
||||||
console.log(`args`, tokens, idx, options, env, self);
|
|
||||||
// return [...args]
|
|
||||||
console.log(`tokens[idx]`, tokens[idx]);
|
|
||||||
|
|
||||||
const { markup } = tokens[idx]
|
|
||||||
console.log(`markup`, markup);
|
|
||||||
setTimeout(() => {
|
|
||||||
const dom = document.getElementById("cardTest");
|
|
||||||
// if (dom) return
|
|
||||||
const vm = new Vue({
|
|
||||||
el: "#cardTest",
|
|
||||||
render: h => h(KnowledgeCard, {
|
|
||||||
props: {
|
|
||||||
content: tokens[idx]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
// console.log(`vue instance`, vm);
|
|
||||||
})
|
|
||||||
|
|
||||||
// return tokens[idx]
|
|
||||||
return "<div id='cardTest'></div>"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -84,11 +84,11 @@ export default {
|
|||||||
// 可以调用接口展示 名字 或者存在session里
|
// 可以调用接口展示 名字 或者存在session里
|
||||||
|
|
||||||
let sesstions = JSON.parse(sessionStorage.getItem('results')).productResults
|
let sesstions = JSON.parse(sessionStorage.getItem('results')).productResults
|
||||||
// console.log(sesstions)
|
console.log(sesstions)
|
||||||
let text = sesstions.map((item) => {
|
let text = sesstions.map((item) => {
|
||||||
return item.productName + '<br/>'
|
return item.productName + '<br/>'
|
||||||
})
|
})
|
||||||
// console.log(text)
|
console.log(text)
|
||||||
let other = '对比产品 <br/>' + text.join('')
|
let other = '对比产品 <br/>' + text.join('')
|
||||||
|
|
||||||
this.messages.push({
|
this.messages.push({
|
||||||
@@ -103,7 +103,7 @@ export default {
|
|||||||
this.isThink = e
|
this.isThink = e
|
||||||
},
|
},
|
||||||
getHotProducts(e) {
|
getHotProducts(e) {
|
||||||
// console.log(e)
|
console.log(e)
|
||||||
this.hotList = e
|
this.hotList = e
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,26 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="chat-page">
|
<div class="chat-page">
|
||||||
<van-nav-bar title="产品知识助手" left-text="返回" left-arrow @click-left="$router.history.go(-1)" />
|
<van-nav-bar title="产品知识助手" left-text="返回" left-arrow @click-left="$router.history.go(-1)" />
|
||||||
<sticky :hotList="hotList" :productName="productName" :messagesList.sync="messages"
|
<sticky
|
||||||
:autoScrollEnabled.sync="autoScrollEnabled" @setProductName="setProductName"
|
:hotList="hotList"
|
||||||
:isDisabled="messageStatus === 'send'" :conversationId="conversationId"></sticky>
|
:productName="productName"
|
||||||
|
:messagesList.sync="messages"
|
||||||
|
:autoScrollEnabled.sync="autoScrollEnabled"
|
||||||
|
@setProductName="setProductName"
|
||||||
|
:isDisabled="messageStatus === 'send'"
|
||||||
|
:conversationId="conversationId"
|
||||||
|
></sticky>
|
||||||
|
|
||||||
<main class="chat-main">
|
<main class="chat-main">
|
||||||
<div class="chat-content">
|
<div class="chat-content">
|
||||||
<div class="message-area" ref="messageArea" @scroll="handleScroll">
|
<div class="message-area" ref="messageArea" @scroll="handleScroll">
|
||||||
<messageComponent :messagesList="messages" :is-deep="isDeep" :is-search="isSearching" :think-ok="isThink"
|
<messageComponent
|
||||||
@setProductName="setProductName"></messageComponent>
|
:messagesList="messages"
|
||||||
|
:is-deep="isDeep"
|
||||||
|
:is-search="isSearching"
|
||||||
|
:think-ok="isThink"
|
||||||
|
@setProductName="setProductName"
|
||||||
|
></messageComponent>
|
||||||
<!-- <HotProducts class="mb10" :messagesList.sync="messages" @getHotList="getHotProducts"></HotProducts> -->
|
<!-- <HotProducts class="mb10" :messagesList.sync="messages" @getHotList="getHotProducts"></HotProducts> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -18,10 +29,19 @@
|
|||||||
<van-icon name="upgrade" size="2em" @click="scrollToTop" />
|
<van-icon name="upgrade" size="2em" @click="scrollToTop" />
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<chatMessage :messages.sync="messages" :messageStatus.sync="messageStatus" :is-deep.sync="isDeep"
|
|
||||||
:conversation-id.sync="conversationId" :is-searching.sync="isSearching" :product-name.sync="productName"
|
<chatMessage
|
||||||
:autoScrollEnabled.sync="autoScrollEnabled" @getIsThink="getIsThink" action="chat"
|
:messages.sync="messages"
|
||||||
@initBotMessage="initBotMessage" />
|
:messageStatus.sync="messageStatus"
|
||||||
|
:is-deep.sync="isDeep"
|
||||||
|
:conversation-id.sync="conversationId"
|
||||||
|
:is-searching.sync="isSearching"
|
||||||
|
:product-name.sync="productName"
|
||||||
|
:autoScrollEnabled.sync="autoScrollEnabled"
|
||||||
|
@getIsThink="getIsThink"
|
||||||
|
action="chat"
|
||||||
|
@initBotMessage="initBotMessage"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -70,11 +90,11 @@ export default {
|
|||||||
// 可以调用接口展示 名字 或者存在session里
|
// 可以调用接口展示 名字 或者存在session里
|
||||||
|
|
||||||
let sesstions = JSON.parse(sessionStorage.getItem('results')).productResults
|
let sesstions = JSON.parse(sessionStorage.getItem('results')).productResults
|
||||||
// console.log(sesstions)
|
console.log(sesstions)
|
||||||
let text = sesstions.map(item => {
|
let text = sesstions.map(item => {
|
||||||
return item.productName + '<br/>'
|
return item.productName + '<br/>'
|
||||||
})
|
})
|
||||||
// console.log(text)
|
console.log(text)
|
||||||
let other = '对比产品 <br/>' + text.join('')
|
let other = '对比产品 <br/>' + text.join('')
|
||||||
|
|
||||||
this.messages.push({
|
this.messages.push({
|
||||||
@@ -89,7 +109,7 @@ export default {
|
|||||||
this.isThink = e
|
this.isThink = e
|
||||||
},
|
},
|
||||||
getHotProducts(e) {
|
getHotProducts(e) {
|
||||||
// console.log(e)
|
console.log(e)
|
||||||
this.hotList = e
|
this.hotList = e
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -122,14 +142,7 @@ export default {
|
|||||||
initBotMessage() {
|
initBotMessage() {
|
||||||
this.messages.splice(0, this.messages.length, {
|
this.messages.splice(0, this.messages.length, {
|
||||||
type: 'bot',
|
type: 'bot',
|
||||||
text: `这里是产品知识小助手,请告诉我您想要了解哪个产品?也可以输入以下信息,我帮您进行精准查询:\n\n1.投保规则\n\n2.保障责任\n\n3.增值服务\n\n您可以直接向我提问~ \n\n`
|
text: `这里是产品知识小助手,请告诉我您想要了解哪个产品?也可以输入以下信息,我帮您进行精准查询:\n\n1.投保规则\n\n2.保障责任\n\n3.增值服务\n\n您可以直接向我提问~`
|
||||||
/* ::: card
|
|
||||||
{
|
|
||||||
"img": "/family.png",
|
|
||||||
"title": "标题",
|
|
||||||
"tags": ["标签1", "标签2", "标签3"]
|
|
||||||
}
|
|
||||||
::: */
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user