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
|
// Only run this in Tauri builds
|
||||||
if (typeof window !== 'undefined' && (window as any).__TAURI__) {
|
if (typeof window !== 'undefined' && (window as any).__TAURI__) {
|
||||||
try {
|
try {
|
||||||
// Use new Function to avoid static analysis by Vite/Rollup
|
const { openUrl } = await import('@tauri-apps/plugin-opener');
|
||||||
await new Function(
|
await openUrl(url);
|
||||||
'url',
|
|
||||||
"return import('@tauri-apps/plugin-opener').then(m => m.openUrl(url));"
|
|
||||||
)(url);
|
|
||||||
return;
|
return;
|
||||||
} catch (err) {
|
} 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');
|
window.open(url, '_blank');
|
||||||
|
|||||||
Reference in New Issue
Block a user