📝 新增gitea数据

This commit is contained in:
远野千束 2024-09-02 21:27:28 +08:00
parent da905d21bd
commit dbc4d83b08

View File

@ -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 = { export const statsApi: StatsApi = {
getTotal: async () => { getTotal: async () => {
@ -103,7 +117,7 @@ export const statsApi: StatsApi = {
return -1; return -1;
} }
}, },
getGithubStats: getGiteaStats, getGithubStats: getRepoStats,
getPluginNum: async () => { getPluginNum: async () => {
try { try {
const res = await fetch('/plugins.json'); const res = await fetch('/plugins.json');