feat(deep-link): implement getCurrent on Windows/Linux (#1759)

* feat(deep-link): implement getCurrent on Windows/Linux

checks std::env::args() on initialization, also includes integration with the single-instance plugin

* fmt

* update docs, fix event

* add register_all function

* expose api

* be nicer on docs, clippy
This commit is contained in:
Lucas Fernandes Nogueira
2024-09-10 16:00:42 -03:00
committed by GitHub
parent 77680f6ed8
commit 64a6240f79
13 changed files with 171 additions and 24 deletions
+8 -2
View File
@@ -13,6 +13,7 @@
#![cfg(not(any(target_os = "android", target_os = "ios")))]
use tauri::{plugin::TauriPlugin, AppHandle, Manager, Runtime};
use tauri_plugin_deep_link::DeepLink;
#[cfg(target_os = "windows")]
#[path = "platform_impl/windows.rs"]
@@ -31,9 +32,14 @@ pub(crate) type SingleInstanceCallback<R> =
dyn FnMut(&AppHandle<R>, Vec<String>, String) + Send + Sync + 'static;
pub fn init<R: Runtime, F: FnMut(&AppHandle<R>, Vec<String>, String) + Send + Sync + 'static>(
f: F,
mut f: F,
) -> TauriPlugin<R> {
platform_impl::init(Box::new(f))
platform_impl::init(Box::new(move |app, args, cwd| {
if let Some(deep_link) = app.try_state::<DeepLink<R>>() {
deep_link.handle_cli_arguments(args.iter());
}
f(app, args, cwd)
}))
}
pub fn destroy<R: Runtime, M: Manager<R>>(manager: &M) {