Skip to content

Commit

Permalink
🚨 修复 qodana 报错
Browse files Browse the repository at this point in the history
  • Loading branch information
BTMuli committed Dec 17, 2023
1 parent 02ce344 commit 497f6cd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/components/character/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ for (const item of amberJson) {
Counter.Fail();
continue;
}
await sharp(res.data).toFile(savePath);
await sharp(<ArrayBuffer>res.data).toFile(savePath);
logger.console.info(
`[components][character][download] ${item.id} ${item.name}·${element} Icon 下载完成`,
);
Expand Down
4 changes: 2 additions & 2 deletions core/components/gcg/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ for (const item of amberJson) {
Counter.Fail();
continue;
}
await sharp(res.data).toFile(savePath);
await sharp(<ArrayBuffer>res.data).toFile(savePath);
logger.console.info(`[components][gcg][download] ${item.name} 图片下载完成`);
Counter.Success();
}
Expand Down Expand Up @@ -129,7 +129,7 @@ for (const item of monsterData) {
Counter.Fail();
continue;
}
await sharp(res.data).toFile(savePath);
await sharp(<ArrayBuffer>res.data).toFile(savePath);
logger.console.info(`[components][gcg][download] ${item.title} 图片下载完成`);
Counter.Success();
}
Expand Down
10 changes: 7 additions & 3 deletions core/components/namecard/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ let nameCardsData: TGACore.Components.Namecard.RawData[] = [];
try {
const jsonRead = fs.readJSONSync(path.join(jsonDir.src, "namecard.json"), "utf-8");
if (Array.isArray(jsonRead)) {
nameCardsData = jsonRead.filter((item) => Object.values(item).every((value) => value !== ""));
nameCardsData = jsonRead.filter((item) =>
Object.values(<TGACore.Components.Namecard.RawData>item).every((value) => value !== ""),
);
}
} catch (err) {
logger.default.error("[components][namecard][download] 获取原始数据失败,请检查 JSON 文件");
Expand Down Expand Up @@ -167,7 +169,9 @@ async function downloadImg(
Counter.Fail();
return;
}
await sharp(res.data).webp().toFile(savePath);
await sharp(<ArrayBuffer>res.data)
.webp()
.toFile(savePath);
logger.console.mark(
`[components][namecard][download] 第 ${indexStr} 张名片 ${imgType} 下载成功`,
);
Expand Down Expand Up @@ -208,7 +212,7 @@ async function getNameCardData(
const html = await axios.get(url, { params: { lang: "CHS" } });
const tbSelector =
"body > div.wp-site-blocks > div.wp-block-columns > div:nth-child(3) > div.entry-content.wp-block-post-content > table";
const htmlDom = load(html.data);
const htmlDom = load(<string>html.data);
const trsGet = htmlDom(tbSelector).find("tr");
const namecard: TGACore.Components.Namecard.RawData = {
index,
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"*.json",
"config/**/*",
"core/**/*",
"scripts/*.ts",
"test/**.test.ts",
"vitest.config.ts",
"web/**/*.ts"
Expand Down

0 comments on commit 497f6cd

Please sign in to comment.