fix: simplify opener import and improve error logging
This commit is contained in:
@@ -6,14 +6,13 @@ export const openExternalUrl = async (url: string): Promise<void> => {
|
||||
// Only run this in Tauri builds
|
||||
if (typeof window !== 'undefined' && (window as any).__TAURI__) {
|
||||
try {
|
||||
// Use new Function to avoid static analysis by Vite/Rollup
|
||||
await new Function(
|
||||
'url',
|
||||
"return import('@tauri-apps/plugin-opener').then(m => m.openUrl(url));"
|
||||
)(url);
|
||||
const { openUrl } = await import('@tauri-apps/plugin-opener');
|
||||
await openUrl(url);
|
||||
return;
|
||||
} catch (err) {
|
||||
console.warn('Tauri opener.openUrl failed, falling back to window.open:', err);
|
||||
console.error('Tauri opener.openUrl failed:', err);
|
||||
// Don't fall back to window.open in Tauri - it won't work with localhost plugin
|
||||
return;
|
||||
}
|
||||
}
|
||||
window.open(url, '_blank');
|
||||
|
||||
Reference in New Issue
Block a user