Skip to content

Commit 52886fd

Browse files
committed
减少不必要的请求数
1 parent 45267bd commit 52886fd

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/components/PlayedGames.astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ if (!ENABLE_REQUEST) {
2020
return;
2121
}
2222
const DELAY_MS = 1000;
23-
const appidList = await steamApi.playedGames();
23+
const appidList = (await steamApi.playedGames()).filter((game) => game.playtime_forever > 200);;
24+
let count = 1;
2425
for (const game of appidList) {
26+
console.log(`请求 ${game.appid} 中 ${count++}/${appidList.length}`);
2527
await delay(DELAY_MS);
2628
const gameDetail = await steamApi.appdetails(game.appid);
2729
playedGames.push({
@@ -32,15 +34,14 @@ for (const game of appidList) {
3234
app.appid.toString() == game.appid
3335
)?.name || "",
3436
// imgurl: steamApi.imageUrl(game.appid.toString()),
35-
imgurl: gameDetail[game.appid].data.header_image,
37+
imgurl: gameDetail[game.appid]?.data?.header_image,
3638
});
3739
}
3840
3941
orderGames.forEach((game) => `${import.meta.env.SITE}${game.imgurl}`);
4042
4143
playedGames = playedGames
4244
.concat(orderGames)
43-
.filter((game) => game.playtime_forever > 200)
4445
.sort((a, b) => b.playtime_forever - a.playtime_forever);
4546
---
4647

0 commit comments

Comments
 (0)