Skip to content

renderMessageContent函数无法读取到正确的type值 #198

Description

@Shen-zhihao

Version information (版本信息)

  • ChatUI or ChatUI Pro? ChatUI
  • ChatUI Version: "@chatui/core": "^3.2.0",
  • React Version: "react": "^19.1.0",
  • OS Version: macos
  • Browser Version: Chrome 版本 140.0.7339.81

Describe the bug (描述问题)
appendMsg函数发送了type,renderMessageContent函数无法读取到除了text以外的type
Steps To Reproduce (重现步骤)

// 处理发送消息
const handleSend = async (type, val, showBtn = false) => {
  setIsInit(false);
  switch (type) {
    case "text":
      // 添加用户消息
      appendMsg({
        type,
        content: { text: val.trim() },
        position: "right",
        user: {
          avatar: studentInfo?.avatar,
          name: userAvatarDom,
        },
      });
      // todo
      
      break;
    case "system":
      appendMsg({
        type,
        content: {
          text: (
            <div className="system-message-wrapper">
              <span style={{ color: !showBtn ? "#0077FF" : "#1D2129" }}>
                  {val.trim()}
                </span>
            </div>
          ),
        },
      });
      break;
    case "image":
      break;
    case "file":
      break;
    default:
      break;
  }
};

// 自定义消息渲染器
const renderMessageContent = (MessageProps) => {
  const { content, _id, type } = MessageProps;
console.log(type)

};

Link to minimal reproduction (最小化重现链接)

Expected behavior (期望的结果是什么)
看看是不是哪里出错了

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions