probe-vectors.mjs 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. // 探查品牌位与图层功能图标是否为可重建矢量
  2. import { readFileSync, readdirSync } from 'node:fs'
  3. import { join } from 'node:path'
  4. const raw = '.scratch/lanhu-cockpit-asset-replacement/research/raw'
  5. const files = readdirSync(raw).filter((f) => /^desktop-\d+\.json$/.test(f)).sort()
  6. const targets = ['管线图层', '监测设备', '事件定位', '应急资源', '城市生命线驾驶舱系统']
  7. for (const file of files) {
  8. const j = JSON.parse(readFileSync(join(raw, file), 'utf8'))
  9. const ab = j.artboard
  10. const hits = []
  11. function walk(node, path) {
  12. const p = path ? `${path}/${node.name}` : node.name
  13. const isText = node.type === 'textLayer' && node.text?.style?.content
  14. const label = isText ? String(node.text.style.content) : node.name
  15. if (targets.some((t) => label && label.includes(t))) {
  16. hits.push({
  17. label,
  18. path: p,
  19. type: node.type,
  20. frame: `${Math.round(node.frame?.width ?? 0)}x${Math.round(node.frame?.height ?? 0)}`,
  21. paths: (node.paths || []).length,
  22. fills: (node.style?.fills || []).map((f) => f.type).join('+'),
  23. })
  24. }
  25. for (const ch of node.layers || []) walk(ch, p)
  26. }
  27. for (const l of ab.layers || []) walk(l, '')
  28. if (hits.length) {
  29. console.log(`\n=== ${ab.name}`)
  30. for (const h of hits) console.log(` ${h.label} | ${h.type} | ${h.frame} | paths=${h.paths} | fills=${h.fills} | ${h.path}`)
  31. }
  32. }