import { SignalFilled } from '@ant-design/icons'; import { Modal } from 'antd'; import { useEffect, useState } from 'react'; import { IChatItem } from '../ChatLogsType'; import styles from './index.module.scss'; export const ChatVote: React.FC = (props) => { const votetype: any = { '101': '发起投票', '102': '参与投票' }; const [open, setOpen] = useState(false); const [voteitem, setVoteitem] = useState([]); useEffect(() => { try { const msg = JSON.parse(props.chat?.content as string); setVoteitem(msg?.voteitem); } catch (e) {} }, [props.chat]); function content() { try { const msg = JSON.parse(props.chat?.content as string); return ( <>
setOpen(true)} >
{msg?.votetitle}
{Array.isArray(msg?.voteitem) ? [0, 1, 2].map((item) => { return msg?.voteitem[item] ? (
{msg?.voteitem[item]}
) : ( <> ); }) : null}
投票 [ {votetype[msg?.votetype as string]}]
{ setOpen(false); }} footer={false} >
{Array.isArray(voteitem) ? voteitem.map((item) => { return (
{item}
); }) : null}
); } catch (e) {} return (
{props.chat?.content}
投票
); } return <>{content()}; };