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.
32 lines
1.5 KiB
32 lines
1.5 KiB
// 提取团队页全部正文文本(label/description/displayName/placeholderText/表格单元格)
|
|
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 out = [];
|
|
function walk(obj, path) {
|
|
if (obj === null || typeof obj !== 'object') return;
|
|
if (Array.isArray(obj)) { obj.forEach((v, i) => walk(v, `${path}[${i}]`)); return; }
|
|
for (const [k, v] of Object.entries(obj)) {
|
|
if (typeof v === 'string' && (k === 'label' || k === 'description' || k === 'displayName' || k === 'placeholderText' || k === 'name' || k === '')
|
|
&& v.trim() && /[\u4e00-\u9fa5A-Za-z0-9]/.test(v) && !v.startsWith('images/') && !/^'?.*(sans-serif|Arial|微软)/.test(v)) {
|
|
out.push(`[${k}] ${v.trim().slice(0, 200)}`);
|
|
} else if (v && typeof v === 'object') walk(v, `${path}.${k}`);
|
|
}
|
|
}
|
|
walk(data.page, 'page');
|
|
walk(data.masters, 'masters');
|
|
const uniq = [...new Set(out)];
|
|
console.log(`total=${out.length} unique=${uniq.length}`);
|
|
uniq.forEach((l, i) => console.log(String(i + 1).padStart(3), l));
|
|
|