修改功能

This commit is contained in:
fengjignqi
2026-11-14 09:42:57 +08:00
parent dae233e651
commit 673eb7e59c
139 changed files with 9742 additions and 6235 deletions

View File

@@ -0,0 +1,23 @@
import { readFile, writeFile } from 'node:fs/promises';
const credentials = JSON.parse(await readFile('C:/Users/Admin/.config/lanhu-design/credentials.json', 'utf8'));
process.env.LANHU_COOKIE = credentials.credential.value;
const { getDesignSchema } = await import('file:///C:/Users/Admin/.codex/skills/lanhu-design/scripts/lanhu-client.mjs');
const url = 'https://lanhuapp.com/web/#/item/project/stage?pid=f72a7b3f-fb7d-4c6c-bcb0-a68da4c0ed3b&tid=f0e0b575-2d65-4ac8-9464-1cd44e56810f';
for (const index of [20, 3]) {
const { sketchData } = await getDesignSchema(url, String(index));
await writeFile(`.lanhu/shop_${index}_raw.json`, JSON.stringify(sketchData), 'utf8');
const photos = [];
function walk(value, path = '') {
if (!value || typeof value !== 'object') return;
if (value.name && (value.fills || value.image || value.images)) {
photos.push({ name: value.name, frame: value.frame, rect: value.rect, fills: value.fills, image: value.image, images: value.images });
}
for (const [key, child] of Object.entries(value)) {
if (child && typeof child === 'object') walk(child, path + '/' + key);
}
}
walk(sketchData);
await writeFile(`.lanhu/shop_${index}_photos.json`, JSON.stringify(photos, null, 2), 'utf8');
console.log(JSON.stringify({ index, photoLayers: photos.length }));
}