From 92be07cb4718c12515235daa346dbbd690ff801d Mon Sep 17 00:00:00 2001 From: Max Litruv Boonzaayer Date: Sat, 24 Jan 2026 08:12:39 +1100 Subject: [PATCH] feat: refactor openExternalUrl to use dedicated Tauri shell utility --- src/app/utils/tauri.ts | 6 ++---- src/app/utils/tauriShell.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 src/app/utils/tauriShell.ts diff --git a/src/app/utils/tauri.ts b/src/app/utils/tauri.ts index f9858b3..0913ba4 100644 --- a/src/app/utils/tauri.ts +++ b/src/app/utils/tauri.ts @@ -3,12 +3,10 @@ * @param url The URL to open */ export const openExternalUrl = async (url: string): Promise => { - // Only try to import Tauri shell in Tauri builds if (typeof window !== 'undefined' && (window as any).__TAURI__) { try { - // @ts-ignore - const { open } = await import(/* @vite-ignore */ '@tauri-apps/plugin-shell'); - await open(url); + const { openWithTauriShell } = await import('./tauriShell'); + await openWithTauriShell(url); return; } catch (err) { console.warn('Tauri shell.open failed, falling back to window.open:', err); diff --git a/src/app/utils/tauriShell.ts b/src/app/utils/tauriShell.ts new file mode 100644 index 0000000..ae7fa2e --- /dev/null +++ b/src/app/utils/tauriShell.ts @@ -0,0 +1,9 @@ +/** + * Tauri shell open utility, only imported in Tauri builds + */ + +export async function openWithTauriShell(url: string): Promise { + // @ts-ignore + const { open } = await import(/* @vite-ignore */ '@tauri-apps/plugin-shell'); + await open(url); +}