From 92b30a605914ea2a8e7eb38273333ad6b9571d5b Mon Sep 17 00:00:00 2001 From: ivamp Date: Fri, 13 Sep 2024 18:54:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components.d.ts | 2 +- src/components/chat/Chat.vue | 20 +- src/components/chat/chat.vue | 606 ----------------------------------- 3 files changed, 19 insertions(+), 609 deletions(-) delete mode 100644 src/components/chat/chat.vue diff --git a/src/components.d.ts b/src/components.d.ts index 2b42f87..f47bdb4 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -9,7 +9,7 @@ declare module 'vue' { export interface GlobalComponents { AssistantMenu: typeof import('./components/AssistantMenu.vue')['default'] Assistants: typeof import('./components/assistants/index.vue')['default'] - Chat: typeof import('./components/chat/chat.vue')['default'] + Chat: typeof import('./components/chat/Chat.vue')['default'] ChatMenu: typeof import('./components/ChatMenu.vue')['default'] ChatSettings: typeof import('./components/ChatSettings.vue')['default'] LeftSettings: typeof import('./components/LeftSettings.vue')['default'] diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index 5241944..8c5095b 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -292,6 +292,13 @@ function sendText() { input.innerText = ""; updateInputHeight(); + + // 滚动 + // @ts-ignore ignore + element.mainContainer?.scrollTo({ + top: "999999", + behavior: "smooth", + }); } async function sendMessage( @@ -395,6 +402,14 @@ async function getChatMessages() { chatMessages.value = cm.data.data; + // 滚动 + setTimeout(() => { + // @ts-ignore ignore + element.mainContainer?.scrollTo({ + top: "999999", + behavior: "smooth", + }); + }, 400); // 完成 return true; } @@ -478,6 +493,7 @@ function streamChat(streamId: String, redirect = false) { } if (autoScroll.value) { + // @ts-ignore ignore element.mainContainer?.scrollTo({ top: "999999", behavior: "smooth", @@ -515,14 +531,14 @@ onUnmounted(() => { }); const uploadFile = () => { - if (!fileUpload.value) { + if (!fileUpload.value || !chatId.value) { return; } uploading.value = true; getApi() .ChatMessage.apiV1ChatsIdFilesPost( - chatId, + Number(chatId.value), { file: fileUpload.value, url: "", diff --git a/src/components/chat/chat.vue b/src/components/chat/chat.vue deleted file mode 100644 index 6ce750c..0000000 --- a/src/components/chat/chat.vue +++ /dev/null @@ -1,606 +0,0 @@ - - - -