修改功能
This commit is contained in:
23
.lanhu/fetch_shop_artwork.mjs
Normal file
23
.lanhu/fetch_shop_artwork.mjs
Normal 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 }));
|
||||
}
|
||||
Reference in New Issue
Block a user