diff --git a/src/views/system/gen-chat.vue b/src/views/system/gen-chat.vue
index a93e304..97e514b 100644
--- a/src/views/system/gen-chat.vue
+++ b/src/views/system/gen-chat.vue
@@ -60,7 +60,7 @@
🧑🎓
-
+
([]); // 用于存储过滤后的文件列表
const uploadFileVisible = ref(false); // 控制上传文件对话框的显示与隐藏
+const historyMsgHtml= ref([]); // 用于存储历史消息的HTML内容
-const renderMarkdown = (content: string) => {
- return md.render(content);
+const renderMarkdown = (message: Message, index:number) => {
+ if(message.finished == false){
+ //console.log("not finished");
+ return message.content;
+ }
+ if(historyMsgHtml.value[index]){
+ //console.log("historyMsgHtml:", historyMsgHtml.value[index]);
+ //console.log("historyMsgHtml:", index);
+ //已经渲染过的消息,直接返回
+ return historyMsgHtml.value[index];
+ }
+ //console.log("new finish:");
+ const html = md.render(message.content);
+ historyMsgHtml.value.push(html);
+ return html;
};
const scrollToBottom = () => {
@@ -626,6 +640,7 @@ const loadSession = async (session_id: number) => {
const clearCurrent = () => {
sessionID.value = 0;
messages.length = 0; // 清空消息
+ historyMsgHtml.value.length = 0; // 清空历史消息
sessionName.value = "新会话";
ElMessage.success("新会话已创建!可以开始聊天了");
};
@@ -649,6 +664,7 @@ const getShortenedName = (name: string) => {
};
const getMessage = async (session_id: number) => {
+ historyMsgHtml.value.length = 0; // 清空历史消息
let result = {};
try {
let req = {
diff --git a/src/views/system/kbase-chat.vue b/src/views/system/kbase-chat.vue
index 7af3c55..6a46131 100644
--- a/src/views/system/kbase-chat.vue
+++ b/src/views/system/kbase-chat.vue
@@ -60,7 +60,7 @@
🧑🎓
-
+
([]); // 用于存储过滤后的文件列表
const uploadFileVisible = ref(false); // 控制上传文件对话框的显示与隐藏
-
- const renderMarkdown = (content: string) => {
- return md.render(content);
- };
-
+ const historyMsgHtml= ref([]); // 用于存储历史消息的HTML内容
+
+const renderMarkdown = (message: Message, index:number) => {
+ if(message.finished == false){
+ //console.log("not finished");
+ return message.content;
+ }
+ if(historyMsgHtml.value[index]){
+ //console.log("historyMsgHtml:", historyMsgHtml.value[index]);
+ //console.log("historyMsgHtml:", index);
+ //已经渲染过的消息,直接返回
+ return historyMsgHtml.value[index];
+ }
+ //console.log("new finish:");
+ const html = md.render(message.content);
+ historyMsgHtml.value.push(html);
+ return html;
+};
const scrollToBottom = () => {
let x = document.getElementsByClassName("chat-messages")[0];
if (!x) return;
@@ -665,6 +678,7 @@
};
const getMessage = async (session_id: number) => {
+ historyMsgHtml.value.length = 0; // 清空历史消息
let result = {};
try {
let req = {