mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-12-01 01:05:30 +08:00
feat: 档案和导出页面支持查看多选消息
This commit is contained in:
1 parent
2fb519a373
commit
b86582e606
19 files changed
+1897
-152
No files matched your search
@@ -258,6 +258,56 @@ describe('export media', () => {
|
||||
dom.window.close()
|
||||
})
|
||||
|
||||
it('opens the forward bundle of the clicked card after filters shrink the list', () => {
|
||||
const html = renderExportPage('合并转发索引')
|
||||
const dom = new JSDOM(html, { runScripts: 'outside-only' })
|
||||
Object.assign(dom.window, {
|
||||
__WECHAT_EXPORT__: {
|
||||
version: 2,
|
||||
name: '合并转发索引',
|
||||
exportedAt: '2026-08-04T00:00:00.000Z',
|
||||
conversations: [
|
||||
{ id: 'alpha', name: '聊天 A', type: 'user', messageCount: 2 },
|
||||
{ id: 'beta', name: '聊天 B', type: 'group', messageCount: 1 }
|
||||
],
|
||||
messages: [
|
||||
messageForArchive('alpha-1', 'alpha', '聊天 A', '普通文本甲', 1_767_225_600),
|
||||
{
|
||||
...messageForArchive('alpha-2', 'alpha', '聊天 A', '合并转发摘要', 1_767_225_700),
|
||||
contentData: {
|
||||
type: 'forwardBundle',
|
||||
title: '目标聊天记录',
|
||||
items: [
|
||||
{ messageType: 1, sender: '张三', text: '第一层内容甲' },
|
||||
{ messageType: 1, sender: '李四', text: '第一层内容乙' }
|
||||
]
|
||||
}
|
||||
},
|
||||
messageForArchive('beta-1', 'beta', '聊天 B', '普通文本乙', 1_769_904_000)
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
dom.window.eval(inlineScriptOf(html))
|
||||
|
||||
const search = dom.window.document.querySelector('#query') as HTMLInputElement
|
||||
search.value = '合并转发摘要'
|
||||
search.dispatchEvent(new dom.window.Event('input'))
|
||||
|
||||
const list = dom.window.document.querySelector('#messages')!
|
||||
expect(list.querySelectorAll('.message')).toHaveLength(1)
|
||||
const card = list.querySelector('[data-forward-open]') as HTMLElement
|
||||
expect(card.getAttribute('data-forward-open')).toBe('0')
|
||||
|
||||
card.dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }))
|
||||
|
||||
const root = dom.window.document.querySelector('#forward-modal-root')!
|
||||
expect(root.querySelectorAll('.forward-modal-window')).toHaveLength(1)
|
||||
expect(root.querySelector('.forward-modal-title')?.textContent).toBe('目标聊天记录')
|
||||
expect(root.textContent).toContain('第一层内容甲')
|
||||
dom.window.close()
|
||||
})
|
||||
|
||||
it('locates every filtered message kind in all messages, including outside the latest window', () => {
|
||||
const html = renderExportPage('定位消息')
|
||||
const dom = new JSDOM(html, { runScripts: 'outside-only' })
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { parseMessageContent } from '../../src/main/message-parser'
|
||||
import { attachForwardBundleRecordDir, parseMessageContent } from '../../src/main/message-parser'
|
||||
|
||||
describe('message parser', () => {
|
||||
it('parses image, voice and sticker messages without confusing their types', () => {
|
||||
@@ -79,6 +79,45 @@ describe('message parser', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('parses forwarded images (datatype=2), nested forwards (datatype=17), and attaches Rec dir refs', () => {
|
||||
const xml = `<msg><appmsg><type>19</type><title>群聊的聊天记录</title><recorditem><![CDATA[<recordinfo><title>群聊的聊天记录</title><datalist count="2"><dataitem datatype="2" dataid="img-1"><sourcename>张三</sourcename><sourcetime>2026-01-02 10:00</sourcetime><fullmd5>0123456789abcdef0123456789abcdef</fullmd5><thumbfullmd5>fedcba9876543210fedcba9876543210</thumbfullmd5><datasize>204800</datasize><thumbsize>8192</thumbsize></dataitem><dataitem datatype="17" dataid="nest-1"><sourcename>成员A</sourcename><datatitle>内层聊天记录</datatitle><recordxml><recordinfo><title>内层聊天记录</title><datalist count="2"><dataitem datatype="1" dataid="inner-1"><sourcename>成员B</sourcename><datadesc>内层文本消息</datadesc></dataitem><dataitem datatype="2" dataid="inner-2"><sourcename>成员B</sourcename><fullmd5>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</fullmd5></dataitem></datalist></recordinfo></recordxml></dataitem></datalist></recordinfo>]]></recorditem></appmsg></msg>`
|
||||
const parsed = parseMessageContent(xml, 49)
|
||||
expect(parsed.type).toBe('forwardBundle')
|
||||
if (parsed.type === 'forwardBundle') {
|
||||
const attached = attachForwardBundleRecordDir(parsed, 'fixture-rec-0001')
|
||||
expect(attached.recordDir).toBe('fixture-rec-0001')
|
||||
expect(attached.items).toHaveLength(2)
|
||||
expect(attached.items[0]).toMatchObject({
|
||||
messageType: 2,
|
||||
sender: '张三',
|
||||
text: '[图片]',
|
||||
dataIndex: 0,
|
||||
imageMd5: '0123456789abcdef0123456789abcdef',
|
||||
thumbMd5: 'fedcba9876543210fedcba9876543210',
|
||||
imageDatName: 'rec:fixture-rec-0001:0',
|
||||
dataSize: 204800,
|
||||
thumbSize: 8192
|
||||
})
|
||||
expect(attached.items[1]).toMatchObject({
|
||||
messageType: 17,
|
||||
nestedTitle: '内层聊天记录'
|
||||
})
|
||||
expect(attached.items[1].imageMd5).toBeUndefined()
|
||||
expect(attached.items[1].thumbMd5).toBeUndefined()
|
||||
expect(attached.items[1].nested).toHaveLength(2)
|
||||
expect(attached.items[1].nested?.[0]).toMatchObject({
|
||||
messageType: 1,
|
||||
sender: '成员B',
|
||||
text: '内层文本消息'
|
||||
})
|
||||
expect(attached.items[1].nested?.[1]).toMatchObject({
|
||||
messageType: 2,
|
||||
text: '[图片]',
|
||||
imageMd5: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
it.each([
|
||||
['6', '测试附件.pdf'],
|
||||
['74', '发送中的附件.zip']
|
||||
|
||||
@@ -143,6 +143,25 @@ describe('VideoAssetService local fallback', () => {
|
||||
expect(service.pathForUrl(result.url!)).toBe(join(month, `${targetStem}.mp4`))
|
||||
})
|
||||
|
||||
it('prefers _raw original video over compressed mp4 when both exist', async () => {
|
||||
const { accountRoot, service } = createService()
|
||||
const month = join(accountRoot, 'msg', 'video', '2026-11')
|
||||
mkdirSync(month, { recursive: true })
|
||||
const stem = '0c0236112233445566778899aabbcee6'
|
||||
const compressedPath = join(month, `${stem}.mp4`)
|
||||
const rawPath = join(month, `${stem}_raw.mp4`)
|
||||
const posterPath = join(month, `${stem}_thumb.jpg`)
|
||||
writeFileSync(compressedPath, mp4Fixture(10, 'compressed'))
|
||||
writeFileSync(rawPath, mp4Fixture(10, 'original-raw-video-bytes'))
|
||||
writeFileSync(posterPath, jpegFixture(720, 1280))
|
||||
|
||||
const result = await service.resolve([stem])
|
||||
|
||||
expect(result.success).toBe(true)
|
||||
expect(service.pathForUrl(result.url!)).toBe(rawPath)
|
||||
expect(service.pathForUrl(result.poster!)).toBe(posterPath)
|
||||
})
|
||||
|
||||
it('does not guess when multiple files match the same metadata', async () => {
|
||||
const { accountRoot, service } = createService()
|
||||
const month = join(accountRoot, 'msg', 'video', '2026-02')
|
||||
|
||||
Reference in new issue
Block a user