Add support for Android downloads
This commit is contained in:
parent
9da5ac1b00
commit
bdd7b1d134
1 changed files with 85 additions and 87 deletions
|
@ -1,74 +1,76 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
onMount(async () => {
|
||||
const UA = navigator.userAgent;
|
||||
const url = `https://gitlab.com/api/v4/projects/55919530/repository/tree`;
|
||||
async function getTag() {
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
// Convert to JSON
|
||||
let files = await response.json();
|
||||
|
||||
files = files.filter((f) => f.name.startsWith("v") && f.type === "tree");
|
||||
// get the latest release using the version number
|
||||
// thanks, copilot!!
|
||||
const latestRelease = files.reduce((a, b) => {
|
||||
const aVersion = a.name.replace("v", "").split(".");
|
||||
const bVersion = b.name.replace("v", "").split(".");
|
||||
if (aVersion[0] > bVersion[0]) {
|
||||
return a;
|
||||
} else if (aVersion[0] < bVersion[0]) {
|
||||
return b;
|
||||
} else {
|
||||
if (aVersion[1] > bVersion[1]) {
|
||||
return a;
|
||||
} else if (aVersion[1] < bVersion[1]) {
|
||||
return b;
|
||||
} else {
|
||||
if (aVersion[2] > bVersion[2]) {
|
||||
return a;
|
||||
} else if (aVersion[2] < bVersion[2]) {
|
||||
return b;
|
||||
} else {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
import { onMount } from "svelte";
|
||||
onMount(async () => {
|
||||
const UA = navigator.userAgent;
|
||||
const url = `https://gitlab.com/api/v4/projects/55919530/repository/tree`;
|
||||
async function getTag() {
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
// Convert to JSON
|
||||
let files = await response.json();
|
||||
|
||||
// Release found
|
||||
if (latestRelease) {
|
||||
console.log("Latest release tag:", latestRelease.name);
|
||||
return latestRelease.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();
|
||||
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);
|
||||
})
|
||||
files = files.filter((f) => f.name.startsWith("v") && f.type === "tree");
|
||||
// get the latest release using the version number
|
||||
// thanks, copilot!!
|
||||
const latestRelease = files.reduce((a, b) => {
|
||||
// what in the FUCK.. null, i HATE you officially
|
||||
const aVersion = a.name.replace("v", "").split(".");
|
||||
const bVersion = b.name.replace("v", "").split(".");
|
||||
if (aVersion[0] > bVersion[0]) {
|
||||
return a;
|
||||
} else if (aVersion[0] < bVersion[0]) {
|
||||
return b;
|
||||
} else {
|
||||
if (aVersion[1] > bVersion[1]) {
|
||||
return a;
|
||||
} else if (aVersion[1] < bVersion[1]) {
|
||||
return b;
|
||||
} else {
|
||||
if (aVersion[2] > bVersion[2]) {
|
||||
return a;
|
||||
} else if (aVersion[2] < bVersion[2]) {
|
||||
return b;
|
||||
} else {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Release found
|
||||
if (latestRelease) {
|
||||
console.log("Latest release tag:", latestRelease.name);
|
||||
return latestRelease.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();
|
||||
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("Android")) {
|
||||
window.location.href = `https://gitlab.com/suyu-emu/suyu-releases/-/raw/master/${latestRelease}/app-mainline-release.apk`;
|
||||
} 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>
|
||||
|
@ -94,24 +96,22 @@
|
|||
stroke="white"
|
||||
/>
|
||||
</svg>
|
||||
<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]">
|
||||
<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}
|
||||
|
@ -119,8 +119,6 @@
|
|||
{/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.suyu.dev/suyu/suyu/releases">here</a
|
||||
|
|
Loading…
Reference in a new issue