mirror of
https://git.suyu.dev/suyu/website.git
synced 2025-12-24 16:24:35 +01:00
Fix downloading
This commit is contained in:
parent
a4d42a5251
commit
5d4d09c544
2 changed files with 76 additions and 19 deletions
|
|
@ -20,7 +20,9 @@ async function fetchLatestReleaseTag() {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export const load = (async () => {
|
||||
let latestReleaseTag = await fetchLatestReleaseTag();
|
||||
console.log(latestReleaseTag)
|
||||
return latestReleaseTag //? { body: latestReleaseTag } : { status: 404 };
|
||||
})
|
||||
|
|
@ -1,22 +1,49 @@
|
|||
<script>
|
||||
import { load } from "../api/fetchtag/+server";
|
||||
function downloadSuyu() {
|
||||
let UA = navigator.userAgent;
|
||||
let latestRelease = load();
|
||||
console.log(latestRelease)
|
||||
if (UA.includes("Windows")) {
|
||||
window.location.href = `https://gitlab.com/suyu-emu/suyu-releases/-/blob/master/${latestRelease}/Suyu-Windows_x64.7z`;
|
||||
} else if (UA.includes("Linux")) {
|
||||
window.location.href = `https://gitlab.com/suyu-emu/suyu-releases/-/blob/master/${latestRelease}/suyu-mainline--.AppImage`;
|
||||
} else if (UA.includes("Macintosh")) {
|
||||
window.location.href = `https://gitlab.com/suyu-emu/suyu-releases/-/blob/master/${latestRelease}/suyu-macOS-arm64.dmg`;
|
||||
} else {
|
||||
window.location.href = `https://gitlab.com/suyu-emu/suyu-releases/-/blob/master/${latestRelease}/`;
|
||||
}
|
||||
}
|
||||
downloadSuyu();
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
// Note: This is an absolutely terrible and unoptimized way to do this. Feel free to change it xd
|
||||
onMount(async () => {
|
||||
const UA = navigator.userAgent;
|
||||
const url = `https://gitlab.com/api/v4/projects/55558123/releases`; // 55558123 = Suyu repo ID
|
||||
async function getTag() {
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
// Convert to JSON
|
||||
const releases = await response.json();
|
||||
|
||||
// Release found
|
||||
if (releases && releases.length > 0) {
|
||||
console.log("Latest release tag:", releases[0].tag_name);
|
||||
return releases[0].tag_name; // Assuming the first result is the latest
|
||||
} else {
|
||||
console.log("No releases found.");
|
||||
return null;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error fetching latest release tag:", error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
const latestRelease = await getTag();
|
||||
// give it time so the user can see the message
|
||||
setTimeout(() => {
|
||||
if (UA.includes("Windows")) {
|
||||
window.location.href = `https://gitlab.com/suyu-emu/suyu-releases/-/raw/master/${latestRelease}/Suyu-Windows_x64.7z`;
|
||||
} else if (UA.includes("Linux")) {
|
||||
window.location.href = `https://gitlab.com/suyu-emu/suyu-releases/-/raw/master/${latestRelease}/suyu-mainline--.AppImage`;
|
||||
} else if (UA.includes("Macintosh;")) {
|
||||
window.location.href = `https://gitlab.com/suyu-emu/suyu-releases/-/raw/master/${latestRelease}/suyu-macOS-arm64.dmg?inline=false`;
|
||||
} else {
|
||||
window.location.href = `https://gitlab.com/suyu-emu/suyu-releases/-/blob/master/${latestRelease}/`;
|
||||
}
|
||||
}, 3000);
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
<svelte:head>
|
||||
<title>Downloading Suyu</title>
|
||||
</svelte:head>
|
||||
|
|
@ -42,8 +69,36 @@
|
|||
stroke="white"
|
||||
/>
|
||||
</svg>
|
||||
<h1 class="text-[24px] leading-[1.41] md:text-[60px] md:leading-[1.1]">Downloading Suyu..</h1>
|
||||
<script>
|
||||
onMount(() => {
|
||||
let text = "Downloading Suyu";
|
||||
let interval = setInterval(() => {
|
||||
text += ".";
|
||||
if (text.length > 16) {
|
||||
text = "Downloading Suyu";
|
||||
}
|
||||
$text = text;
|
||||
}, 500);
|
||||
$: clearInterval(interval);
|
||||
});
|
||||
</script>
|
||||
<!-- TODO: Have the 3 dots loop (e.g . -> .. -> ...) -->
|
||||
<h1 class="text-[24px] leading-[1.41] md:text-[60px] md:leading-[1.1]">
|
||||
Downloading Suyu...
|
||||
</h1>
|
||||
<!-- <h1 class="text-[24px] leading-[1.41] md:text-[60px] md:leading-[1.1]">
|
||||
{#if $text}
|
||||
{$text}
|
||||
{:else}
|
||||
Downloading Suyu
|
||||
{/if}
|
||||
</h1> -->
|
||||
|
||||
|
||||
|
||||
<p class="max-w-[36rem] text-lg leading-relaxed text-[#A6A5A7]">
|
||||
Your download should start shortly. If it doesn't, click <a href="https://gitlab.com/suyu-emu/suyu/-/releases">here</a>.
|
||||
Your download should start shortly. If it doesn't, click <a
|
||||
href="https://gitlab.com/suyu-emu/suyu/-/releases">here</a
|
||||
>.
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue