chore: add inline updater

This commit is contained in:
2025-07-30 20:26:05 +02:00
parent 9b3cb0bd26
commit 084e006f06
8 changed files with 206 additions and 87 deletions

View File

@@ -138,3 +138,17 @@ export const hasOsuWinello = async () => await invoke<boolean>('has_osuwinello')
export const hasNet8 = async () => await invoke<boolean>('has_net8');
export const encryptString = async (str: string, entropy: string) =>
await invoke<string>('encrypt_string', { string: str, entropy });
export const downloadUpdate = async (
url: string,
progressCallback: (file: UpdateStatus) => void
) => {
const downloadStatusListen = await listen('download-progress', (event) =>
progressCallback(event.payload as UpdateStatus)
);
try {
await invoke<string>('download_ezpp_launcher_update', { url });
} finally {
downloadStatusListen();
}
};
export const installUpdate = async () => await invoke('install_ezpp_launcher_update');

View File

@@ -83,6 +83,7 @@
import { osuapi } from '@/api/osuapi';
import {
downloadEZPPLauncherUpdateFiles,
downloadUpdate,
encryptString,
exit,
getBeatmapSetsCount,
@@ -94,6 +95,7 @@
hasNet8,
hasOsuWinello,
hasWMCTRL,
installUpdate,
isOsuCorrupted,
isOsuRunning,
isValidOsuFolder,
@@ -114,6 +116,8 @@
let launchInfo = $state('');
let launchError = $state<Error | undefined>(undefined);
let downloadingUpdate = $state(false);
let selectedGamemode = $derived(
getGamemodeInt(modeIntToStr($preferredMode), typeIntToStr($preferredType))
);
@@ -577,14 +581,45 @@
</div>
</div>
<div class="flex items-center justify-center mb-3">
<Button
onclick={async () => {
if ($newVersion) {
await openURL($newVersion.html_url);
await exit();
}
}}>Update now</Button
>
{#if $platform === 'windows'}
{#if downloadingUpdate}
<div class="flex flex-col items-center justify-center gap-2 p-3 rounded-lg w-full">
<Progress indeterminate={progress === -1} value={progress} />
<span class="text-muted-foreground text-sm mt-4">{launchInfo}</span>
</div>
{:else}
<Button
onclick={async () => {
const updateFile = $newVersion?.assets.find((asset) => asset.name.endsWith('.exe'));
if (!updateFile) {
toast.error('Hmmm...', {
description: 'No update file found.',
});
$newVersion = undefined;
return;
}
downloadingUpdate = true;
launchInfo = 'Downloading Update...';
await downloadUpdate(updateFile.browser_download_url, (file) => {
progress = file.progress;
launchInfo = `Downloading Update (${formatBytes(file.downloaded)}/${formatBytes(file.size)})...`;
});
progress = -1;
launchInfo = 'Update downloaded, installing...';
await installUpdate();
}}>Install Update now</Button
>
{/if}
{:else}
<Button
onclick={async () => {
if ($newVersion) {
await openURL($newVersion.html_url);
await exit();
}
}}>Update now</Button
>
{/if}
</div>
</AlertDialog.Content>
</AlertDialog.Root>