| 123456789101112131415161718192021 |
- import { readFile } from 'node:fs/promises';
- const source = new URL('./lanhu-flash-delivery/analysis.json', import.meta.url);
- const payload = JSON.parse(await readFile(source, 'utf8'));
- for (const design of payload.designs ?? []) {
- const annotations = design.sketch_annotations ?? '';
- const textStart = annotations.indexOf('📝 文本图层:');
- const shapeStart = annotations.indexOf('🔷 形状图层:');
- const textSection = textStart >= 0
- ? annotations.slice(textStart, shapeStart >= 0 ? shapeStart : undefined)
- : '';
- const texts = [...textSection.matchAll(/^ "(.+)"$/gm)].map((match) => match[1]);
- console.log(JSON.stringify({
- name: design.name,
- status: design.status,
- imageBytes: design.image_bytes,
- layoutSource: design.layout_source,
- texts
- }));
- }
|