message修改为data

This commit is contained in:
2026-05-21 20:40:39 +08:00
parent ffaf527721
commit 690ebac266
2 changed files with 20 additions and 21 deletions

View File

@@ -62,7 +62,7 @@ function sendChatMessage(message) {
if (store.getRenderStreaming()) { if (store.getRenderStreaming()) {
store.getRenderStreaming().sendMessage({ store.getRenderStreaming().sendMessage({
type: 'chat-message', type: 'chat-message',
message: message, data: message,
}); });
} }
} }

View File

@@ -715,39 +715,38 @@ class CallStateManager {
this.renderstreaming.onMessage = (data) => { this.renderstreaming.onMessage = (data) => {
console.log('收到消息:', data); console.log('收到消息:', data);
if (data.type === 'chat-message') { if (data.type === 'chat-message') {
// 处理聊天 const chatPayload = data.data || data.message;
// 添加到列表并更新UI if (!chatPayload) {
chatMessage.handleChatMessage(data.message); return;
// Host端按participantId更新对应用户信息
if (data.participantId && this.role === 'host' && this.state.participants[data.participantId]) {
this.state.participants[data.participantId].id = data.message.senderId;
if (data.message.senderName) {
this.state.participants[data.participantId].name = data.message.senderName;
} }
if (data.message.senderAvatar) {
this.state.participants[data.participantId].avatar = data.message.senderAvatar; chatMessage.handleChatMessage(chatPayload);
if (data.participantId && this.role === 'host' && this.state.participants[data.participantId]) {
this.state.participants[data.participantId].id = chatPayload.senderId;
if (chatPayload.senderName) {
this.state.participants[data.participantId].name = chatPayload.senderName;
}
if (chatPayload.senderAvatar) {
this.state.participants[data.participantId].avatar = chatPayload.senderAvatar;
} }
this.notify({ type: 'PARTICIPANTS_UPDATE', participants: this.state.participants }); this.notify({ type: 'PARTICIPANTS_UPDATE', participants: this.state.participants });
this.broadcastParticipantsList(); this.broadcastParticipantsList();
} }
// Participant端根据消息来源更新对应用户信息
if (!this.role || this.role !== 'host') { if (!this.role || this.role !== 'host') {
if (data.participantId && this.state.participants[data.participantId]) { if (data.participantId && this.state.participants[data.participantId]) {
// 来自其他Participant的消息更新participants中对应条目 if (chatPayload.senderName) {
if (data.message.senderName) { this.state.participants[data.participantId].name = chatPayload.senderName;
this.state.participants[data.participantId].name = data.message.senderName;
} }
if (data.message.senderAvatar) { if (chatPayload.senderAvatar) {
this.state.participants[data.participantId].avatar = data.message.senderAvatar; this.state.participants[data.participantId].avatar = chatPayload.senderAvatar;
} }
this.notify({ type: 'PARTICIPANTS_UPDATE', participants: this.state.participants }); this.notify({ type: 'PARTICIPANTS_UPDATE', participants: this.state.participants });
} else if (data.message && data.message.senderId !== this.state.session.localUser.id) { } else if (chatPayload.senderId !== this.state.session.localUser.id) {
// 来自Host的消息更新remoteUser
this.state.session.remoteUser = { this.state.session.remoteUser = {
...this.state.session.remoteUser, ...this.state.session.remoteUser,
id: data.message.senderId, id: chatPayload.senderId,
name: data.message.senderName, name: chatPayload.senderName,
avatar: data.message.senderAvatar avatar: chatPayload.senderAvatar
}; };
this.notify({ type: 'REMOTE_MEDIA_CHANGE', mediaState: this.state.session.remoteUser.mediaState }); this.notify({ type: 'REMOTE_MEDIA_CHANGE', mediaState: this.state.session.remoteUser.mediaState });
} }