|
@@ -113,6 +113,12 @@ const leftPanelRef = ref(null);
|
|
|
|
|
|
|
|
// 定义props
|
|
// 定义props
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
|
|
+ //根据需求传输
|
|
|
|
|
+ courseId: { type: Number},
|
|
|
|
|
+ conversationId: { type: String},
|
|
|
|
|
+ preDialogueList: { type: Array, default: () => []},
|
|
|
|
|
+ replySupplement: { type: String, default: ''},
|
|
|
|
|
+
|
|
|
personId: { type: Number},
|
|
personId: { type: Number},
|
|
|
personName: { type: String },
|
|
personName: { type: String },
|
|
|
personImage: { type: String},
|
|
personImage: { type: String},
|
|
@@ -198,6 +204,12 @@ const getConversation = async (id) => {
|
|
|
activeConversation.value = conversation;
|
|
activeConversation.value = conversation;
|
|
|
// activeConversationId.value = personId.value
|
|
// activeConversationId.value = personId.value
|
|
|
activeConversationModelPath.value = personImage.value;
|
|
activeConversationModelPath.value = personImage.value;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 获取对话消息列表【后面补充接口】
|
|
|
|
|
+ // activeMessageList.value = await ChatMessageApi.getChatMessageListByConversationId(
|
|
|
|
|
+ // activeConversationId.value
|
|
|
|
|
+ // )
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 语音输入识别结果处理
|
|
// 语音输入识别结果处理
|
|
@@ -279,7 +291,7 @@ const doSendMessage = async (content) => {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (activeConversationId.value == null) {
|
|
if (activeConversationId.value == null) {
|
|
|
- console.error("还没创建对话,不能发送!");
|
|
|
|
|
|
|
+ console.error("请刷新创建新对话!");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
// 递增消息计数器
|
|
// 递增消息计数器
|
|
@@ -405,6 +417,7 @@ const stopStream = async () => {
|
|
|
if (conversationInAbortController.value) {
|
|
if (conversationInAbortController.value) {
|
|
|
conversationInAbortController.value.abort();
|
|
conversationInAbortController.value.abort();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
// 设置为 false
|
|
// 设置为 false
|
|
|
conversationInProgress.value = false;
|
|
conversationInProgress.value = false;
|
|
|
};
|
|
};
|
|
@@ -443,6 +456,12 @@ const messageList = computed(() => {
|
|
|
content: activeConversation.value.systemMessage,
|
|
content: activeConversation.value.systemMessage,
|
|
|
};
|
|
};
|
|
|
activeMessageList.value.push(systemMessage);
|
|
activeMessageList.value.push(systemMessage);
|
|
|
|
|
+
|
|
|
|
|
+ // 加入预置对话
|
|
|
|
|
+ props.preDialogueList.forEach(item => {
|
|
|
|
|
+ activeMessageList.value.push(item);
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
return [systemMessage];
|
|
return [systemMessage];
|
|
|
}
|
|
}
|
|
|
return [];
|
|
return [];
|
|
@@ -519,6 +538,14 @@ const textRoll = async () => {
|
|
|
// 重新设置任务
|
|
// 重新设置任务
|
|
|
timer = setTimeout(task, textSpeed.value);
|
|
timer = setTimeout(task, textSpeed.value);
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ // 文本完全显示且对话已结束,添加补充信息
|
|
|
|
|
+ if (!conversationInProgress.value && props.replySupplement) {
|
|
|
|
|
+ activeMessageList.value.push({
|
|
|
|
|
+ type: "system",
|
|
|
|
|
+ content: props.replySupplement,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 不是对话中可以结束
|
|
// 不是对话中可以结束
|
|
|
if (!conversationInProgress.value) {
|
|
if (!conversationInProgress.value) {
|
|
|
textRoleRunning.value = false;
|
|
textRoleRunning.value = false;
|
|
@@ -569,15 +596,26 @@ onMounted(async () => {
|
|
|
// 确保selectedImage被设置
|
|
// 确保selectedImage被设置
|
|
|
selectedImage.value = personImage.value;
|
|
selectedImage.value = personImage.value;
|
|
|
|
|
|
|
|
- // 智能问答
|
|
|
|
|
- CreateDialogue({ roleId: personId.value })
|
|
|
|
|
- .then((res) => {
|
|
|
|
|
- console.log("创建会话:", res);
|
|
|
|
|
- activeConversationId.value = res.data;
|
|
|
|
|
- })
|
|
|
|
|
- .catch((error) => {
|
|
|
|
|
- console.error("请求出错:", error);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ //创建对话
|
|
|
|
|
+ if (props.conversationId) {
|
|
|
|
|
+ activeConversationId.value = props.conversationId;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ // 智能问答
|
|
|
|
|
+ CreateDialogue({ roleId: personId.value })
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ console.log("创建会话:", res);
|
|
|
|
|
+ activeConversationId.value = res.data;
|
|
|
|
|
+
|
|
|
|
|
+ //将会话存入会话缓存
|
|
|
|
|
+ if(props.courseId){
|
|
|
|
|
+ localStorage.setItem(localStorage.getItem("token") + "-" + props.courseId, activeConversationId.value)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((error) => {
|
|
|
|
|
+ console.error("请求出错:", error);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
await getConversation(personId.value);
|
|
await getConversation(personId.value);
|
|
|
// 获取列表数据
|
|
// 获取列表数据
|
|
|
// activeMessageListLoading.value = true
|
|
// activeMessageListLoading.value = true
|