资讯动态

控制UI发送消息的代码分析

发布时间:2026/8/3 2:52:00 来源:尧图企业网站定制
控制UI发送消息的代码分析核心发送方法在 openclaw-cn\ui\src\ui\controllers\chat.ts 文件中, sendChatMessage 函数是发送消息的核心实现:export async function sendChatMessage( state: ChatState, message: string, attachments?: ChatAttachment[], ): Promisestring | null { if (!state.client || !state. connected) { return null; } const msg = message.trim(); const hasAttachments = attachments attachments. length 0; if (!msg !hasAttachments) { return null; } // 构建用户消息内容块 const contentBlocks: Array{ type: string; text?: string; source?: unknown } = []; if (msg) { contentBlocks.push({ type: "text", text: msg }); } // 添加图片预览到消息中 if (hasAttachments) { for (cons

读完文章,也想定制专属网站?

尧图设计师 24 小时内与您沟通定制方案

免费获取报价