|
|
@@ -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('');
|