// 定位「默认带入当前商机团队」所在字段的路径 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)); const needle = '默认带入当前商机团队'; const hits = []; function find(obj, path) { if (obj === null || typeof obj !== 'object') return; if (Array.isArray(obj)) { obj.forEach((v, i) => find(v, `${path}[${i}]`)); return; } for (const [k, v] of Object.entries(obj)) { if (typeof v === 'string' && v.includes(needle)) hits.push({ path: `${path}.${k}`, val: v.slice(0, 300) }); else if (v && typeof v === 'object') find(v, `${path}.${k}`); } } find(data, '$'); for (const h of hits) console.log(h.path, '\n →', h.val, '\n'); // 顺带统计所有「值像正文」的字符串键分布 const keyStats = {}; function stat(obj) { if (obj === null || typeof obj !== 'object') return; if (Array.isArray(obj)) { obj.forEach(stat); return; } for (const [k, v] of Object.entries(obj)) { if (typeof v === 'string' && /[\u4e00-\u9fa5]{2,}/.test(v) && !v.startsWith('images/')) { keyStats[k] = (keyStats[k] || 0) + 1; } else if (v && typeof v === 'object') stat(v); } } stat(data); console.log('中文值键分布:', JSON.stringify(keyStats, null, 2));