danmu-sim/app/danmu/message.tsx

22 lines
565 B
TypeScript
Raw Normal View History

2024-04-07 01:53:46 +08:00
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>
);
}