|
@@ -29,7 +29,7 @@
|
|
|
<div class="center-header">
|
|
|
<div style="margin-left: 30px"></div>
|
|
|
<div>小新老师</div>
|
|
|
- <div class="header-exit-btn">退出</div>
|
|
|
+ <div class="header-exit-btn" @click="exitChatPage">退出</div>
|
|
|
</div>
|
|
|
<div v-loading="loadingHistoryRecord" class="chat-container">
|
|
|
<div class="message-list" ref="chatContainerRef">
|
|
@@ -122,6 +122,7 @@
|
|
|
import {Base64} from 'js-base64'
|
|
|
import * as AudioPlayer from "/public/ai/tts/dist/index.umd.js"
|
|
|
import {aiChatRecordList, aiChatRecordAdd} from '@/api/xjc-integratedmachine/common/aiChat.js'
|
|
|
+ import {getCareerChatRecordList, addCareerChatRecord} from "@/api/xjc-integratedmachine/environment/ai-career.js";
|
|
|
import msgFold from '@/assets/images/environment/ai-career-msg-fold.png'
|
|
|
import msgExpand from '@/assets/images/environment/ai-career-msg-expand.png'
|
|
|
import mutePlayer from '@/assets/images/environment/ai-career-mute-player.png'
|
|
@@ -131,7 +132,6 @@
|
|
|
|
|
|
const param = route.query
|
|
|
|
|
|
-
|
|
|
const loadingHistoryRecord = ref(false)
|
|
|
// 聊天记录
|
|
|
let chatRecordList = ref([])
|
|
@@ -154,14 +154,18 @@
|
|
|
// 播放按钮状态
|
|
|
let playActiveIndex = ref(0)
|
|
|
let playButtonFlag = ref(false)
|
|
|
+
|
|
|
+ const HELLO_MSG = '你是谁?'
|
|
|
// 查看所有聊天记录
|
|
|
function list() {
|
|
|
loadingHistoryRecord.value = true
|
|
|
let queryForm = {
|
|
|
pageNum: 1,
|
|
|
- pageSize: 10000
|
|
|
+ pageSize: 10000,
|
|
|
+ occupationId: param.occupationId,
|
|
|
}
|
|
|
- aiChatRecordList(queryForm).then(resp =>{
|
|
|
+ console.log("=======>"+JSON.stringify(queryForm))
|
|
|
+ getCareerChatRecordList(queryForm).then(resp =>{
|
|
|
chatRecordList.value = resp.rows;
|
|
|
loadingHistoryRecord.value = false
|
|
|
setTimeout(()=>{
|
|
@@ -175,10 +179,12 @@
|
|
|
|
|
|
function addRecord(content) {
|
|
|
let queryForm = {
|
|
|
- content: content,
|
|
|
- isUser: 0
|
|
|
+ 'occupationName': param.occupationName,
|
|
|
+ 'occupationId': param.occupationId,
|
|
|
+ 'content': content,
|
|
|
+ 'isUser': 0
|
|
|
}
|
|
|
- aiChatRecordAdd(queryForm).then(resp =>{
|
|
|
+ addCareerChatRecord(queryForm).then(resp =>{
|
|
|
console.log(resp)
|
|
|
|
|
|
})
|
|
@@ -192,7 +198,7 @@
|
|
|
}
|
|
|
chatRecordList.value.push(botMsg);*/
|
|
|
|
|
|
- sendRequest('你是谁?')
|
|
|
+ sendRequest(HELLO_MSG)
|
|
|
}
|
|
|
|
|
|
const sendMessage = () => {
|
|
@@ -203,14 +209,17 @@
|
|
|
}
|
|
|
|
|
|
const sendRequest = async(message) => {
|
|
|
- // 用户信息
|
|
|
- const userMsg = {
|
|
|
- isUser: true,
|
|
|
- content: message,
|
|
|
- isTyping: false
|
|
|
+ if(message !== HELLO_MSG){
|
|
|
+ // 用户信息
|
|
|
+ const userMsg = {
|
|
|
+ isUser: true,
|
|
|
+ content: message,
|
|
|
+ isTyping: false
|
|
|
+ }
|
|
|
+ // 消息加入聊天记录
|
|
|
+ chatRecordList.value.push(userMsg)
|
|
|
}
|
|
|
- // 消息加入聊天记录
|
|
|
- chatRecordList.value.push(userMsg)
|
|
|
+
|
|
|
const botMsg = {
|
|
|
isUser: false,
|
|
|
content: '', // 增量填充
|
|
@@ -229,10 +238,12 @@
|
|
|
|
|
|
// 请求体
|
|
|
let form = {
|
|
|
+ 'occupationName': param.occupationName,
|
|
|
+ 'occupationId': param.occupationId,
|
|
|
"content": message? message: "你是谁?"
|
|
|
}
|
|
|
// 发送fetch请求
|
|
|
- const response = await fetch('/dev-api/ai/chat/record/stream', {
|
|
|
+ const response = await fetch('/dev-api/ai/career/chat/record/stream', {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
|
'Content-Type': 'application/json',
|
|
@@ -732,6 +743,10 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function exitChatPage(){
|
|
|
+ router.go(-1)
|
|
|
+ }
|
|
|
+
|
|
|
onMounted(()=>{
|
|
|
nextTick(()=>{
|
|
|
initSpeechRecognition();
|
|
@@ -839,6 +854,7 @@
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
margin-right: 30px;
|
|
|
+ cursor: pointer;
|
|
|
}
|
|
|
}
|
|
|
.chat-container {
|