From 3a503764c671d4d17b602c77f9ce286281b80492 Mon Sep 17 00:00:00 2001 From: Twilight Date: Fri, 20 Sep 2024 13:01:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BE=93=E5=85=A5=E6=97=B6?= =?UTF-8?q?=E5=80=99=E7=9A=84=20markdown=20=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/components/chat/Chat.vue | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ae25d59..20c2722 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ }, "dependencies": { "@kangc/v-md-editor": "^2.3.18", + "@notable/html2markdown": "^2.0.3", "@traptitech/markdown-it-katex": "^3.6.0", "animate.css": "^4.1.1", "axios": "^1.7.7", diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index e3d1d3e..77458e9 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -199,6 +199,7 @@ import { useIsMobile } from "@/utils/composables"; import { useAppStore } from "@/stores/app"; import { UploadCustomRequestOptions, useDialog, useMessage } from "naive-ui"; import { useAssistantStore } from "@/stores/assistants"; +import html2markdown from "@notable/html2markdown"; // 获取组件传入的 chatId const chatId: Ref = ref(null); @@ -230,7 +231,6 @@ const content = ref(""); const inputExpanded = ref(false); const chatMessages: Ref = ref([]); const processing = ref(false); -const fileUpload = ref(); const uploading = ref(false); const autoScroll = ref(true); const appStore = useAppStore(); @@ -360,14 +360,14 @@ function sendText() { } const input = inputText.value; - const textContent = input.innerText.trim(); + const textContent = input.innerHTML; if (textContent === "") { return; } // 发送文本到服务器 - sendMessage("user", textContent); + sendMessage("user", html2markdown(textContent)); // 清空输入框 input.innerText = "";