修复群公告解析错误

This commit is contained in:
xuncha
2026-02-03 14:37:34 +08:00
committed by xuncha
parent 34cd337146
commit a70d8fe6c8
4 changed files with 120 additions and 0 deletions

View File

@@ -2510,4 +2510,65 @@
color: white;
}
}
.announcement-message {
background: rgba(255, 255, 255, 0.15);
.announcement-label {
color: rgba(255, 255, 255, 0.8);
}
.announcement-text {
color: white;
}
.announcement-icon {
color: white;
}
}
}
// 群公告消息
.announcement-message {
display: flex;
gap: 12px;
align-items: flex-start;
padding: 12px 14px;
background: var(--hover-color);
border-radius: 12px;
max-width: 320px;
.announcement-icon {
flex-shrink: 0;
width: 28px;
height: 28px;
display: flex;
align-items: center;
justify-content: center;
color: #f59e42;
svg {
width: 20px;
height: 20px;
}
}
.announcement-content {
flex: 1;
min-width: 0;
.announcement-label {
font-size: 12px;
color: var(--text-tertiary);
margin-bottom: 4px;
}
.announcement-text {
font-size: 14px;
color: var(--text-primary);
line-height: 1.5;
word-break: break-word;
white-space: pre-wrap;
}
}
}

View File

@@ -2622,6 +2622,7 @@ function MessageBubble({ message, session, showTime, myAvatarUrl, isGroupChat, o
let desc = ''
let url = ''
let appMsgType = ''
let textAnnouncement = ''
try {
const content = message.rawContent || message.parsedContent || ''
@@ -2635,10 +2636,29 @@ function MessageBubble({ message, session, showTime, myAvatarUrl, isGroupChat, o
desc = doc.querySelector('des')?.textContent || ''
url = doc.querySelector('url')?.textContent || ''
appMsgType = doc.querySelector('appmsg > type')?.textContent || doc.querySelector('type')?.textContent || ''
textAnnouncement = doc.querySelector('textannouncement')?.textContent || ''
} catch (e) {
console.error('解析 AppMsg 失败:', e)
}
// 群公告消息 (type=87)
if (appMsgType === '87') {
const announcementText = textAnnouncement || desc || '群公告'
return (
<div className="announcement-message">
<div className="announcement-icon">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<path d="M22 17H2a3 3 0 0 0 3-3V9a7 7 0 0 1 14 0v5a3 3 0 0 0 3 3zm-8.27 4a2 2 0 0 1-3.46 0" />
</svg>
</div>
<div className="announcement-content">
<div className="announcement-label"></div>
<div className="announcement-text">{announcementText}</div>
</div>
</div>
)
}
// 聊天记录 (type=19)
if (appMsgType === '19') {
const recordList = message.chatRecordList || []