danmu-sim/app/danmu/message.tsx
2024-04-07 01:53:46 +08:00

22 lines
565 B
TypeScript

export default function MessageDispatcher({ message }: { message: any }) {
const messageType = message?.groups?.[0]?.units?.[0]?.type;
let nick = "wait";
let content = "wait";
if (message?.type === 'sauth_ret') {
return <div>{message?.data?.em}</div>
}
if (messageType === "Message") {
nick = message?.groups?.[0]?.nick;
content = message?.groups?.[0]?.units?.[0]?.["Msg.Message.data"]?.text;
}
return (
<div className="chat chat-start">
<div className="chat-bubble">
{nick}: {content}
</div>
</div>
);
}