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.
 
 
 
 
 

47 lines
2.4 KiB

// 从 network-log-v2.json 提取 /api/project/image 的请求参数与响应关键字段(写入研究文档用)
import fs from 'node:fs';
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 || []);
for (const e of arr) {
const url = e.url || (e.request && e.request.url) || '';
if (!url.includes('/api/project/image?')) continue;
console.log('=== REQUEST ===');
console.log('url:', url);
const body = e.responseBody || e.body || (e.response && e.response.body) || e.text || '';
if (typeof body === 'string' && body.length) {
try {
const j = JSON.parse(body);
// 打印顶层结构
const out = { topLevelKeys: Object.keys(j) };
if (j.data) out.dataKeys = Object.keys(j.data);
console.log('response shape:', JSON.stringify(out));
// 找 json_url 与版本
const s = JSON.stringify(j);
const jsonUrls = [...new Set((s.match(/https?:[^"]*?\.json/g) || []).map(u => u.replace(/\\u0026/g, '&')))];
console.log('json urls found:', jsonUrls.length);
jsonUrls.forEach(u => console.log(' ', u));
// 版本历史摘要
if (j.data && j.data.versions) console.log('versions:', j.data.versions.length, 'first:', JSON.stringify(j.data.versions[0]).slice(0, 300));
if (j.data && j.data.histories) console.log('histories:', j.data.histories.length, 'first:', JSON.stringify(j.data.histories[0]).slice(0, 300));
} catch (err) {
console.log('body not JSON, len:', body.length, 'head:', body.slice(0, 200));
}
} else {
console.log('no body captured. entry keys:', Object.keys(e).join(','));
}
break;
}
// 项目里的 6 个文档清单(来自之前嗅探的响应,从 log 里再捞一次 multi_info/product_documents)
for (const e of arr) {
const url = e.url || (e.request && e.request.url) || '';
if (url.includes('/api/project/product_documents') || url.includes('/api/project/multi_info')) {
const body = e.responseBody || e.body || (e.response && e.response.body) || '';
if (typeof body === 'string' && body.length > 100) {
console.log('\n=== ', url.split('?')[0], '===');
try {
const j = JSON.parse(body);
console.log(JSON.stringify(j).slice(0, 1500));
} catch { console.log('(not json)', body.slice(0, 300)); }
}
}
}