Sfoglia il codice sorgente

[Mod 0000]AI助手对话导出功能修改日期格式

wangkeyi 5 giorni fa
parent
commit
4d98b78531

+ 6 - 1
src/views/ventAI/manageAssistent/components/chatModal/exportDoc.ts

@@ -1,4 +1,5 @@
 import { marked } from 'marked';
+import dayjs from 'dayjs';
 import type { Message } from './types';
 
 /**
@@ -20,7 +21,11 @@ const cleanContent = (content: string): string =>
 export const buildConversationMarkdown = (messages: Message[]): string => {
   const lines: string[] = [];
   for (const msg of messages) {
-    const time = msg.time ? `(${msg.time})` : '';
+    const time = msg.createdAt
+      ? `(${dayjs(msg.createdAt).format('YYYY-MM-DD HH:mm:ss')})`
+      : msg.time
+      ? `(${msg.time})`
+      : '';
     if (msg.type === 'user') {
       lines.push(`### 用户 ${time}`.trimEnd());
       lines.push('');