You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.7 KiB
63 lines
2.7 KiB
|
7 days ago
|
// 1. 完整打印 table[0] 对象结构(所有 key 的值预览)
|
||
|
|
// 2. network-log-v2.json 全部 /api/ 请求列表
|
||
|
|
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));
|
||
|
|
|
||
|
|
function findAll(obj, type, acc) {
|
||
|
|
if (obj === null || typeof obj !== 'object') return;
|
||
|
|
if (Array.isArray(obj)) { obj.forEach(v => findAll(v, type, acc)); return; }
|
||
|
|
if (obj.type === type) acc.push(obj);
|
||
|
|
for (const v of Object.values(obj)) if (v && typeof v === 'object') findAll(v, type, acc);
|
||
|
|
}
|
||
|
|
const tables = [];
|
||
|
|
findAll(data.page, 'table', tables);
|
||
|
|
const mTables = [];
|
||
|
|
findAll(data.masters || {}, 'table', mTables);
|
||
|
|
console.log('page tables:', tables.length, '| master tables:', mTables.length);
|
||
|
|
|
||
|
|
// 完整看第一个 table(截断每个值)
|
||
|
|
function preview(v) {
|
||
|
|
const s = typeof v === 'string' ? v : JSON.stringify(v);
|
||
|
|
return s.length > 150 ? s.slice(0, 150) + `…(len=${s.length})` : s;
|
||
|
|
}
|
||
|
|
const show = (t, idx, tag) => {
|
||
|
|
console.log(`\n=== ${tag} table[${idx}] ===`);
|
||
|
|
for (const [k, v] of Object.entries(t)) {
|
||
|
|
if (k === 'objects' && Array.isArray(v)) {
|
||
|
|
console.log(` objects: array(${v.length})`);
|
||
|
|
} else {
|
||
|
|
console.log(` ${k}: ${preview(v)}`);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (Array.isArray(t.objects)) {
|
||
|
|
// 找 label 非空的 cell
|
||
|
|
const nonEmpty = t.objects.filter(c => c.label && c.label.trim());
|
||
|
|
console.log(` → label 非空的 cell: ${nonEmpty.length}/${t.objects.length}`);
|
||
|
|
nonEmpty.slice(0, 10).forEach(c => console.log(` [${c.id}] label="${c.label}"`));
|
||
|
|
// cell[0] 的完整 key-value
|
||
|
|
console.log(' → cell[0] 完整结构:');
|
||
|
|
for (const [k, v] of Object.entries(t.objects[0])) console.log(` ${k}: ${preview(v)}`);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
tables.forEach((t, i) => show(t, i, 'page'));
|
||
|
|
mTables.forEach((t, i) => show(t, i, 'master'));
|
||
|
|
|
||
|
|
// network log 全部 API
|
||
|
|
console.log('\n\n=== network-log-v2.json 全部请求 URL ===');
|
||
|
|
const log = JSON.parse(fs.readFileSync('e:/code/crm-backend-matt/.scratch/lanhu-latest/network-log-v2.json', 'utf8'));
|
||
|
|
const arr = Array.isArray(log) ? log : (log.requests || log.entries || []);
|
||
|
|
const urls = [...new Set(arr.map(e => (e.url || (e.request && e.request.url) || '').split('?')[0]).filter(Boolean))];
|
||
|
|
urls.forEach(u => console.log(' ', u));
|