renderMessageContent函数无法读取到正确的type值
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 425
- PR merge metrics
- No merged PRs in 30d
Description
**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: (
{val.trim()}
),
},
});
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 (期望的结果是什么)**
看看是不是哪里出错了
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the appendMsg entry point into the renderMessageContent callback, using the reported text and system cases as the reproduction. Check how the message type is stored and passed to the renderer, then confirm the behavior for non-text messages with a regression test or the project’s existing message-rendering tests. Done means renderMessageContent receives the intended type for the reported cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100