import { Modal } from 'antd'; import React, { useEffect, useState } from 'react'; import { IChatItem } from '../ChatLogsType'; import { EmojiFormat } from './EmojiFormat'; export const ChatRecord: React.FC = (props) => { const [visible, setVisible] = useState(false); function chatRecordContent(data: any, type: string) { if (data.type == 'ChatRecordText') { const content = JSON.parse(data.content); return (
{type == 'ellipsis' ? content.content : }
); } else if (data.type == 'ChatRecordImage') { return
[图片]
; } else if (data.type == 'ChatRecordFile') { return
[文件]
; } else if (data.type == 'ChatRecordVideo') { return
[视频]
; } else if (data.type == 'ChatRecordLink') { return
[链接]
; } else if (data.type == 'ChatRecordLocation') { return
[位置]
; } else if (data.type == 'ChatRecordMixed') { return
[混合信息]
; } return
[未匹配到类型信息]
; } const [record, setRecord] = useState(null); useEffect(() => { try { const msg = JSON.parse(props.chat?.content as string); setRecord(msg); } catch (e) { /* empty */ } }, [props.chat]); function content() { try { const msg = JSON.parse(props.chat?.content as string); // console.log(msg); return (
{ setVisible(true); }} >
{msg.title}
{msg.item[0] ? (
{chatRecordContent(msg.item[0], 'ellipsis')}
) : null} {msg.item[1] ? (
{chatRecordContent(msg.item[1], 'ellipsis')}
) : null} {msg.item[2] ? (
{chatRecordContent(msg.item[2], 'ellipsis')}
) : null}
聊天记录
); } catch (_e) { return (
{props.chat?.content}
); } } return ( <> { setVisible(false); }} centered destroyOnClose >
{record ? (
{record.item.map((item: any) => { return (
{chatRecordContent(item, 'no_ellipsis')}
); })}
) : null}
{content()} ); };