perf: 历史记录: 显示绝对时间

dev/chat
Lei OT 2 years ago
parent d242ed3909
commit 6b4c3a0557

@ -4,6 +4,7 @@ import { fetchJSON, postJSON } from '@/utils/request'
import { parseRenderMessageList } from '@/lib/msgUtils';
import { API_HOST } from '@/config';
import { isEmpty } from '@/utils/commons';
import dayjs from 'dayjs';
export const fetchTemplates = async () => {
const data = await fetchJSON(`${API_HOST}/listtemplates`);
@ -89,6 +90,7 @@ export const fetchConversationsSearch = async (params) => {
whatsapp_name: `${ele.whatsapp_name || ''}`.trim(),
opi_sn: ele.OPI_SN || ele.opi_sn || 0,
OPI_Name: `${ele.OPI_Name || ele.opi_name || ''}`.trim(),
dateText: dayjs(ele.last_received_time).format('MM-DD HH:mm'),
matchMsgList: parseRenderMessageList((ele.msglist_AsJOSN || [])), // .reverse()),
}));
return list;

@ -1,4 +1,5 @@
import { cloneDeep, isEmpty, olog } from "@/utils/utils";
import dayjs from "dayjs";
import { v4 as uuid } from "uuid";
export const replaceTemplateString = (str, replacements) => {
@ -480,6 +481,7 @@ export const parseRenderMessageList = (messages, conversationid = null) => {
type: msgContent.type,
...(typeof whatsappMsgTypeMapped[msgType].type === 'function' ? whatsappMsgTypeMapped[msgType].type(msg) : { type: whatsappMsgTypeMapped[msgType].type || 'text' }),
date: msgContent?.sendTime || msg.msgtime || '',
dateText: dayjs(msgContent?.sendTime || msg.msgtime).format('MM-DD HH:mm'),
localDate: (msg.msgtime || '').replace('T', ' '),
from: msgContent.from,
sender: msgContent.from,

@ -316,6 +316,7 @@ function ChatHistory() {
subtitle={`${item.OPI_Name || ''} ${item.coli_id || ''}`}
date={item.last_received_time}
// dateString={item.last_received_time}
dateString={item.dateText}
className={String(item.conversationid) === String(selectedConversation.conversationid) ? '__active text-primary bg-neutral-100' : ''}
onClick={() => setSelectedConversation(item)}
/>
@ -340,7 +341,7 @@ function ChatHistory() {
title={item.sender === 'me' ? selectedConversation.OPI_Name || item.senderName : item.senderName}
subtitle={item.originText}
date={item.msgtime}
// dateString={item.msgtime}
dateString={item.dateText}
className={String(item.sn) === String(selectMatch?.sn) ? '__active text-primary bg-neutral-100' : ' bg-white'}
onClick={() => handleMatchMsgClick(item)}
/>
@ -392,7 +393,7 @@ function ChatHistory() {
navigator.clipboard.writeText(message.text);
appMessage.success('复制成功😀');
},
Component: () => <div>复制</div>,
Component: () => <div key='copy'>复制</div>,
},
],
}

Loading…
Cancel
Save