From dbc4d83b08a7ac7a3f8d747aaa4b12d77d9c9abc Mon Sep 17 00:00:00 2001 From: snowykami Date: Mon, 2 Sep 2024 21:27:28 +0800 Subject: [PATCH] =?UTF-8?q?:memo:=20=E6=96=B0=E5=A2=9Egitea=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/components/scripts/statsApi.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/components/scripts/statsApi.ts b/docs/components/scripts/statsApi.ts index 28f07be0..db4fc2f0 100644 --- a/docs/components/scripts/statsApi.ts +++ b/docs/components/scripts/statsApi.ts @@ -83,6 +83,20 @@ async function getGithubStats() { } } +async function getRepoStats() { + // 两个接口各数据,哪个大取哪个 + const githubStats = await getGithubStats(); + const giteaStats = await getGiteaStats(); + return { + stars: Math.max(githubStats.stars, giteaStats.stars), + forks: Math.max(githubStats.forks, giteaStats.forks), + watchers: Math.max(githubStats.watchers, giteaStats.watchers), + issues: Math.max(githubStats.issues, giteaStats.issues), + prs: Math.max(githubStats.prs, giteaStats.prs), + size: Math.max(githubStats.size, giteaStats.size), + }; +} + // 实现接口 export const statsApi: StatsApi = { getTotal: async () => { @@ -103,7 +117,7 @@ export const statsApi: StatsApi = { return -1; } }, - getGithubStats: getGiteaStats, + getGithubStats: getRepoStats, getPluginNum: async () => { try { const res = await fetch('/plugins.json');