fix(tauri): use raw __TAURI_INTERNALS__ invoke, fix dynamic import on Android

Root cause: dynamic import('@tauri-apps/plugin-opener') silently fails on
Android Tauri WebView because the module resolution path for @tauri-apps/api
(plugin dependency) differs from npm expectations in the bundled context.

Rewrote tauri.ts to use window.__TAURI_INTERNALS__.invoke() directly:
- openUrl() → invoke('plugin:opener|open_url', {url})
- setupDeepLinkHandler() → invoke('plugin:deep-link|get_current')
- Warm-start listener still uses import('@tauri-apps/api/event') for
  deep-link://new-url events (bundled as separate chunk by Vite)
- Added @tauri-apps/api as direct dependency

Also kept withGlobalTauri: true (needed for __TAURI_INTERNALS__ injection)
but reverted APK frontendDist back to bundled React app (../web/dist)
since redirect-to-live-web approach was unreliable.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
MythEclipse
2026-06-16 04:34:13 +07:00
co-authored by Claude
parent 4b252a1d5d
commit 7423e4d83b
4 changed files with 43 additions and 34 deletions
+3 -3
View File
@@ -4,10 +4,10 @@
"version": "0.1.0",
"identifier": "com.zeavis.edu",
"build": {
"frontendDist": "../web/dist-tauri",
"frontendDist": "../web/dist",
"devUrl": "http://localhost:5173",
"beforeBuildCommand": "echo 'Nothing to build (APK loads live web content)'",
"beforeDevCommand": "echo 'Dev mode - connect to localhost:5173'"
"beforeBuildCommand": "cd ../web && bun run build",
"beforeDevCommand": "cd ../web && bun run dev"
},
"app": {
"withGlobalTauri": true,