| 1234567891011121314151617181920 |
- // 扫描小尺寸矢量图层,判断设计稿是否含点位/设备标记母版
- import { readFileSync } from 'node:fs'
- const files = ['desktop-06.json', 'desktop-08.json', 'desktop-02.json']
- for (const file of files) {
- const j = JSON.parse(readFileSync(`.scratch/lanhu-cockpit-asset-replacement/research/raw/${file}`, 'utf8'))
- const small = []
- function walk(node, path) {
- const p = path ? `${path}/${node.name}` : node.name
- const w = node.frame?.width ?? 0
- const h = node.frame?.height ?? 0
- if ((node.type === 'shapeLayer' || node.type === 'groupLayer') && w > 0 && h > 0 && w <= 44 && h <= 44 && (node.paths || []).length) {
- small.push({ p, w: Math.round(w), h: Math.round(h), t: node.type, fills: (node.style?.fills || []).map((f) => f.type).join('+') })
- }
- for (const ch of node.layers || []) walk(ch, p)
- }
- for (const l of j.artboard.layers || []) walk(l, '')
- console.log(`\n=== ${j.artboard.name}: small vector shapes = ${small.length}`)
- for (const s of small.slice(0, 22)) console.log(` ${s.w}x${s.h} ${s.t} fills=${s.fills} | ${s.p}`)
- }
|