feat(images): v3.26.124 插件图片策略 v2(宿主三层 API + 解码闸门 + 插件全部改走小图)
This commit is contained in:
1 parent
9df561b3e0
commit
a0526e7860
19 files changed
+292
-57
No files matched your search
@@ -67,6 +67,26 @@ for (const id of fs.readdirSync(srcRoot)) {
|
||||
}
|
||||
}
|
||||
|
||||
// ── 图片策略守卫(v3.26.124,warn 阶段)─────────────────────────────────
|
||||
// 插件里出现「取整幅原图再自己缩放」的写法,在 WebKit 上每次都是 21MB 级解码,
|
||||
// 正是 mac 端 GB 级占用的来源。这里只报警不阻塞(下一版转 error)。
|
||||
const IMG_WARN = [
|
||||
{ re: /ctx\.images\.dataUrl\(/g, why: 'ctx.images.dataUrl 会取整幅原图;预览请用 ctx.images.preview({max}),网格请用 thumb({max})' },
|
||||
{ re: /getNodeImage\(\s*[A-Za-z0-9_.$]+\s*\)/g, why: 'getNodeImage 未传 {max}:插件只需看/预览时请传 {max:2048}(导出才拿原图)' },
|
||||
{ re: /createImageBitmap\(/g, why: '插件里 createImageBitmap 会整幅解码;改用 ctx.images.thumb/preview 让宿主原生缩放' },
|
||||
]
|
||||
try {
|
||||
for (const id of fs.readdirSync(srcRoot)) {
|
||||
const entry = path.join(srcRoot, id, 'src', 'index.js')
|
||||
if (!fs.existsSync(entry)) continue
|
||||
const code = fs.readFileSync(entry, 'utf8')
|
||||
for (const rule of IMG_WARN) {
|
||||
const hits = (code.match(rule.re) || []).length
|
||||
if (hits) console.log('[img-policy][warn] ' + id + ' ×' + hits + ':' + rule.why)
|
||||
}
|
||||
}
|
||||
} catch (e) { /* 源码仓不可读时跳过 */ }
|
||||
|
||||
if (problems.length) {
|
||||
console.error('[check-plugins] 两仓不一致(' + problems.length + ' 项):')
|
||||
for (const p of problems) console.error(' - ' + p)
|
||||
|
||||
Reference in new issue
Block a user