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
@@ -21,3 +21,5 @@ dist-ssr
*.njsproj
*.sln
*.sw?
dist/
@@ -22,6 +22,7 @@ serde_json = { workspace = true }
tauri = { workspace = true, features = ["wry", "compression"] }
tauri-plugin-deep-link = { path = "../../../" }
tauri-plugin-log = { path = "../../../../log" }
tauri-plugin-single-instance = { path = "../../../../single-instance" }
log = "0.4"
[features]
@@ -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);
});
@@ -29,8 +29,13 @@
},
"deep-link": {
"mobile": [
{ "host": "fabianlars.de", "pathPrefix": ["/intent"] },
{ "host": "tauri.app" }
{
"host": "fabianlars.de",
"pathPrefix": ["/intent"]
},
{
"host": "tauri.app"
}
],
"desktop": {
"schemes": ["fabianlars", "my-tauri-app"]