probe-v2-geometry.mjs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // 票 15 取证(六):主画板几何(顶栏 / 筛选条 / 面板 / 栏宽 / 内边距)
  2. import { readFileSync } from 'node:fs'
  3. const dir = '.scratch/lanhu-cockpit-asset-replacement/research/raw-v2'
  4. const load = (n) => JSON.parse(readFileSync(`${dir}/desktop-${String(n).padStart(2, '0')}.json`, 'utf8')).artboard
  5. for (const n of [6, 2, 5]) {
  6. const ab = load(n)
  7. console.log(`\n########## ${ab.name} ${ab.frame.width}x${ab.frame.height}`)
  8. for (const l of ab.layers || []) {
  9. console.log(` 顶层 ${l.type}:${l.name} @(${Math.round(l.frame.left)},${Math.round(l.frame.top)}) ${Math.round(l.frame.width)}x${Math.round(l.frame.height)}`)
  10. }
  11. // nav 及其子项
  12. const nav = (ab.layers || []).find((l) => l.name === 'nav')
  13. if (nav) {
  14. console.log(' nav 子项:')
  15. for (const c of nav.layers || []) console.log(` ${c.type}:${c.name} @(${Math.round(c.frame.left)},${Math.round(c.frame.top)}) ${Math.round(c.frame.width)}x${Math.round(c.frame.height)}`)
  16. }
  17. // 面板几何:Panel 节点的位置、尺寸与内部 Header 高度、内边距
  18. const panels = []
  19. ;(function walk(node) {
  20. if (/^Panel$/.test(node.name) && node.frame?.width >= 300) panels.push(node)
  21. for (const c of node.layers || []) walk(c)
  22. })(ab)
  23. for (const p of panels.slice(0, 4)) {
  24. const header = (p.layers || []).find((c) => /Header/.test(c.name))
  25. const container = (p.layers || []).find((c) => /Container/.test(c.name))
  26. console.log(
  27. ` Panel @(${Math.round(p.frame.left)},${Math.round(p.frame.top)}) ${Math.round(p.frame.width)}x${Math.round(p.frame.height)}` +
  28. ` | Header ${header ? `${Math.round(header.frame.width)}x${Math.round(header.frame.height)}` : '-'}` +
  29. ` | Container ${container ? `${Math.round(container.frame.left - p.frame.left)},${Math.round(container.frame.top - p.frame.top)} ${Math.round(container.frame.width)}x${Math.round(container.frame.height)}` : '-'}`,
  30. )
  31. }
  32. // 栏:面板按 left 值分组,看栏宽与栏间距
  33. const xs = [...new Set(panels.map((p) => Math.round(p.frame.left)))].sort((a, b) => a - b)
  34. console.log(` Panel left 取值: ${xs.join(', ')}`)
  35. }