From 514d9ab9443b83c5a475d6e01f64b00e9bed70eb Mon Sep 17 00:00:00 2001 From: zoujing Date: Tue, 2 Sep 2025 20:42:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8A=A0=E8=BD=BD=E4=B8=AD=E5=8A=A8?= =?UTF-8?q?=E7=94=BB=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/chat/ChatCardAI.vue | 8 +++--- pages/chat/ChatMainList.vue | 26 ++----------------- pages/loading/DotLoading.vue | 48 ++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 27 deletions(-) create mode 100644 pages/loading/DotLoading.vue diff --git a/pages/chat/ChatCardAI.vue b/pages/chat/ChatCardAI.vue index 0b1cce1..523ea46 100644 --- a/pages/chat/ChatCardAI.vue +++ b/pages/chat/ChatCardAI.vue @@ -2,13 +2,14 @@ - - + /> + + @@ -20,6 +21,7 @@ import { defineProps, computed, ref, watch } from "vue"; import ChatMarkdown from "./ChatMarkdown.vue"; import loading from "@/pages/loading/loading.vue"; +import DotLoading from "@/pages/loading/DotLoading.vue"; const props = defineProps({ text: { diff --git a/pages/chat/ChatMainList.vue b/pages/chat/ChatMainList.vue index 0e49d0c..8f1e3ef 100644 --- a/pages/chat/ChatMainList.vue +++ b/pages/chat/ChatMainList.vue @@ -203,8 +203,6 @@ let typewriterManager = null; // 当前会话的消息ID,用于保持发送和终止的messageId一致 let currentSessionMessageId = null; -let loadingTimer = null; - // 打开抽屉 const emits = defineEmits(["openDrawer"]); const openDrawer = () => emits("openDrawer"); @@ -456,11 +454,6 @@ const initWebSocket = () => { // 处理WebSocket消息 const handleWebSocketMessage = (data) => { - if (loadingTimer) { - clearInterval(loadingTimer); - loadingTimer = null; - } - const aiMsgIndex = chatMsgList.value.length - 1; if (!chatMsgList.value[aiMsgIndex] || aiMsgIndex < 0) { return; @@ -484,8 +477,6 @@ const handleWebSocketMessage = (data) => { // 处理完成状态 if (data.finish) { - clearInterval(loadingTimer); - loadingTimer = null; // 等待打字机完成后处理其他数据 const waitForTypingComplete = () => { const status = typewriterManager @@ -498,7 +489,7 @@ const handleWebSocketMessage = (data) => { const msg = chatMsgList.value[aiMsgIndex].msg; console.log("全量消息内容:", msg); - if (!msg || msg === "加载中." || msg.startsWith("加载中")) { + if (!msg || msg === "加载中" || msg.startsWith("加载中")) { chatMsgList.value[aiMsgIndex].msg = "未获取到内容,请重试"; chatMsgList.value[aiMsgIndex].isLoading = false; if (data.toolCall) { @@ -644,7 +635,7 @@ const sendChat = (message, isInstruct = false) => { const aiMsg = { msgId: `msg_${chatMsgList.value.length}`, msgType: MessageRole.AI, - msg: "加载中.", + msg: "加载中", isLoading: true, msgContent: { type: MessageType.TEXT, @@ -654,14 +645,6 @@ const sendChat = (message, isInstruct = false) => { chatMsgList.value.push(aiMsg); const aiMsgIndex = chatMsgList.value.length - 1; - // 动态加载中动画 - let dotCount = 1; - loadingTimer && clearInterval(loadingTimer); - loadingTimer = setInterval(() => { - dotCount = (dotCount % 3) + 1; - chatMsgList.value[aiMsgIndex].msg = "加载中" + ".".repeat(dotCount); - }, 400); - // 发送消息 const success = sendWebSocketMessage(messageType, messageContent); if (!success) { @@ -679,11 +662,6 @@ const stopRequest = () => { // 发送中断消息给服务器 (messageType=2) sendWebSocketMessage(2, "stop_request", { silent: true }); - if (loadingTimer) { - clearInterval(loadingTimer); - loadingTimer = null; - } - // 停止打字机效果 if (typewriterManager) { typewriterManager.stopTypewriter(); diff --git a/pages/loading/DotLoading.vue b/pages/loading/DotLoading.vue new file mode 100644 index 0000000..f5c2112 --- /dev/null +++ b/pages/loading/DotLoading.vue @@ -0,0 +1,48 @@ + + + + +