probe-markers.mjs 1.1 KB

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