Compare commits
3 Commits
5e21938d06
...
33e04802dd
| Author | SHA1 | Date | |
|---|---|---|---|
| 33e04802dd | |||
| f90625c125 | |||
| e565e967fc |
@@ -50,7 +50,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tianmu": {
|
"tianmu": {
|
||||||
"clientId": "4",
|
"clientId": "9",
|
||||||
"appId": "wx0be424e1d22065a9",
|
"appId": "wx0be424e1d22065a9",
|
||||||
"name": "沐沐",
|
"name": "沐沐",
|
||||||
"placeholder": "快告诉沐沐您在想什么~",
|
"placeholder": "快告诉沐沐您在想什么~",
|
||||||
|
|||||||
@@ -19,8 +19,8 @@
|
|||||||
<view
|
<view
|
||||||
class="bg-F5F7FA border-box flex flex-items-center p-12 rounded-10 font-size-14 color-171717 mb-12"
|
class="bg-F5F7FA border-box flex flex-items-center p-12 rounded-10 font-size-14 color-171717 mb-12"
|
||||||
>
|
>
|
||||||
<text class="font-500 line-height-22 mr-20">房间号</text>
|
<text class="font-500 line-height-22 mr-20">所在位置</text>
|
||||||
<input placeholder="请填写房间号" v-model="roomId" />
|
<input placeholder="请填写所在位置" v-model="roomId" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
<view v-else class="border-box card-content flex flex-items-center p-12">
|
<view v-else class="border-box card-content flex flex-items-center p-12">
|
||||||
<view class="border-box left flex-full pr-20">
|
<view class="border-box left flex-full pr-20">
|
||||||
<view class="font-size-12 color-525866 line-height-20 mb-4"
|
<view class="font-size-12 color-525866 line-height-20 mb-4"
|
||||||
>房间号:{{ roomId }}</view
|
>所在位置:{{ roomId }}</view
|
||||||
>
|
>
|
||||||
<view class="font-size-12 color-525866 line-height-20 mb-4"
|
<view class="font-size-12 color-525866 line-height-20 mb-4"
|
||||||
>联系方式: {{ contactPhone }}</view
|
>联系方式: {{ contactPhone }}</view
|
||||||
@@ -210,7 +210,7 @@ const handleCall = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!roomId.value.trim()) {
|
if (!roomId.value.trim()) {
|
||||||
uni.showToast({ title: "请填写房间号", icon: "none" });
|
uni.showToast({ title: "请填写所在位置", icon: "none" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,20 @@ export const MessageRole = {
|
|||||||
OTHER: "OTHER",
|
OTHER: "OTHER",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// 消息类型 0-对话 1-指令 2-中断停止 3-心跳检测 4-通知
|
||||||
|
export const MessageType = {
|
||||||
|
// 对话消息
|
||||||
|
dialog: 0,
|
||||||
|
// 指令消息
|
||||||
|
command: 1,
|
||||||
|
// 中断停止
|
||||||
|
stop: 2,
|
||||||
|
// 心跳检测
|
||||||
|
heartbeat: 3,
|
||||||
|
// 通知消息
|
||||||
|
notice: 4,
|
||||||
|
};
|
||||||
|
|
||||||
/// 组件的名称
|
/// 组件的名称
|
||||||
export const CompName = {
|
export const CompName = {
|
||||||
// 快速预定卡片
|
// 快速预定卡片
|
||||||
@@ -28,11 +42,13 @@ export const CompName = {
|
|||||||
// 回答卡片
|
// 回答卡片
|
||||||
longTextCard: "longTextCard",
|
longTextCard: "longTextCard",
|
||||||
// 生成合成图片
|
// 生成合成图片
|
||||||
generatorPhotoCard: "generatorPhotoCard",
|
aigcPhotoGeneratorCard: "aigcPhotoGeneratorCard",
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 发送的指令类型
|
/// 发送的指令类型
|
||||||
export const Command = {
|
export const Command = {
|
||||||
|
// 通知消息
|
||||||
|
welcome: "Command.welcome",
|
||||||
// 快速预定
|
// 快速预定
|
||||||
quickBooking: "Command.quickBooking",
|
quickBooking: "Command.quickBooking",
|
||||||
// 探索发现
|
// 探索发现
|
||||||
@@ -47,4 +63,6 @@ export const Command = {
|
|||||||
myWorkOrder: "Command.myWorkOrder",
|
myWorkOrder: "Command.myWorkOrder",
|
||||||
// 反馈意见
|
// 反馈意见
|
||||||
feedbackCard: "Command.feedbackCard",
|
feedbackCard: "Command.feedbackCard",
|
||||||
|
// 生成合成图片
|
||||||
|
aigcPhotoGenerator: "Command.aigcPhotoGenerator",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<view class="border-box card-content flex flex-items-center pb-12">
|
<view class="border-box card-content flex flex-items-center pb-12">
|
||||||
<view class="border-box left flex-full pr-20">
|
<view class="border-box left flex-full pr-20">
|
||||||
<view class="font-size-12 color-525866 line-height-20 mb-4"
|
<view class="font-size-12 color-525866 line-height-20 mb-4"
|
||||||
>房间号:{{ orderData.roomNo }}</view
|
>所在位置:{{ orderData.roomNo }}</view
|
||||||
>
|
>
|
||||||
<view class="font-size-12 color-525866 line-height-20 mb-4"
|
<view class="font-size-12 color-525866 line-height-20 mb-4"
|
||||||
>联系方式: {{ orderData.userPhone }}</view
|
>联系方式: {{ orderData.userPhone }}</view
|
||||||
|
|||||||
@@ -10,8 +10,7 @@
|
|||||||
:scroll-with-animation="true" @scroll="handleScroll" @scrolltolower="handleScrollToLower">
|
:scroll-with-animation="true" @scroll="handleScroll" @scrolltolower="handleScrollToLower">
|
||||||
<!-- welcome栏 -->
|
<!-- welcome栏 -->
|
||||||
<ChatTopWelcome ref="welcomeRef" :mainPageDataModel="mainPageDataModel" />
|
<ChatTopWelcome ref="welcomeRef" :mainPageDataModel="mainPageDataModel" />
|
||||||
|
<NoticeMessage v-if="notitceConent"></NoticeMessage>
|
||||||
<!-- <NoticeMessage></NoticeMessage> -->
|
|
||||||
|
|
||||||
<view class="area-msg-list-content" v-for="item in chatMsgList" :key="item.msgId" :id="item.msgId">
|
<view class="area-msg-list-content" v-for="item in chatMsgList" :key="item.msgId" :id="item.msgId">
|
||||||
<template v-if="item.msgType === MessageRole.AI">
|
<template v-if="item.msgType === MessageRole.AI">
|
||||||
@@ -33,7 +32,7 @@
|
|||||||
item.toolCall && item.toolCall.componentName === CompName.mapCard
|
item.toolCall && item.toolCall.componentName === CompName.mapCard
|
||||||
" />
|
" />
|
||||||
<GeneratorPhotoComponent v-else-if="
|
<GeneratorPhotoComponent v-else-if="
|
||||||
item.toolCall && item.toolCall.componentName === CompName.generateMessageId
|
item.toolCall && item.toolCall.componentName === CompName.aigcPhotoGeneratorCard
|
||||||
" />
|
" />
|
||||||
<Feedback v-else-if="
|
<Feedback v-else-if="
|
||||||
item.toolCall && item.toolCall.componentName === CompName.feedbackCard
|
item.toolCall && item.toolCall.componentName === CompName.feedbackCard
|
||||||
@@ -96,7 +95,7 @@ import {
|
|||||||
NOTICE_EVENT_LOGOUT,
|
NOTICE_EVENT_LOGOUT,
|
||||||
NOTICE_EVENT_LOGIN_SUCCESS,
|
NOTICE_EVENT_LOGIN_SUCCESS,
|
||||||
} from "@/constant/constant";
|
} from "@/constant/constant";
|
||||||
import { MessageRole, CompName } from "@/model/ChatModel";
|
import { MessageRole, MessageType, CompName, Command } from "@/model/ChatModel";
|
||||||
import ChatTopWelcome from "../ChatTopWelcome/index.vue";
|
import ChatTopWelcome from "../ChatTopWelcome/index.vue";
|
||||||
import NoticeMessage from "../NoticeMessage/index.vue";
|
import NoticeMessage from "../NoticeMessage/index.vue";
|
||||||
import ChatTopNavBar from "../ChatTopNavBar/index.vue";
|
import ChatTopNavBar from "../ChatTopNavBar/index.vue";
|
||||||
@@ -136,6 +135,7 @@ const statusBarHeight = ref(20);
|
|||||||
const inputAreaRef = ref(null);
|
const inputAreaRef = ref(null);
|
||||||
const topNavBarRef = ref();
|
const topNavBarRef = ref();
|
||||||
const welcomeRef = ref();
|
const welcomeRef = ref();
|
||||||
|
const notitceConent = ref("");
|
||||||
|
|
||||||
const holdKeyboardTimer = ref(null);
|
const holdKeyboardTimer = ref(null);
|
||||||
/// focus时,点击页面的时候不收起键盘
|
/// focus时,点击页面的时候不收起键盘
|
||||||
@@ -420,6 +420,16 @@ const initWebSocket = async () => {
|
|||||||
console.log("WebSocket连接成功");
|
console.log("WebSocket连接成功");
|
||||||
// 重置会话状态
|
// 重置会话状态
|
||||||
isSessionActive.value = false; // 连接成功时重置会话状态,避免影响新消息发送
|
isSessionActive.value = false; // 连接成功时重置会话状态,避免影响新消息发送
|
||||||
|
|
||||||
|
// 连接成功后发送 welcome 消息 (messageType=4)
|
||||||
|
try {
|
||||||
|
// fire-and-forget, sendWebSocketMessage 会处理重连与队列
|
||||||
|
sendWebSocketMessage(MessageType.notice, Command.welcome, { tryReconnect: true, messageId:IdUtils.generateMessageId() }).catch((e) => {
|
||||||
|
console.warn('发送 Command.welcome 消息失败:', e);
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('发送 Command.welcome 消息时异常:', e);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 连接断开回调
|
// 连接断开回调
|
||||||
@@ -476,6 +486,15 @@ const handleWebSocketMessage = (data) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Welcome 消息 (messageType=4):用于更新顶部欢迎栏内容
|
||||||
|
if (data.messageType && data.messageType === 'broadcast') {
|
||||||
|
console.log("收到 welcome 类型消息:", data);
|
||||||
|
if (data.content) {
|
||||||
|
notitceConent.value = data.content;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let aiMsgIndex = -1;
|
let aiMsgIndex = -1;
|
||||||
// Prefer matching by replyMessageId if provided
|
// Prefer matching by replyMessageId if provided
|
||||||
if (data.replyMessageId) {
|
if (data.replyMessageId) {
|
||||||
@@ -733,7 +752,7 @@ const sendWebSocketMessage = async (messageType, messageContent, options = {}) =
|
|||||||
const args = {
|
const args = {
|
||||||
conversationId: conversationId.value,
|
conversationId: conversationId.value,
|
||||||
agentId: agentId.value,
|
agentId: agentId.value,
|
||||||
messageType: String(messageType), // 消息类型 0-对话 1-指令 2-中断停止 3-心跳检测
|
messageType: String(messageType), // 消息类型 0-对话 1-指令 2-中断停止 3-心跳检测 4-消息
|
||||||
messageContent: messageContent,
|
messageContent: messageContent,
|
||||||
messageId: options.messageId || currentSessionMessageId,
|
messageId: options.messageId || currentSessionMessageId,
|
||||||
};
|
};
|
||||||
@@ -840,7 +859,7 @@ const sendChat = async (message, isInstruct = false) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const messageType = isInstruct ? 1 : 0;
|
const messageType = isInstruct ? MessageType.command : MessageType.dialog;
|
||||||
const messageContent = isInstruct ? messageCommonType : message;
|
const messageContent = isInstruct ? messageCommonType : message;
|
||||||
// 生成 messageId 并保存到当前会话变量(stopRequest 可能使用)
|
// 生成 messageId 并保存到当前会话变量(stopRequest 可能使用)
|
||||||
currentSessionMessageId = IdUtils.generateMessageId();
|
currentSessionMessageId = IdUtils.generateMessageId();
|
||||||
@@ -903,7 +922,7 @@ const stopRequest = async () => {
|
|||||||
|
|
||||||
// 发送中断消息给服务器 (messageType=2),带上当前 messageId
|
// 发送中断消息给服务器 (messageType=2),带上当前 messageId
|
||||||
try {
|
try {
|
||||||
await sendWebSocketMessage(2, "stop_request", { messageId: currentSessionMessageId, silent: true });
|
await sendWebSocketMessage(MessageType.stop, "stop_request", { messageId: currentSessionMessageId, silent: true });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("stopRequest send failed:", e);
|
console.warn("stopRequest send failed:", e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user