Commit a7f37904 by 前端

优化推流

1 parent a4f652fa
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn * @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-02-25 10:30:47 * @Date: 2024-02-25 10:30:47
* @LastEditors: 前端 qianduan01@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-03-06 10:02:16 * @LastEditTime: 2024-03-06 16:14:05
* @FilePath: \dj-scrm-wx-work-attachment-psd\src\mixins\socket.js * @FilePath: \dj-scrm-wx-work-attachment-psd\src\mixins\socket.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -11,7 +11,7 @@ import { ROLE_LIST, AI_TYPE } from '@/utils/constants' ...@@ -11,7 +11,7 @@ import { ROLE_LIST, AI_TYPE } from '@/utils/constants'
export default { export default {
data() { data() {
return { return {
path: window.$fetchConfig.baseURL, path: window.$fetchConfig.baseURL + (Math.random() + '').slice(2),
isShow: true, isShow: true,
isSend: true, isSend: true,
timer_chat: null, timer_chat: null,
...@@ -149,6 +149,7 @@ export default { ...@@ -149,6 +149,7 @@ export default {
this.issue = '' this.issue = ''
}, },
close() { close() {
console.log('关闭')
this.socket.close() // 关闭 websocket this.socket.close() // 关闭 websocket
}, },
toBottom() { toBottom() {
......
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-02-26 14:10:00
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-03-06 15:46:16
* @FilePath: \salesgpt-project\src\store\index.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import getters from './getters' import getters from './getters'
import app from './modules/app' import app from './modules/app'
// import socket from './modules/socket'
// import createPersistedState from "vuex-persistedstate" // import createPersistedState from "vuex-persistedstate"
Vue.use(Vuex) Vue.use(Vuex)
const store = new Vuex.Store({ const store = new Vuex.Store({
modules: { modules: {
app app,
// socket
}, },
getters getters
// plugins: [createPersistedState({ // plugins: [createPersistedState({
......
const state = {
path: window.$fetchConfig.baseURL,
socket: ''
}
const mutations = {}
const actions = {
connect({ state }) {
state.socket = new WebSocket(this.path)
}
}
export default {
state,
mutations,
actions
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn * @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-02-23 09:47:18 * @Date: 2024-02-23 09:47:18
* @LastEditors: 前端 qianduan01@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-03-06 10:00:11 * @LastEditTime: 2024-03-06 17:16:14
* @FilePath: \dj-scrm-wx-work-attachment-psd\src\views\ai\index.vue * @FilePath: \dj-scrm-wx-work-attachment-psd\src\views\ai\index.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
--> -->
...@@ -53,6 +53,7 @@ export default { ...@@ -53,6 +53,7 @@ export default {
return { return {
isInput: false, isInput: false,
timer: null, timer: null,
isStart: true,
identityValue: '', identityValue: '',
messageList: [], messageList: [],
roleIndex: -1, roleIndex: -1,
...@@ -81,19 +82,19 @@ export default { ...@@ -81,19 +82,19 @@ export default {
}, },
summarize(msg) { summarize(msg) {
if (this.roleIndex > -1) { if (this.roleIndex > -1) {
this.isStart = false
this.messageList.push(msg) this.messageList.push(msg)
if (!this.timer) if (!this.timer)
this.timer = setInterval(() => { this.timer = setInterval(() => {
let i = this.messageList.shift() let i = this.messageList.shift()
if (i == '<rdfast stop>') { if (i == '<rdfast stop>') {
i = '' i = ''
this.roleIndex++
} }
if (this.messageList.length == 0) { if (this.messageList.length == 0) {
clearInterval(this.timer) clearInterval(this.timer)
this.timer = null this.timer = null
} }
this.$set(this.descList, this.roleIndex, this.descList[this.roleIndex] + i) this.$set(this.descList, this.identityIndex, this.descList[this.identityIndex] + i)
}, 50) }, 50)
return return
} }
...@@ -104,17 +105,22 @@ export default { ...@@ -104,17 +105,22 @@ export default {
this.identityList = matches.length ? matches.map(match => match[1]) : this.roleMsg.replace(/\。/, '').split('、') this.identityList = matches.length ? matches.map(match => match[1]) : this.roleMsg.replace(/\。/, '').split('、')
for (let i = 0; i < this.identityList.length; i++) { for (let i = 0; i < this.identityList.length; i++) {
this.descList.push('') this.descList.push('')
}
this.sendIdentity()
} else {
this.roleMsg += msg
}
},
//根据角色切换生成用车意向
sendIdentity() {
this.isStart = true
this.sendMessage( this.sendMessage(
JSON.stringify({ JSON.stringify({
type: 'roles_generate_desc', type: 'roles_generate_desc',
question: `你是一名购车客户你的身份是${this.identityList[i]},请根据你的身份从${CAR_TYPE}里面选一款车型,并描述你的用车意向,大约100字左右` question: `你是一名购车客户你的身份是${this.identityList[this.identityIndex]},请根据你的身份从${CAR_TYPE}里面选一款车型,并描述你的用车意向,大约60字左右`
// question: `你是一名购车客户你的身份是${this.identityList[i]},请根据你的身份描述你的用车意向,大约100字左右` // question: `你是一名购车客户你的身份是${this.identityList[i]},请根据你的身份描述你的用车意向,大约100字左右`
}) })
) )
}
} else {
this.roleMsg += msg
}
}, },
handleSelectCar(item) { handleSelectCar(item) {
this.show = true this.show = true
...@@ -124,11 +130,14 @@ export default { ...@@ -124,11 +130,14 @@ export default {
this.sceneIndex = item this.sceneIndex = item
}, },
handleSelectIdentity(item) { handleSelectIdentity(item) {
if (this.messageList.length || this.isStart) return
// if(this.roleIndex<=this.identityList.length) { // if(this.roleIndex<=this.identityList.length) {
// return // return
// } // }
this.desc_d = '' this.desc_d = ''
this.identityIndex = item this.identityIndex = item
if (this.descList[this.identityIndex]) return
this.sendIdentity()
}, },
handleSure() { handleSure() {
const index = CAR_TYPE.findIndex(i => this.descList[this.identityIndex].includes(i)) const index = CAR_TYPE.findIndex(i => this.descList[this.identityIndex].includes(i))
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!