浏览代码

fix:增加历史模式

张涛 1 年之前
父节点
当前提交
4899dfab7e
共有 1 个文件被更改,包括 16 次插入4 次删除
  1. 16 4
      src/views/Home.vue

+ 16 - 4
src/views/Home.vue

@@ -190,6 +190,7 @@ export default defineComponent({
         const navId = ref(-1);
         const readonly = ref(false);
         const showDialog = ref(false);
+        const historyMode = ref(false);
         const dialogList = ref([]);
         const selectId = ref("");
         const initDialog = ref(false);
@@ -210,6 +211,8 @@ export default defineComponent({
         const selectNav = async (node) => {
             navId.value = node.id;
             textValue.value = [];
+            // 关闭历史模式
+            historyMode.value = false;
             if (node.index === -1) {
                 swiperNumber.value = 5;
             } else {
@@ -250,6 +253,8 @@ export default defineComponent({
         };
         const selectHistory = async (id) => {
             showDialog.value = true;
+            // 历史记录对话模式,不调用对话ID接口
+            historyMode.value = true;
             selectId.value = id;
             helper.$bus.emit("set-loading", true);
             helper.$bus.emit("stop-writing");
@@ -289,8 +294,11 @@ export default defineComponent({
                     });
                 }
             }
-            const data = await ajax.message.createDialog(selectId.value);
-            dialogId.value = data.chat_id;
+            // 如果不是历史记录对话模式,则创建对话
+            if (!historyMode.value) {
+                const data = await ajax.message.createDialog(selectId.value);
+                dialogId.value = data.chat_id;
+            }
             dialogList.value = [];
             showDialog.value = true;
             initDialog.value = true;
@@ -359,8 +367,12 @@ export default defineComponent({
             agents = await ajax.agent.getAgents();
             agentIds.value = agents.map((data) => data.id);
             helper.$bus.on("open-dialog", async (value) => {
-                const data = await ajax.message.createDialog(selectId.value);
-                dialogId.value = data.chat_id;
+                // 如果不是历史记录对话模式,则创建对话
+                if (!historyMode.value) {
+                    const data = await ajax.message.createDialog(selectId.value);
+                    dialogId.value = data.chat_id;
+                }
+
                 dialogList.value = [];
                 showDialog.value = true;
                 initDialog.value = true;