| 123456789101112131415161718192021222324252627282930313233343536 |
- // 探查 Chip 与 title 的子节点,确认图标是否为带路径的矢量
- import { readFileSync } from 'node:fs'
- const j = JSON.parse(readFileSync('.scratch/lanhu-cockpit-asset-replacement/research/raw/desktop-06.json', 'utf8'))
- const ab = j.artboard
- function find(node, want, path = '') {
- const p = path ? `${path}/${node.name}` : node.name
- if (node.name === want) return { node, path: p }
- for (const ch of node.layers || []) {
- const r = find(ch, want, p)
- if (r) return r
- }
- return null
- }
- function dump(node, depth = 0, path = '') {
- const p = path ? `${path}/${node.name}` : node.name
- const pad = ' '.repeat(depth)
- const paths = node.paths || []
- const fills = (node.style?.fills || []).map((f) => f.type).join('+')
- const shapeCount = paths.reduce((n, x) => n + (x.paths || x.subPaths || []).length, 0)
- console.log(`${pad}${node.type}:${node.name} ${Math.round(node.frame?.width ?? 0)}x${Math.round(node.frame?.height ?? 0)} paths=${paths.length} shapes=${shapeCount} fills=${fills} export=${!!node.hasExportImage}`)
- for (const ch of (node.layers || []).slice(0, 14)) dump(ch, depth + 1, p)
- }
- const chip = find(ab, 'Chip')
- const title = find(ab, 'title')
- if (chip) {
- console.log('=== Chip node:', chip.path)
- dump(chip.node)
- }
- if (title) {
- console.log('\n=== title node:', title.path)
- dump(title.node)
- }
|