fetch and pass uninstall info

This commit is contained in:
llama 2025-10-24 19:44:41 +08:00
parent 6b82e84b7b
commit 0c66df1dc3
No known key found for this signature in database
GPG key ID: 0B7543854B9413C3
2 changed files with 12 additions and 8 deletions

View file

@ -17,7 +17,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import ErrorState from "./ErrorState.svelte";
import Normal from "./Normal.svelte";
import Uninstall from "./Uninstall.svelte";
import { launcherOsUnsupported } from "@generated/ftl";
const { data }: PageProps = $props();
@ -25,6 +24,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
let selectedLang = $state(data.userLocale);
let flow = $state(data.state);
let mirrors = $state(data.mirrors);
let uninstallInfo = data.uninstallInfo;
async function onLangChange(lang: string) {
await setLang({ val: lang });
@ -46,16 +46,18 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
let footer: any = $state(null);
const uninstall = () => {
flow.case = "uninstall";
};
const uninstall = uninstallInfo.ankiProgramFilesExists
? () => {
flow.case = "uninstall";
}
: null;
</script>
<Start bind:selectedLang {langs} {footer}>
{#if flow.case === "normal"}
<Normal {mirrors} options={flow.value.options!} {uninstall} bind:footer />
{:else if flow.case === "uninstall"}
<Uninstall bind:footer />
<Uninstall {uninstallInfo} bind:footer />
{:else if flow.case === "osUnsupported"}
<ErrorState
title={$tr.launcherOsUnsupported()}

View file

@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import { getLangs, getMirrors, getState } from "@generated/backend-launcher";
import { getLangs, getMirrors, getState, getUninstallInfo } from "@generated/backend-launcher";
import { ModuleName, setupI18n } from "@tslib/i18n";
import type { PageLoad } from "./$types";
@ -10,13 +10,15 @@ export const load = (async () => {
const langsPromise = getLangs({});
const statePromise = getState({});
const mirrorsPromise = getMirrors({});
const uninstallInfoPromise = getUninstallInfo({});
const [_, { userLocale, langs }, { kind: state }, { mirrors }] = await Promise.all([
const [_, { userLocale, langs }, { kind: state }, { mirrors }, uninstallInfo] = await Promise.all([
i18nPromise,
langsPromise,
statePromise,
mirrorsPromise,
uninstallInfoPromise,
]);
return { langs, userLocale, state, mirrors };
return { langs, userLocale, state, mirrors, uninstallInfo };
}) satisfies PageLoad;