feat: use Forgejo releases API instead of GitHub
This commit is contained in:
parent
e4da2ef485
commit
37047bd1af
1 changed files with 7 additions and 3 deletions
|
|
@ -47,8 +47,12 @@ export const useVersionCheck = (owner: string, repo: string) => {
|
|||
useEffect(() => {
|
||||
const checkVersion = async () => {
|
||||
try {
|
||||
const response = await fetch(`https://api.github.com/repos/${owner}/${repo}/releases/latest`);
|
||||
const data = await response.json();
|
||||
const baseUrl = import.meta.env.VITE_FORGEJO_BASE_URL || 'https://forge.wilddragon.net';
|
||||
const response = await fetch(`${baseUrl}/api/v1/repos/${owner}/${repo}/releases?limit=1&page=1`);
|
||||
if (!response.ok) return;
|
||||
const releases = await response.json();
|
||||
const data = releases[0];
|
||||
if (!data) return;
|
||||
|
||||
// Handle the case where there might not be any releases
|
||||
if (data.tag_name) {
|
||||
|
|
@ -61,7 +65,7 @@ export const useVersionCheck = (owner: string, repo: string) => {
|
|||
setReleaseInfo({
|
||||
title: data.name || data.tag_name,
|
||||
body: data.body || '',
|
||||
htmlUrl: data.html_url || `https://github.com/${owner}/${repo}/releases/latest`,
|
||||
htmlUrl: data.html_url || `${import.meta.env.VITE_FORGEJO_BASE_URL || 'https://forge.wilddragon.net'}/${owner}/${repo}/releases`,
|
||||
publishedAt: data.published_at
|
||||
});
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue