diff --git a/docs/components/StatsBar.vue b/docs/components/StatsBar.vue index 765b47e2..6f731fd5 100644 --- a/docs/components/StatsBar.vue +++ b/docs/components/StatsBar.vue @@ -13,55 +13,55 @@ const dataSections = { total: { name: 'total', color: '#00a6ff', - value: ref(2005), + value: ref(-1), link: StarMapUrl }, online: { name: 'online', color: '#7eff7e', - value: ref(1145), + value: ref(-1), link: StarMapUrl }, stars: { name: 'stars', color: '#ffcc00', - value: ref(1234), + value: ref(-1), link: `${RepoUrl}/stargazers` }, forks: { name: 'forks', color: '#ff6600', - value: ref(9420), + value: ref(-1), link: `${RepoUrl}/forks` }, issues: { name: 'issues', color: '#ff0000', - value: ref(1145), + value: ref(-1), link: `${RepoUrl}/issues` }, prs: { name: 'prs', color: '#f15df1', - value: ref(6543), + value: ref(-1), link: `${RepoUrl}/pulls` }, plugins: { name: 'plugins', color: '#a766ff', - value: ref(1763), + value: ref(-1), link: './store/plugin' }, resources: { name: 'resources', color: '#5a54fa', - value: ref(6789), + value: ref(-1), link: './store/resource' }, visitors: { name: 'visitors', color: '#00a6ff', - value: ref(1234), + value: ref(-1), link: RepoUrl }, } diff --git a/docs/components/scripts/i18n.ts b/docs/components/scripts/i18n.ts index a7d3e0ab..56a5f692 100644 --- a/docs/components/scripts/i18n.ts +++ b/docs/components/scripts/i18n.ts @@ -29,8 +29,8 @@ const i18nData = { offline: '离线', total: '实例', fetching: '获取中', - stars: '星星', - forks: '叉子', + stars: '获星', + forks: '分叉', issues: '开启议题', prs: '合并请求', visitors: '访客', diff --git a/docs/components/scripts/statsApi.ts b/docs/components/scripts/statsApi.ts index 8dea2b5b..28f07be0 100644 --- a/docs/components/scripts/statsApi.ts +++ b/docs/components/scripts/statsApi.ts @@ -2,6 +2,7 @@ export const OWNER = "LiteyukiStudio" export const REPO = "LiteyukiBot" const githubAPIUrl = "https://api.github.com" +const giteaAPIUrl = "https://git.liteyuki.icu/api/v1" const onlineFetchUrl = "https://api.liteyuki.icu/online"; const totalFetchUrl = "https://api.liteyuki.icu/count"; const visitRecordUrl = "https://api.liteyuki.icu/visit"; @@ -32,28 +33,34 @@ interface StatsApi { export type {GithubStats}; -// 实现接口 -export const statsApi: StatsApi = { - getTotal: async () => { - try { - const res = await fetch(totalFetchUrl); - const data = await res.json(); - return data.register; - } catch (e) { - return -1; - } - }, - getOnline: async () => { - try { - const res = await fetch(onlineFetchUrl); - const data = await res.json(); - return data.online; - } catch (e) { - return -1; - } - }, - getGithubStats: async () => { - try { +async function getGiteaStats() { + try { + const url = `${giteaAPIUrl}/repos/${OWNER}/${REPO}`; + console.log(url); + const res = await fetch(url); + const data = await res.json(); + return { + stars: data.stars_count, + forks: data.forks_count, + watchers: data.watchers_count, + issues: 0, + prs: 0, + size: data.size, + }; + } catch (e) { + return { + stars: -1, + forks: -1, + watchers: -1, + issues: -1, + prs: -1, + size: -1, + }; + } +} + +async function getGithubStats() { + try { const res = await fetch(`${githubAPIUrl}/repos/${OWNER}/${REPO}`); const data = await res.json(); return { @@ -74,7 +81,29 @@ export const statsApi: StatsApi = { size: -1, }; } +} + +// 实现接口 +export const statsApi: StatsApi = { + getTotal: async () => { + try { + const res = await fetch(totalFetchUrl); + const data = await res.json(); + return data.register; + } catch (e) { + return -1; + } }, + getOnline: async () => { + try { + const res = await fetch(onlineFetchUrl); + const data = await res.json(); + return data.online; + } catch (e) { + return -1; + } + }, + getGithubStats: getGiteaStats, getPluginNum: async () => { try { const res = await fetch('/plugins.json');