mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-12-01 01:05:30 +08:00
feat: 完善日报图片与公众号消息展示
修复日报图片读取格式与模型不支持时的友好降级 恢复话题关键词回退,确保词云在缺少顶层关键词时仍可展示 支持公众号多文章消息在聊天、日报、检索和 HTML 导出中完整呈现 迁移账号身份缓存并优化首次连接的账号占位信息 补充图片、词云、账号缓存与多文章消息回归测试
This commit is contained in:
1 parent
b5f67c47e5
commit
a6a004e403
18 files changed
+432
-36
No files matched your search
@@ -8,6 +8,12 @@ type LocationContent = {
|
||||
lng: number
|
||||
}
|
||||
type CardContent = { type: 'card'; username: string; nickname: string; avatarUrl?: string }
|
||||
type ShareArticle = {
|
||||
title: string
|
||||
description?: string
|
||||
url: string
|
||||
coverUrl?: string
|
||||
}
|
||||
type ShareContent = {
|
||||
type: 'share'
|
||||
title: string
|
||||
@@ -15,6 +21,7 @@ type ShareContent = {
|
||||
url: string
|
||||
appname?: string
|
||||
typeVal?: string
|
||||
articles?: ShareArticle[]
|
||||
}
|
||||
type ForwardedMessageItem = {
|
||||
messageType: number
|
||||
@@ -482,17 +489,71 @@ function parseShareMessage(content: string): ParsedContent {
|
||||
}
|
||||
}
|
||||
|
||||
const title = decodeXmlEntities(extractXmlValue(content, 'title')) || ''
|
||||
const des = extractXmlValue(content, 'des') || extractXmlValue(content, 'desc') || ''
|
||||
const url = extractXmlValue(content, 'url') || ''
|
||||
const appname = extractXmlValue(content, 'appname') || extractXmlValue(content, 'appInfo') || ''
|
||||
const articles = parseShareArticles(content)
|
||||
const title =
|
||||
articles[0]?.title || decodeXmlEntities(extractXmlValue(content, 'title')) || ''
|
||||
const des =
|
||||
articles[0]?.description ||
|
||||
decodeXmlEntities(extractXmlValue(content, 'des') || extractXmlValue(content, 'desc')) ||
|
||||
''
|
||||
const url = articles[0]?.url || decodeXmlUrl(extractXmlValue(content, 'url')) || ''
|
||||
const appname =
|
||||
decodeXmlEntities(
|
||||
extractXmlValue(content, 'appname') ||
|
||||
extractXmlValue(content, 'publisher') ||
|
||||
extractXmlValue(content, 'appInfo')
|
||||
) || ''
|
||||
const typeVal = extractXmlValue(content, 'type') || ''
|
||||
|
||||
if (!title && !url) {
|
||||
return { type: 'unknown', raw: content }
|
||||
}
|
||||
|
||||
return { type: 'share', title, des, url, appname, typeVal }
|
||||
return {
|
||||
type: 'share',
|
||||
title,
|
||||
des,
|
||||
url,
|
||||
appname,
|
||||
typeVal,
|
||||
articles: articles.length > 1 ? articles : undefined
|
||||
}
|
||||
}
|
||||
|
||||
function parseShareArticles(content: string): ShareArticle[] {
|
||||
if (!/<mmreader\b/i.test(content)) return []
|
||||
const articles = Array.from(
|
||||
content.matchAll(/<item(?:\s[^>]*)?>([\s\S]*?)<\/item>/gi),
|
||||
(match) => match[1] || ''
|
||||
)
|
||||
.map((item): ShareArticle | null => {
|
||||
const title = decodeXmlEntities(extractXmlValue(item, 'title'))
|
||||
const url = decodeXmlUrl(extractXmlValue(item, 'url'))
|
||||
if (!title && !url) return null
|
||||
const description = decodeXmlEntities(
|
||||
extractXmlValue(item, 'digest') ||
|
||||
extractXmlValue(item, 'summary') ||
|
||||
extractXmlValue(item, 'des')
|
||||
)
|
||||
const coverUrl = decodeXmlUrl(
|
||||
extractXmlValue(item, 'cover') || extractXmlValue(item, 'cover_1_1')
|
||||
)
|
||||
return {
|
||||
title: title || '公众号文章',
|
||||
url,
|
||||
description: description || undefined,
|
||||
coverUrl: coverUrl || undefined
|
||||
}
|
||||
})
|
||||
.filter((article): article is ShareArticle => Boolean(article))
|
||||
|
||||
const seen = new Set<string>()
|
||||
return articles.filter((article) => {
|
||||
const key = `${article.url}|${article.title}`
|
||||
if (seen.has(key)) return false
|
||||
seen.add(key)
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
function parseForwardBundle(content: string): ForwardBundleContent {
|
||||
|
||||
Reference in new issue
Block a user