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); +}