Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
guyutongxue committed Jan 1, 2025
1 parent 74e5a5b commit 610d70b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
43 changes: 20 additions & 23 deletions src/node/generate_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any[]> = {};
const downloaded: Record<string, any[]> = {};

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"];
4 changes: 1 addition & 3 deletions src/node/generate_images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -18,8 +18,6 @@ if (typeof input === "undefined") {
process.exit(1);
}

const { actionCards, characters, entities, keywords } = await generateData();

// 将原始提取素材的图片分组,找到每组中的最大文件(最高分辨率)路径

const allImagePaths: Record<string, string> = {};
Expand Down

0 comments on commit 610d70b

Please sign in to comment.