实现ai对话(电脑同步)
This commit is contained in:
@@ -146,40 +146,6 @@ export const useSocketStore = defineStore('socket', () => {
|
||||
return timer
|
||||
}
|
||||
|
||||
// function handleMessage(messageData) {
|
||||
// addLog('receive', `收到: ${JSON.stringify(messageData)}`)
|
||||
|
||||
// const {
|
||||
// ws_event,
|
||||
// queue,
|
||||
// data
|
||||
// } = messageData || {}
|
||||
// if (data?.task_call_id) {
|
||||
// taskCallId.value = data.task_call_id
|
||||
// uni.setStorageSync('taskCallId', data.task_call_id)
|
||||
// }
|
||||
|
||||
|
||||
// switch (ws_event) {
|
||||
// case 'connect':
|
||||
// addLog('success', '连接成功')
|
||||
|
||||
// handleBindConversation(messageData)
|
||||
// break
|
||||
|
||||
// case 'disconnect':
|
||||
// addLog('warn', '收到服务端断开指令')
|
||||
// disconnect()
|
||||
// break
|
||||
|
||||
// case 'message':
|
||||
// handleBusinessMessage(messageData)
|
||||
// break
|
||||
|
||||
// default:
|
||||
// addLog('info', `未知事件类型: ${ws_event}`)
|
||||
// }
|
||||
// }
|
||||
function handleMessage(messageData) {
|
||||
addLog('receive', `收到: ${JSON.stringify(messageData)}`)
|
||||
|
||||
@@ -240,44 +206,6 @@ export const useSocketStore = defineStore('socket', () => {
|
||||
}
|
||||
}
|
||||
|
||||
// function handleBusinessMessage(messageData) {
|
||||
// const {
|
||||
// ws_event,
|
||||
// queue,
|
||||
// data
|
||||
// } = messageData
|
||||
// const messageContent = data?.content || data?.chunk || ''
|
||||
|
||||
// // 调用工具
|
||||
// if (data?.cmd === 'list_tools' || data?.cmd === 'catalog') {
|
||||
// socketManager.send({
|
||||
// "ws_event": "message",
|
||||
// "data": {
|
||||
// "task_call_id": taskCallId.value,
|
||||
// "result": {
|
||||
// "tools": []
|
||||
// }
|
||||
// },
|
||||
// })
|
||||
// addLog('info', `调用工具: ${data?.module}`)
|
||||
// return
|
||||
// }
|
||||
|
||||
// // 消息事件:渲染队列的业务消息
|
||||
// if (ws_event === 'message' && queue === 'render') {
|
||||
// messageString.value += messageContent
|
||||
// // 有任务ID时,自动回复消息确认包
|
||||
// if (data.task_call_id) {
|
||||
|
||||
// socketManager.send({
|
||||
// "ws_event": "message",
|
||||
// "data": {
|
||||
// "task_call_id": taskCallId.value
|
||||
// }
|
||||
// }).catch(err => console.error('发送确认失败:', err))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
function handleBusinessMessage(data) {
|
||||
// 处理 data 为字符串 "exit" 的情况
|
||||
if (data === "exit") {
|
||||
@@ -288,6 +216,8 @@ export const useSocketStore = defineStore('socket', () => {
|
||||
|
||||
// 处理 data 为对象的情况
|
||||
if (!data || typeof data !== 'object') return
|
||||
|
||||
|
||||
|
||||
const {
|
||||
role,
|
||||
|
||||
Reference in New Issue
Block a user