From 2e75ef696a08c6d69687a220831e4fb53919f504 Mon Sep 17 00:00:00 2001
From: ldq <1582649509@qq.com>
Date: Fri, 13 Dec 2024 20:29:07 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B6=88=E6=81=AF=E5=B1=95=E7=A4=BA?=
=?UTF-8?q?=E5=80=92=E5=BA=8F=20&=20=E5=A4=B4=E5=83=8F=E9=A2=84=E8=A7=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/client/assets/css/chatMessage.css | 11 +
.../src/client/component/ChatMessage.tsx | 23 +-
.../client/component/InquiryRecordView.tsx | 18 +-
.../client/component/MaterialInquiryView.tsx | 11 +-
.../client/context/InquiryRecordContext.tsx | 801 ++++--------------
5 files changed, 234 insertions(+), 630 deletions(-)
diff --git a/packages/plugins/@gemel/plugin-inquiry-record-detail/src/client/assets/css/chatMessage.css b/packages/plugins/@gemel/plugin-inquiry-record-detail/src/client/assets/css/chatMessage.css
index 63f9af091..7290085c5 100644
--- a/packages/plugins/@gemel/plugin-inquiry-record-detail/src/client/assets/css/chatMessage.css
+++ b/packages/plugins/@gemel/plugin-inquiry-record-detail/src/client/assets/css/chatMessage.css
@@ -32,3 +32,14 @@
.avatar {
flex-shrink: 0;
}
+
+.messageTime {
+ font-size: 12px;
+ color: #999;
+ margin-bottom: 2px;
+ padding: 0 12px;
+}
+
+.messageItemSender .messageTime {
+ text-align: right;
+}
diff --git a/packages/plugins/@gemel/plugin-inquiry-record-detail/src/client/component/ChatMessage.tsx b/packages/plugins/@gemel/plugin-inquiry-record-detail/src/client/component/ChatMessage.tsx
index 38b188733..bb2db53c5 100644
--- a/packages/plugins/@gemel/plugin-inquiry-record-detail/src/client/component/ChatMessage.tsx
+++ b/packages/plugins/@gemel/plugin-inquiry-record-detail/src/client/component/ChatMessage.tsx
@@ -9,16 +9,17 @@
import React from 'react';
import { Avatar } from 'antd';
+import dayjs from 'dayjs';
import '../assets/css/chatMessage.css';
import classNames from 'classnames';
interface ChatMessage {
speakerRole: 'human' | 'ai';
content: string;
+ createdAt: number;
}
const ChatMessages: React.FC<{ messages: ChatMessage[] }> = ({ messages }) => {
- // 将换行符转换为
const formatContent = (content: string) => {
if (!content) return null;
return content.split('\n').map((text, index) => (
@@ -29,9 +30,19 @@ const ChatMessages: React.FC<{ messages: ChatMessage[] }> = ({ messages }) => {
));
};
+ const formatTime = (timestamp: number) => {
+ const messageDate = dayjs.unix(timestamp);
+ const today = dayjs();
+
+ if (messageDate.isSame(today, 'day')) {
+ return messageDate.format('HH:mm');
+ }
+ return messageDate.format('YYYY-MM-DD HH:mm');
+ };
+
return (