fix: update openExternalUrl to use dynamic import for Tauri shell plugin

This commit is contained in:
2026-01-24 08:21:34 +11:00
parent 7c2851e958
commit 92c3ec8082

View File

@@ -3,12 +3,14 @@
* @param url The URL to open * @param url The URL to open
*/ */
export const openExternalUrl = async (url: string): Promise<void> => { export const openExternalUrl = async (url: string): Promise<void> => {
// Only include Tauri shell import in Tauri builds // Only run this in Tauri builds
// @ts-ignore if (typeof window !== 'undefined' && (window as any).__TAURI__) {
if (import.meta.env.VITE_TAURI) {
try { try {
const { open } = await import('@tauri-apps/plugin-shell'); // Use new Function to avoid static analysis by Vite/Rollup
await open(url); await new Function(
'url',
"return import('@tauri-apps/plugin-shell').then(m => m.open(url));"
)(url);
return; return;
} catch (err) { } catch (err) {
console.warn('Tauri shell.open failed, falling back to window.open:', err); console.warn('Tauri shell.open failed, falling back to window.open:', err);