Merge pull request #188 from xunchahaha/dev

修复群公告解析错误
This commit is contained in:
xuncha
2026-02-03 14:50:50 +08:00
committed by GitHub
6 changed files with 120 additions and 12 deletions

View File

@@ -20,9 +20,6 @@ WeFlow 是一个**完全本地**的微信**实时**聊天记录查看、分析
<a href="https://github.com/hicccc77/WeFlow/issues">
<img src="https://img.shields.io/github/issues/hicccc77/WeFlow?style=flat-square" alt="Issues">
</a>
<a href="https://t.me/+hn3QzNc4DbA0MzNl">
<img src="https://img.shields.io/badge/Telegram%20交流群-点击加入-0088cc?style=flat-square&logo=telegram&logoColor=0088cc&labelColor=white" alt="Telegram">
</a>
</p>
@@ -32,15 +29,6 @@ WeFlow 是一个**完全本地**的微信**实时**聊天记录查看、分析
> [!NOTE]
> 仅支持微信 **4.0 及以上**版本,确保你的微信版本符合要求
# 加入微信交流群
> 🎉 扫码加入微信群,与其他 WeFlow 用户一起交流问题和使用心得。
<p align="center">
<img src="mdassets/us.png" alt="WeFlow 微信交流群二维码" width="220" style="margin-right: 16px;"
</p>
## 主要功能
- 本地实时查看聊天记录

View File

@@ -1268,6 +1268,15 @@ class ChatService {
case 8589934592049:
return '[转账]'
default:
// 检查是否是 type=87 的群公告消息
if (xmlType === '87') {
const textAnnouncement = this.extractXmlValue(content, 'textannouncement')
if (textAnnouncement) {
return `[群公告] ${textAnnouncement}`
}
return '[群公告]'
}
// 检查是否是 type=57 的引用消息
if (xmlType === '57') {
const title = this.extractXmlValue(content, 'title')
@@ -1291,6 +1300,15 @@ class ChatService {
const title = this.extractXmlValue(content, 'title')
const type = this.extractXmlValue(content, 'type')
// 群公告消息type 87特殊处理
if (type === '87') {
const textAnnouncement = this.extractXmlValue(content, 'textannouncement')
if (textAnnouncement) {
return `[群公告] ${textAnnouncement}`
}
return '[群公告]'
}
if (title) {
switch (type) {
case '5':
@@ -1324,6 +1342,8 @@ class ChatService {
return '[小程序]'
case '2000':
return '[转账]'
case '87':
return '[群公告]'
default:
return '[消息]'
}

View File

@@ -413,6 +413,15 @@ class ExportService {
if (xmlType) {
const title = this.extractXmlValue(content, 'title')
// 群公告消息type 87
if (xmlType === '87') {
const textAnnouncement = this.extractXmlValue(content, 'textannouncement')
if (textAnnouncement) {
return `[群公告] ${textAnnouncement}`
}
return '[群公告]'
}
// 转账消息
if (xmlType === '2000') {
const feedesc = this.extractXmlValue(content, 'feedesc')
@@ -496,6 +505,15 @@ class ExportService {
const subType = typeMatch ? parseInt(typeMatch[1], 10) : 0
const title = this.extractXmlValue(normalized, 'title') || this.extractXmlValue(normalized, 'appname')
// 群公告消息type 87
if (subType === 87) {
const textAnnouncement = this.extractXmlValue(normalized, 'textannouncement')
if (textAnnouncement) {
return `[群公告]${textAnnouncement}`
}
return '[群公告]'
}
// 转账消息特殊处理
if (subType === 2000 || title.includes('转账') || normalized.includes('transfer')) {
const feedesc = this.extractXmlValue(normalized, 'feedesc')
@@ -686,6 +704,7 @@ class ExportService {
if (xmlType) {
switch (xmlType) {
case '87': return '群公告'
case '2000': return '转账消息'
case '5': return '链接消息'
case '6': return '文件消息'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 203 KiB

After

Width:  |  Height:  |  Size: 185 KiB

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 || []