fix: update openExternalUrl to use dynamic import for Tauri shell plugin
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user