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
@@ -13,6 +13,9 @@ fn greet(name: &str) -> String {
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_single_instance::init(|_app, argv, _cwd| {
println!("single instance triggered: {argv:?}");
}))
.plugin(tauri_plugin_deep_link::init())
.plugin(
tauri_plugin_log::Builder::default()
@@ -20,6 +23,16 @@ pub fn run() {
.build(),
)
.setup(|app| {
// ensure deep links are registered on the system
// this is useful because AppImages requires additional setup to be available in the system
// and calling register() makes the deep links immediately available - without any user input
#[cfg(target_os = "linux")]
{
use tauri_plugin_deep_link::DeepLinkExt;
app.deep_link().register_all()?;
}
app.listen("deep-link://new-url", |url| {
dbg!(url);
});