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 = "";