From 610d70b87a25f3ba7c8af6e49d60732f5db55665 Mon Sep 17 00:00:00 2001 From: Guyutongxue Date: Wed, 1 Jan 2025 15:09:15 +0800 Subject: [PATCH] fix --- src/node/generate_data.ts | 43 +++++++++++++++++-------------------- src/node/generate_images.ts | 4 +--- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/node/generate_data.ts b/src/node/generate_data.ts index 26f5390..73730bc 100644 --- a/src/node/generate_data.ts +++ b/src/node/generate_data.ts @@ -6,31 +6,28 @@ import type { } from "@gi-tcg/static-data"; import { outputDir } from "./config"; -export async function generateData() { - // 从 github 获取最新的数据 +// 从 github 获取最新的数据 - const GITHUB_CONTENT_BASE = `https://raw.githubusercontent.com/genius-invokation/genius-invokation/refs/heads/main/packages/static-data/src/data`; +const GITHUB_CONTENT_BASE = `https://raw.githubusercontent.com/genius-invokation/genius-invokation/refs/heads/main/packages/static-data/src/data`; - const FILENAMES = [ - "action_cards.json", - "characters.json", - "entities.json", - "keywords.json", - ]; +const FILENAMES = [ + "action_cards.json", + "characters.json", + "entities.json", + "keywords.json", +]; - const downloaded: Record = {}; +const downloaded: Record = {}; - for (const filename of FILENAMES) { - const data = await fetch(`${GITHUB_CONTENT_BASE}/${filename}`).then((r) => - r.text(), - ); - downloaded[filename] = JSON.parse(data); - await Bun.write(`${outputDir}/${filename}`, data); - } - - const actionCards: ActionCardRawData[] = downloaded["action_cards.json"]; - const characters: CharacterRawData[] = downloaded["characters.json"]; - const entities: EntityRawData[] = downloaded["entities.json"]; - const keywords: KeywordRawData[] = downloaded["keywords.json"]; - return { actionCards, characters, entities, keywords }; +for (const filename of FILENAMES) { + const data = await fetch(`${GITHUB_CONTENT_BASE}/${filename}`).then((r) => + r.text(), + ); + downloaded[filename] = JSON.parse(data); + await Bun.write(`${outputDir}/${filename}`, data); } + +export const actionCards: ActionCardRawData[] = downloaded["action_cards.json"]; +export const characters: CharacterRawData[] = downloaded["characters.json"]; +export const entities: EntityRawData[] = downloaded["entities.json"]; +export const keywords: KeywordRawData[] = downloaded["keywords.json"]; diff --git a/src/node/generate_images.ts b/src/node/generate_images.ts index 5c78aff..81b87fd 100644 --- a/src/node/generate_images.ts +++ b/src/node/generate_images.ts @@ -4,7 +4,7 @@ import { readdir } from "node:fs/promises"; import path from "node:path"; import { statSync } from "node:fs"; import { imageDir, outputDir } from "./config"; -import { generateData } from "./generate_data"; +import { actionCards, characters, entities, keywords } from "./generate_data"; const { positionals: [input], @@ -18,8 +18,6 @@ if (typeof input === "undefined") { process.exit(1); } -const { actionCards, characters, entities, keywords } = await generateData(); - // 将原始提取素材的图片分组,找到每组中的最大文件(最高分辨率)路径 const allImagePaths: Record = {};