diff --git a/client/ui/chat/Message.jsx b/client/ui/chat/Message.jsx index 6d85f33..28c3f97 100644 --- a/client/ui/chat/Message.jsx +++ b/client/ui/chat/Message.jsx @@ -1,65 +1,81 @@ -export default function Message({ direction = 'left', children }) { +import Avatar from "../Avatar.js" + +/** + * 一条消息 + * @param { Object } param + * @param { "left" | "right" } [param.direction="left"] 消息方向 + * @param { String } [param.avatar] 头像链接 + * @param { String } [param.nickname] 昵称 + * @returns { React.JSX.Element } + */ +export default function Message({ direction = 'left', avatar, nickname, children, ...props } = {}) { + let isAtRight = direction == 'right' return (
+ }} + {...props}>
{ // 发送者昵称(左) - direction == 'left' && - } - { - // 发送者头像 - } - - - { - // 发送者昵称(右) - direction == 'right' && + {nickname} + + } + { + // 发送者头像 + } + + { + // 发送者昵称(右) + !isAtRight && + {nickname} }
- { - // 消息内容 - children - } + { + // 消息内容 + children + }