|
|
@ -1,17 +1,6 @@
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<div class="chat-container">
|
|
|
|
<div class="chat-container">
|
|
|
|
<div class="chat-list" ref="scrollContainer">
|
|
|
|
<div class="chat-list" ref="scrollContainer">
|
|
|
|
<!-- <div>
|
|
|
|
|
|
|
|
<div class="echarts-box" id="barEcharts"></div>
|
|
|
|
|
|
|
|
<div class="echatrs-theme">
|
|
|
|
|
|
|
|
<div class="theme-title">风格切换:</div>
|
|
|
|
|
|
|
|
<div class="theme-list">
|
|
|
|
|
|
|
|
<div class="theme-item" @click="handlerTheme(index)" v-for="(item, index) in echartsTheme" :key="index">
|
|
|
|
|
|
|
|
{{ item }}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div> -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<AiHint></AiHint>
|
|
|
|
<AiHint></AiHint>
|
|
|
|
|
|
|
|
|
|
|
@ -28,28 +17,9 @@
|
|
|
|
<div class="message-text" :id="`box${index}`">
|
|
|
|
<div class="message-text" :id="`box${index}`">
|
|
|
|
<!-- 纯文本 -->
|
|
|
|
<!-- 纯文本 -->
|
|
|
|
<div class="text-ros">
|
|
|
|
<div class="text-ros">
|
|
|
|
<span>{{ item.text }}</span>
|
|
|
|
<span v-show="item.type == 'text'">{{ item.text }}</span>
|
|
|
|
<div v-show="item.add">
|
|
|
|
<AddIssue v-show="item.add"></AddIssue>
|
|
|
|
<n-tooltip placement="bottom" trigger="hover">
|
|
|
|
|
|
|
|
<template #trigger>
|
|
|
|
|
|
|
|
<n-icon size="14" style="cursor: pointer">
|
|
|
|
|
|
|
|
<svg
|
|
|
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
|
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
|
|
|
|
|
|
viewBox="0 0 12 12"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<g fill="none">
|
|
|
|
|
|
|
|
<path
|
|
|
|
|
|
|
|
d="M6.5 1.75a.75.75 0 0 0-1.5 0V5H1.75a.75.75 0 0 0 0 1.5H5v3.25a.75.75 0 0 0 1.5 0V6.5h3.25a.75.75 0 0 0 0-1.5H6.5V1.75z"
|
|
|
|
|
|
|
|
fill="currentColor"
|
|
|
|
|
|
|
|
></path>
|
|
|
|
|
|
|
|
</g>
|
|
|
|
|
|
|
|
</svg>
|
|
|
|
|
|
|
|
</n-icon>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<span> 添加为常用问题 </span>
|
|
|
|
|
|
|
|
</n-tooltip>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- 图表 -->
|
|
|
|
<!-- 图表 -->
|
|
|
|
<section v-if="ehcatrsType.includes(item.type)">
|
|
|
|
<section v-if="ehcatrsType.includes(item.type)">
|
|
|
@ -69,13 +39,14 @@
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<!-- 表格 -->
|
|
|
|
|
|
|
|
<AiTable v-if="!item.type" :obj="item"></AiTable>
|
|
|
|
<!-- 思考 -->
|
|
|
|
<!-- 思考 -->
|
|
|
|
<div v-show="item.from === 'ai' && item.loading" class="ai-loading">
|
|
|
|
<div v-show="item.from === 'ai' && item.loading" class="ai-loading">
|
|
|
|
<span>思考中</span> <n-spin size="small" content-class="spin-class" />
|
|
|
|
<span>思考中</span> <n-spin size="small" content-class="spin-class" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- 免责 -->
|
|
|
|
<!-- 免责 -->
|
|
|
|
<div class="ai-hint" v-show="item.from === 'ai' && (item.text || item.type)">
|
|
|
|
<div class="ai-hint" v-show="item.from === 'ai' && !item.loading">
|
|
|
|
<span>注:本回答由AI生成,内容仅供参考</span>
|
|
|
|
<span>注:本回答由AI生成,内容仅供参考</span>
|
|
|
|
<div class="upload-text" @click="uploadImage(index)">
|
|
|
|
<div class="upload-text" @click="uploadImage(index)">
|
|
|
|
<n-icon size="14">
|
|
|
|
<n-icon size="14">
|
|
|
@ -124,7 +95,7 @@ import { ref, reactive, onMounted, onUnmounted, watch, nextTick } from 'vue'
|
|
|
|
import { getAiMsg } from '@/api/ai.js'
|
|
|
|
import { getAiMsg } from '@/api/ai.js'
|
|
|
|
import moment from 'moment'
|
|
|
|
import moment from 'moment'
|
|
|
|
import { LineChart, BarChart, PieChart } from './class/index'
|
|
|
|
import { LineChart, BarChart, PieChart } from './class/index'
|
|
|
|
import { AiHint } from '../components'
|
|
|
|
import { AiHint, AiTable,AddIssue } from '../components'
|
|
|
|
import userIcon from '@/assets/images/ai/user-icon.png'
|
|
|
|
import userIcon from '@/assets/images/ai/user-icon.png'
|
|
|
|
import aiIcon from '@/assets/images/ai/ai-icon.png'
|
|
|
|
import aiIcon from '@/assets/images/ai/ai-icon.png'
|
|
|
|
import { useMessage } from 'naive-ui'
|
|
|
|
import { useMessage } from 'naive-ui'
|
|
|
@ -133,7 +104,6 @@ import { canvasCut } from '@/utils'
|
|
|
|
import { historyMessageRoomById } from '@/api/path'
|
|
|
|
import { historyMessageRoomById } from '@/api/path'
|
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const route = useRoute()
|
|
|
|
const route = useRoute()
|
|
|
|
const useMessageRoom = useMessageRoomStore()
|
|
|
|
const useMessageRoom = useMessageRoomStore()
|
|
|
|
const messageDialog = useMessage()
|
|
|
|
const messageDialog = useMessage()
|
|
|
@ -170,8 +140,10 @@ const getMessageInfo = async () => {
|
|
|
|
const res = await historyMessageRoomById(id)
|
|
|
|
const res = await historyMessageRoomById(id)
|
|
|
|
if (res.code == 200 && res.data) {
|
|
|
|
if (res.code == 200 && res.data) {
|
|
|
|
res.data.content = JSON.parse(res.data.content)
|
|
|
|
res.data.content = JSON.parse(res.data.content)
|
|
|
|
|
|
|
|
console.log(res.data)
|
|
|
|
useMessageRoom.resetList(res.data)
|
|
|
|
useMessageRoom.resetList(res.data)
|
|
|
|
res.data.content.map((item, index) => {
|
|
|
|
res.data.content.map((item, index) => {
|
|
|
|
|
|
|
|
item.chartInstanceActiveIndex = 0
|
|
|
|
messageList.push(item)
|
|
|
|
messageList.push(item)
|
|
|
|
initEcharts(item, index)
|
|
|
|
initEcharts(item, index)
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -209,9 +181,11 @@ const handleSend = async () => {
|
|
|
|
setMessageItem({
|
|
|
|
setMessageItem({
|
|
|
|
from: 'user',
|
|
|
|
from: 'user',
|
|
|
|
text: keyWord.value,
|
|
|
|
text: keyWord.value,
|
|
|
|
|
|
|
|
type:'text',
|
|
|
|
time: moment().format('YYYY/MM/DD HH:mm:ss'),
|
|
|
|
time: moment().format('YYYY/MM/DD HH:mm:ss'),
|
|
|
|
add: true
|
|
|
|
add: true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
return
|
|
|
|
//先存储AI回答,作为交互提示,接口响应后再做更新
|
|
|
|
//先存储AI回答,作为交互提示,接口响应后再做更新
|
|
|
|
setMessageItem(
|
|
|
|
setMessageItem(
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -221,7 +195,7 @@ const handleSend = async () => {
|
|
|
|
loading: true, //ai思考中
|
|
|
|
loading: true, //ai思考中
|
|
|
|
chartInstanceItem: null,
|
|
|
|
chartInstanceItem: null,
|
|
|
|
chartInstanceActiveIndex: 0,
|
|
|
|
chartInstanceActiveIndex: 0,
|
|
|
|
type: null,
|
|
|
|
type:'text',
|
|
|
|
xData: [],
|
|
|
|
xData: [],
|
|
|
|
yData: []
|
|
|
|
yData: []
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -268,10 +242,11 @@ const handleSend = async () => {
|
|
|
|
xData: res.xData,
|
|
|
|
xData: res.xData,
|
|
|
|
data: res.data
|
|
|
|
data: res.data
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else if (res.type === 'text') {
|
|
|
|
} else {
|
|
|
|
//纯文本
|
|
|
|
//纯文本
|
|
|
|
updataMessageItem({
|
|
|
|
updataMessageItem({
|
|
|
|
from: 'ai',
|
|
|
|
from: 'ai',
|
|
|
|
|
|
|
|
title: res.title,
|
|
|
|
type: res.type,
|
|
|
|
type: res.type,
|
|
|
|
text: res.data,
|
|
|
|
text: res.data,
|
|
|
|
time: moment().format('YYYY/MM/DD HH:mm:ss'),
|
|
|
|
time: moment().format('YYYY/MM/DD HH:mm:ss'),
|
|
|
@ -299,9 +274,8 @@ const initEcharts = (item, index) => {
|
|
|
|
if (item.type === 'pie') {
|
|
|
|
if (item.type === 'pie') {
|
|
|
|
item.chartInstanceItem = new PieChart(`${item.type}${index}`, {
|
|
|
|
item.chartInstanceItem = new PieChart(`${item.type}${index}`, {
|
|
|
|
title: item.title,
|
|
|
|
title: item.title,
|
|
|
|
unit: item.unit,
|
|
|
|
unit: item.unit,
|
|
|
|
xData: item.xData,
|
|
|
|
data: item.data
|
|
|
|
data: item.yData
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else if (item.type === 'bar') {
|
|
|
|
} else if (item.type === 'bar') {
|
|
|
|
item.chartInstanceItem = new BarChart(`${item.type}${index}`, {
|
|
|
|
item.chartInstanceItem = new BarChart(`${item.type}${index}`, {
|
|
|
@ -329,12 +303,7 @@ const setMessageItem = (obj, set = true) => {
|
|
|
|
messageList.push(obj)
|
|
|
|
messageList.push(obj)
|
|
|
|
lastIndex.value = messageList.length - 1
|
|
|
|
lastIndex.value = messageList.length - 1
|
|
|
|
if (set) {
|
|
|
|
if (set) {
|
|
|
|
useMessageRoom.setMessage({
|
|
|
|
useMessageRoom.setMessage(obj)
|
|
|
|
from: obj.from,
|
|
|
|
|
|
|
|
text: obj.text,
|
|
|
|
|
|
|
|
time: obj.time,
|
|
|
|
|
|
|
|
add: true
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -346,19 +315,20 @@ const updataMessageItem = data => {
|
|
|
|
messageList[lastIndex.value] = data
|
|
|
|
messageList[lastIndex.value] = data
|
|
|
|
keyWord.value = ''
|
|
|
|
keyWord.value = ''
|
|
|
|
loading.value = false
|
|
|
|
loading.value = false
|
|
|
|
useMessageRoom.setMessage({
|
|
|
|
useMessageRoom.setMessage(data)
|
|
|
|
from: data.from,
|
|
|
|
// useMessageRoom.setMessage({
|
|
|
|
text: data.text,
|
|
|
|
// from: data.from,
|
|
|
|
type: data.type,
|
|
|
|
// text: data.text,
|
|
|
|
loading: false, //ai思考中
|
|
|
|
// type: data.type,
|
|
|
|
time: data.time,
|
|
|
|
// loading: false, //ai思考中
|
|
|
|
chartInstanceItem: data.chartInstanceItem,
|
|
|
|
// time: data.time,
|
|
|
|
chartInstanceActiveIndex: 0,
|
|
|
|
// chartInstanceItem: data.chartInstanceItem,
|
|
|
|
xData: data.xData,
|
|
|
|
// chartInstanceActiveIndex: 0,
|
|
|
|
yData: data.yData,
|
|
|
|
// xData: data.xData,
|
|
|
|
title: data.title,
|
|
|
|
// yData: data.yData,
|
|
|
|
unit: data.unit
|
|
|
|
// title: data.title,
|
|
|
|
})
|
|
|
|
// unit: data.unit
|
|
|
|
|
|
|
|
// })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -374,12 +344,10 @@ const handlerTheme = (item, index) => {
|
|
|
|
item.chartInstanceActiveIndex = index
|
|
|
|
item.chartInstanceActiveIndex = index
|
|
|
|
item.chartInstanceItem.changeColorStyle(index)
|
|
|
|
item.chartInstanceItem.changeColorStyle(index)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
startWatching()
|
|
|
|
startWatching()
|
|
|
|
console.log('监听')
|
|
|
|
console.log('监听')
|
|
|
|
}, 5000)
|
|
|
|
}, 5000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -407,7 +375,7 @@ const startWatching = () => {
|
|
|
|
scrollContainer.value.scrollTop = scrollContainer.value.scrollHeight
|
|
|
|
scrollContainer.value.scrollTop = scrollContainer.value.scrollHeight
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},{deep:true})
|
|
|
|
isWatching.value = true
|
|
|
|
isWatching.value = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -420,7 +388,7 @@ const pauseWatching = () => {
|
|
|
|
onUnmounted(() => {
|
|
|
|
onUnmounted(() => {
|
|
|
|
//清除
|
|
|
|
//清除
|
|
|
|
messageList.forEach(instance => {
|
|
|
|
messageList.forEach(instance => {
|
|
|
|
if (instance.type) {
|
|
|
|
if (ehcatrsType.includes( instance.type) && instance.type) {
|
|
|
|
instance.chartInstanceItem.dispose()
|
|
|
|
instance.chartInstanceItem.dispose()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|