From 3d9e614ea39b82c18dfd5ca46051b0df9fe731f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Thu, 5 Sep 2024 12:24:15 +0200 Subject: [PATCH] Allow opening the app in a browser For development purposes it's convenient to be able to open the app in Chrome. To do this we skip invoking internal Tauri commands. --- src/App.svelte | 7 ++++++- src/global.d.ts | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/global.d.ts diff --git a/src/App.svelte b/src/App.svelte index ec97540..176c8be 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -16,7 +16,12 @@ onMount(async () => { try { - await invoke("authenticate"); + // For development purposes don't run tauri commands when viewing from + // a browser. + if (window.__TAURI_INTERNALS__) { + await invoke("authenticate"); + } + void router.push({ resource: "home" }); // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (e: any) { diff --git a/src/global.d.ts b/src/global.d.ts new file mode 100644 index 0000000..88c82d9 --- /dev/null +++ b/src/global.d.ts @@ -0,0 +1,8 @@ +declare global { + interface Window { + // eslint-disable-next-line @typescript-eslint/naming-convention + __TAURI_INTERNALS__: Record; + } +} + +export {};