feat: 扩展中心支持多模态消息、HTML 渲染、一级导航与应用内通知

This commit is contained in:
Wxw-Gu committed 2026-12-01 14:49:41 +08:00
1 parent b20e514c90
commit 4ea73c3414
63 files changed
+8360 -644

No files matched your search

@@ -0,0 +1,56 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const {
normalizeConfig,
selectMediaBatchItems,
parseDigestSummary,
buildDigestHtml
} = require('../lib/digest-builder.js')
test('normalizeConfig 默认关闭自动发微信并收敛数值边界', () => {
const cfg = normalizeConfig({ windowHours: 999, renderWidth: 100, groupIds: ['g1@chatroom', 'g1@chatroom'] })
assert.equal(cfg.autoSendWechat, false)
assert.equal(cfg.windowHours, 168)
assert.equal(cfg.renderWidth, 320)
assert.deepEqual(cfg.groupIds, ['g1@chatroom'])
})
test('selectMediaBatchItems 按权限筛选图片 OCR/视觉与语音转写批次', () => {
const messages = [
{ type: 'text', messageRef: 'ref-1', text: '早安' },
{ type: 'image', messageRef: 'ref-img' },
{ type: 'voice', messageRef: 'ref-voice' }
]
const items = selectMediaBatchItems(
messages,
normalizeConfig({ enableImageOcr: true, enableVoiceTranscribe: true, maxMediaPerGroup: 5 }),
['media.ocr', 'media.transcribe']
)
assert.equal(items.length, 2)
assert.equal(items[0].op, 'transcribeVoice')
assert.equal(items[1].op, 'ocrImage')
})
test('buildDigestHtml 转义 HTML 特殊字符且不包含脚本或外链', () => {
const summary = parseDigestSummary(
JSON.stringify({
headline: '今日<script>alert(1)</script>焦点',
highlights: ['项目评审通过'],
actionItems: ['张三跟进上线'],
groupBriefs: [{ groupName: '产品测试群', summary: '讨论了发布排期' }]
})
)
const html = buildDigestHtml({
dateLabel: '2026-12-01',
...summary,
totalMessages: 42,
totalMediaResolved: 3,
groupCount: 1
})
assert.equal(/<script/i.test(html), false)
assert.equal(html.includes('&lt;script&gt;'), true)
assert.equal(html.includes('产品测试群'), true)
})