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