diff --git a/cinny b/cinny index 847f755..5461359 160000 --- a/cinny +++ b/cinny @@ -1 +1 @@ -Subproject commit 847f755ba4b0ae89df737eff1c5fa63a649bd3b6 +Subproject commit 546135988ec3d7182ef07ff1b02f84d5d99dcaa8 diff --git a/src-tauri/gen/schemas/capabilities.json b/src-tauri/gen/schemas/capabilities.json index 6a54a07..bdfb6b5 100644 --- a/src-tauri/gen/schemas/capabilities.json +++ b/src-tauri/gen/schemas/capabilities.json @@ -1 +1 @@ -{"default":{"identifier":"default","description":"Default capability for all windows","local":true,"windows":["*"],"permissions":["core:default","opener:default","notification:default","autostart:default"]}} \ No newline at end of file +{"default":{"identifier":"default","description":"Default capability for all windows","local":true,"windows":["*"],"permissions":["core:default","opener:default","notification:default","autostart:default"],"platforms":["linux","windows","macOS"]},"mobile":{"identifier":"mobile","description":"Default capability for mobile","local":true,"windows":["*"],"permissions":["core:default","opener:default","notification:default","deep-link:default"],"platforms":["android","iOS"]}} \ No newline at end of file diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index d0a9f8f..5759068 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -6,8 +6,10 @@ mod mobile; #[cfg(not(any(target_os = "android", target_os = "ios")))] use tauri::{ Manager, + WebviewUrl, menu::{Menu, MenuItem}, tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent}, + webview::WebviewWindowBuilder, WindowEvent, }; @@ -72,7 +74,41 @@ pub fn run() { tauri_plugin_autostart::MacosLauncher::LaunchAgent, Some(vec!["--minimized"]), )) - .setup(|app| { + .setup(move |app| { + // In dev mode, use Vite dev server; in production, use localhost plugin + let url: tauri::Url = if cfg!(dev) { + "http://localhost:8080".parse().unwrap() + } else { + format!("http://localhost:{}", port).parse().unwrap() + }; + + // Create the main window manually with navigation handler for external links + WebviewWindowBuilder::new(app, "main", WebviewUrl::External(url)) + .title("Paarrot") + .inner_size(1280.0, 905.0) + .center() + .resizable(true) + .disable_drag_drop_handler() + .on_navigation(|url| { + let url_str = url.as_str(); + // Allow navigation to localhost (our app) and special protocols + if url_str.starts_with("http://localhost") + || url_str.starts_with("https://localhost") + || url_str.starts_with("tauri://") + || url_str.starts_with("blob:") + || url_str.starts_with("data:") + { + return true; + } + // Block external URLs - open them in default browser + if url_str.starts_with("http://") || url_str.starts_with("https://") { + let _ = tauri_plugin_opener::open_url(url_str, None::<&str>); + return false; + } + true + }) + .build()?; + // Create system tray let show_item = MenuItem::with_id(app, "show", "Show Paarrot", true, None::<&str>)?; let quit_item = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?; diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 3a9f274..50da3d9 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -10,17 +10,8 @@ "beforeBuildCommand": "cd cinny && npm run build" }, "app": { - "windows": [ - { - "title": "Paarrot", - "width": 1280, - "height": 905, - "center": true, - "resizable": true, - "fullscreen": false, - "dragDropEnabled": false - } - ], + "withGlobalTauri": true, + "windows": [], "security": { "csp": "script-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self'; img-src 'self' https: http: data: blob:" }