From 00a3929fe7003715bb4d48f72a3ac2a0550f5588 Mon Sep 17 00:00:00 2001
From: liudong <liudong>
Date: 星期二, 20 八月 2024 09:56:24 +0800
Subject: [PATCH] 历史记录请求加载
---
src/views/sessionManager/index.vue | 121 +++++++++++++++++++++++++++++++++------
1 files changed, 101 insertions(+), 20 deletions(-)
diff --git a/src/views/sessionManager/index.vue b/src/views/sessionManager/index.vue
index a0e78f2..a0a759e 100644
--- a/src/views/sessionManager/index.vue
+++ b/src/views/sessionManager/index.vue
@@ -31,7 +31,17 @@
<icon-down style="margin-left: 4px" />
</a-button>
<template #content>
- <setName :activeSessionId="activeSessionId" @queryNewSessionDetail="queryNewSessionDetail"></setName>
+ <a-button
+ type="text"
+ class="button"
+ style="color: #2a2a2b"
+ @click="handleClick()"
+ >
+ <template #icon>
+ <icon-edit />
+ </template>
+ 淇敼鍚嶇О
+ </a-button>
<!-- <a-divider style="margin: 10px 0" />-->
</template>
</a-popover>
@@ -190,7 +200,7 @@
<!-- </template>-->
<!-- </a-upload>-->
<!-- </div>-->
- <span style="position: absolute;top:96px;left: 10px;z-index: 10000;cursor: pointer">
+ <span style="position: absolute;top:94px;left: 20px;z-index: 999;cursor: pointer">
<icon-attachment size="28" @click="selectFile" style="color: #0960bd;" />
<input
ref="fileInput"
@@ -250,7 +260,19 @@
</div>
</a-col>
</a-row>
-
+ <a-modal v-model:visible="visible" title="淇敼鍚嶇О" @before-open="handleOpened" @cancel="handleCancel" :footer="false" title-align="start">
+ <a-form ref="formRef" :rules="rules" :model="chatObj" @submit="handleSubmit" >
+ <a-form-item field="name" label="鍚嶇О">
+ <a-input v-model="agentTitle" placeholder="璇疯緭鍏ュ悕绉�"/>
+ </a-form-item>
+ <a-form-item>
+ <div style="width: 100%;text-align: right">
+ <a-button @click="visible = false">鍙栨秷</a-button>
+ <a-button style="margin-left: 10px" type="primary" html-type="submit">纭畾</a-button>
+ </div>
+ </a-form-item>
+ </a-form>
+ </a-modal>
</div>
</template>
<script setup lang="ts">
@@ -322,6 +344,54 @@
const files = ref([]);
const file = ref('');
const fileInput = ref(null);
+const chatDataMeg = reactive({})
+const visible = ref(false);
+
+
+
+const rules = {
+ name: [
+ {
+ required: true,
+ message:'鍚嶇О涓嶅厑璁镐负绌�',
+ },
+ ],
+}
+
+const handleSubmit = async({values, errors}) => {
+ if(errors) return;
+ // chatObj.name = agentTitle.value;
+ // chatObj.conversation_id = chatObj.id;
+ let chatData = {
+ id:chatObj.id,
+ conversation_id:chatObj.id,
+ name: agentTitle.value
+ }
+ const { code, data } = await addSessionApi(chatData);
+ if (data) {
+ Message.success("淇敼鎴愬姛");
+ handleCancel()
+ queryNewSessionDetail(activeSessionId.value);
+ }
+}
+
+const handleClick = () => {
+ visible.value = true;
+};
+const handleCancel = () => {
+ visible.value = false;
+}
+
+const handleOpened =(el) => {
+ // Object.assign(form,{
+ // name: '',// 鐢ㄦ埛鍚�
+ // });
+ // formRef.value.resetFields();
+}
+
+
+
+
const selectFile = () => {
fileInput.value.click();
@@ -571,11 +641,12 @@
if (done) {
console.info("done");
displayedText.value = "";
- // if(!isStopChat.value){
- // queryNewSessionDetail(activeSessionId.value);
- // }
- queryNewSessionDetail(activeSessionId.value);
- EventBus.emit("queryAppUsageList");
+ if(isStopChat.value){
+ setChatDataMeg(chatDataMeg);
+ }else{
+ queryNewSessionDetail(activeSessionId.value);
+ EventBus.emit("queryAppUsageList");
+ }
break;
}
}
@@ -585,12 +656,16 @@
loading.value = false;
};
+
+
const stopChat = async () => {
// const { code, data } = await stopChatApi(activeSessionId.value);
// if (code === 200) {
// Message.success("宸插仠姝�");
// queryNewSessionDetail(activeSessionId.value);
// }
+ loading.value = false;
+ chatDis.value = false;
isStopChat.value = true;
console.log("stopChat");
console.log(displayedText.value, "displayedText");
@@ -605,22 +680,28 @@
role: "assistant"
}];
sessionDetailList.value = sessionDetailList.value.splice(0, sessionDetailList.value.length - 2).concat(lastArr);
+
console.log(sessionDetailList.value, "sessionDetailList2");
console.log(chatObj, "chatObj瀵硅薄");
chatObj.message = chatObj.message.concat(lastArr);
- // clearTimeout(timer!);
- // timer = null;
- // const { code, data } = await addSessionApi(chatObj);
- // if (data) {
- // //鍋滄瀹氭椂鍣�
- // clearTimeout(timer!);
- // timer = null;
- // displayedText.value = "";
- // queryNewSessionDetail(activeSessionId.value);
- // }
+ Object.assign(chatDataMeg,{
+ id:chatObj.id,
+ conversation_id:chatObj.id,
+ message: sessionDetailList.value
+ });
+
};
-
+const setChatDataMeg = async(chatData) => {
+ const { code, data } = await addSessionApi(chatData);
+ if (data) {
+ //鍋滄瀹氭椂鍣�
+ clearTimeout(timer!);
+ timer = null;
+ // displayedText.value = "";
+ queryNewSessionDetail(activeSessionId.value);
+ }
+};
@@ -913,7 +994,7 @@
.btn-send {
position: absolute !important;
- right: 10px;
+ right: 4px;
top: 90px;
z-index: 10;
}
--
Gitblit v1.8.0