import { Modal } from 'antd'; import { useEffect, useState } from 'react'; import { IChatItem } from '../ChatLogsType'; import styles from './index.module.scss'; export const ChatRecord: React.FC = (props) => { const [visible, setVisible] = useState(false); function chatRecordContent(data: any) { // todo console.log(msg); if (data.type == 'ChatRecordText') { const content = JSON.parse(data.content); return
{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) {} }, [props.chat]); function content() { try { const msg = JSON.parse(props.chat?.content as string); // setRecord(msg); console.log(msg); return (
{ setVisible(true); }} >
{msg.title}
{msg.item[0] ? (
{chatRecordContent(msg.item[0])}
) : null} {msg.item[1] ? (
{chatRecordContent(msg.item[1])}
) : null} {msg.item[2] ? (
{chatRecordContent(msg.item[2])}
) : null}
聊天记录
); } catch (_e) { return (
{props.chat?.content}
); } } return ( <> { setVisible(false); }} >
{record ? (
{record.item.map((item: any) => { console.log(item); return (
{chatRecordContent(item)}
); })}
) : null}
{props.from?.user_id == props.chat?.msg_from ? (
{props.from?.name}
{content()}
{props.from?.name[0]}
) : (
{props.to?.cust_info.name}
{content()}
)} ); };