// 检查 table / tableCell 对象结构 import fs from 'node:fs'; const raw = fs.readFileSync('e:/code/crm-backend-matt/.scratch/lanhu-latest/team-page-data.js', 'utf8'); const start = raw.indexOf('{'); let depth = 0, end = -1, inStr = false, esc = false; for (let i = start; i < raw.length; i++) { const c = raw[i]; if (esc) { esc = false; continue; } if (c === '\\') { esc = true; continue; } if (c === '"') inStr = !inStr; if (inStr) continue; if (c === '{') depth++; else if (c === '}') { depth--; if (depth === 0) { end = i; break; } } } const data = JSON.parse(raw.slice(start, end + 1)); // 找 table 对象 function findAll(obj, type, acc, path) { if (obj === null || typeof obj !== 'object') return; if (Array.isArray(obj)) { obj.forEach((v, i) => findAll(v, type, acc, path)); return; } if (obj.type === type) acc.push({ obj, path }); for (const [k, v] of Object.entries(obj)) if (v && typeof v === 'object') findAll(v, type, acc, `${path}.${k}`); } const tables = []; findAll(data.page, 'table', tables, 'page'); console.log('tables found:', tables.length); if (tables.length) { const t = tables[0].obj; console.log('table keys:', Object.keys(t).join(',')); if (t.objects) { console.log('cell count:', t.objects.length); const c = t.objects[0]; console.log('cell[0] keys:', Object.keys(c).join(',')); console.log('cell[0] JSON:', JSON.stringify(c, null, 2).slice(0, 2500)); // 全部单元格的 label t.objects.forEach((cc, i) => { const txt = cc.label || cc.text || (cc.style && cc.style.text) || ''; console.log(`cell[${i}] label=${JSON.stringify(cc.label).slice(0, 80)} keys=${Object.keys(cc).join('|')}`); }); } } // 也看 masters(母版里的 table) for (const [mid, m] of Object.entries(data.masters || {})) { const mt = []; findAll(m, 'table', mt, `masters.${mid}`); if (mt.length) console.log(`master ${mid}: ${mt.length} tables`); }