mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-11 04:07:23 +08:00
📝 新增gitea数据
This commit is contained in:
parent
7d91079500
commit
da905d21bd
@ -13,55 +13,55 @@ const dataSections = {
|
|||||||
total: {
|
total: {
|
||||||
name: 'total',
|
name: 'total',
|
||||||
color: '#00a6ff',
|
color: '#00a6ff',
|
||||||
value: ref(2005),
|
value: ref(-1),
|
||||||
link: StarMapUrl
|
link: StarMapUrl
|
||||||
},
|
},
|
||||||
online: {
|
online: {
|
||||||
name: 'online',
|
name: 'online',
|
||||||
color: '#7eff7e',
|
color: '#7eff7e',
|
||||||
value: ref(1145),
|
value: ref(-1),
|
||||||
link: StarMapUrl
|
link: StarMapUrl
|
||||||
},
|
},
|
||||||
stars: {
|
stars: {
|
||||||
name: 'stars',
|
name: 'stars',
|
||||||
color: '#ffcc00',
|
color: '#ffcc00',
|
||||||
value: ref(1234),
|
value: ref(-1),
|
||||||
link: `${RepoUrl}/stargazers`
|
link: `${RepoUrl}/stargazers`
|
||||||
},
|
},
|
||||||
forks: {
|
forks: {
|
||||||
name: 'forks',
|
name: 'forks',
|
||||||
color: '#ff6600',
|
color: '#ff6600',
|
||||||
value: ref(9420),
|
value: ref(-1),
|
||||||
link: `${RepoUrl}/forks`
|
link: `${RepoUrl}/forks`
|
||||||
},
|
},
|
||||||
issues: {
|
issues: {
|
||||||
name: 'issues',
|
name: 'issues',
|
||||||
color: '#ff0000',
|
color: '#ff0000',
|
||||||
value: ref(1145),
|
value: ref(-1),
|
||||||
link: `${RepoUrl}/issues`
|
link: `${RepoUrl}/issues`
|
||||||
},
|
},
|
||||||
prs: {
|
prs: {
|
||||||
name: 'prs',
|
name: 'prs',
|
||||||
color: '#f15df1',
|
color: '#f15df1',
|
||||||
value: ref(6543),
|
value: ref(-1),
|
||||||
link: `${RepoUrl}/pulls`
|
link: `${RepoUrl}/pulls`
|
||||||
},
|
},
|
||||||
plugins: {
|
plugins: {
|
||||||
name: 'plugins',
|
name: 'plugins',
|
||||||
color: '#a766ff',
|
color: '#a766ff',
|
||||||
value: ref(1763),
|
value: ref(-1),
|
||||||
link: './store/plugin'
|
link: './store/plugin'
|
||||||
},
|
},
|
||||||
resources: {
|
resources: {
|
||||||
name: 'resources',
|
name: 'resources',
|
||||||
color: '#5a54fa',
|
color: '#5a54fa',
|
||||||
value: ref(6789),
|
value: ref(-1),
|
||||||
link: './store/resource'
|
link: './store/resource'
|
||||||
},
|
},
|
||||||
visitors: {
|
visitors: {
|
||||||
name: 'visitors',
|
name: 'visitors',
|
||||||
color: '#00a6ff',
|
color: '#00a6ff',
|
||||||
value: ref(1234),
|
value: ref(-1),
|
||||||
link: RepoUrl
|
link: RepoUrl
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ const i18nData = {
|
|||||||
offline: '离线',
|
offline: '离线',
|
||||||
total: '实例',
|
total: '实例',
|
||||||
fetching: '获取中',
|
fetching: '获取中',
|
||||||
stars: '星星',
|
stars: '获星',
|
||||||
forks: '叉子',
|
forks: '分叉',
|
||||||
issues: '开启议题',
|
issues: '开启议题',
|
||||||
prs: '合并请求',
|
prs: '合并请求',
|
||||||
visitors: '访客',
|
visitors: '访客',
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
export const OWNER = "LiteyukiStudio"
|
export const OWNER = "LiteyukiStudio"
|
||||||
export const REPO = "LiteyukiBot"
|
export const REPO = "LiteyukiBot"
|
||||||
const githubAPIUrl = "https://api.github.com"
|
const githubAPIUrl = "https://api.github.com"
|
||||||
|
const giteaAPIUrl = "https://git.liteyuki.icu/api/v1"
|
||||||
const onlineFetchUrl = "https://api.liteyuki.icu/online";
|
const onlineFetchUrl = "https://api.liteyuki.icu/online";
|
||||||
const totalFetchUrl = "https://api.liteyuki.icu/count";
|
const totalFetchUrl = "https://api.liteyuki.icu/count";
|
||||||
const visitRecordUrl = "https://api.liteyuki.icu/visit";
|
const visitRecordUrl = "https://api.liteyuki.icu/visit";
|
||||||
@ -32,28 +33,34 @@ interface StatsApi {
|
|||||||
|
|
||||||
export type {GithubStats};
|
export type {GithubStats};
|
||||||
|
|
||||||
// 实现接口
|
async function getGiteaStats() {
|
||||||
export const statsApi: StatsApi = {
|
try {
|
||||||
getTotal: async () => {
|
const url = `${giteaAPIUrl}/repos/${OWNER}/${REPO}`;
|
||||||
try {
|
console.log(url);
|
||||||
const res = await fetch(totalFetchUrl);
|
const res = await fetch(url);
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
return data.register;
|
return {
|
||||||
} catch (e) {
|
stars: data.stars_count,
|
||||||
return -1;
|
forks: data.forks_count,
|
||||||
}
|
watchers: data.watchers_count,
|
||||||
},
|
issues: 0,
|
||||||
getOnline: async () => {
|
prs: 0,
|
||||||
try {
|
size: data.size,
|
||||||
const res = await fetch(onlineFetchUrl);
|
};
|
||||||
const data = await res.json();
|
} catch (e) {
|
||||||
return data.online;
|
return {
|
||||||
} catch (e) {
|
stars: -1,
|
||||||
return -1;
|
forks: -1,
|
||||||
}
|
watchers: -1,
|
||||||
},
|
issues: -1,
|
||||||
getGithubStats: async () => {
|
prs: -1,
|
||||||
try {
|
size: -1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getGithubStats() {
|
||||||
|
try {
|
||||||
const res = await fetch(`${githubAPIUrl}/repos/${OWNER}/${REPO}`);
|
const res = await fetch(`${githubAPIUrl}/repos/${OWNER}/${REPO}`);
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
return {
|
return {
|
||||||
@ -74,7 +81,29 @@ export const statsApi: StatsApi = {
|
|||||||
size: -1,
|
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 () => {
|
getPluginNum: async () => {
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/plugins.json');
|
const res = await fetch('/plugins.json');
|
||||||
|
Loading…
Reference in New Issue
Block a user