mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-07-14 16:37:22 +02:00
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:
committed by
GitHub
parent
77680f6ed8
commit
64a6240f79
@@ -7,7 +7,7 @@
|
||||
use serde::{Deserialize, Deserializer};
|
||||
use tauri_utils::config::DeepLinkProtocol;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Deserialize, Clone)]
|
||||
pub struct AssociatedDomain {
|
||||
#[serde(deserialize_with = "deserialize_associated_host")]
|
||||
pub host: String,
|
||||
@@ -29,7 +29,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Deserialize, Clone)]
|
||||
pub struct Config {
|
||||
/// Mobile requires `https://<host>` urls.
|
||||
#[serde(default)]
|
||||
@@ -41,7 +41,7 @@ pub struct Config {
|
||||
pub desktop: DesktopProtocol,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Deserialize, Clone)]
|
||||
#[serde(untagged)]
|
||||
#[allow(unused)] // Used in tauri-bundler
|
||||
pub enum DesktopProtocol {
|
||||
@@ -54,3 +54,26 @@ impl Default for DesktopProtocol {
|
||||
Self::List(Vec::new())
|
||||
}
|
||||
}
|
||||
|
||||
impl DesktopProtocol {
|
||||
#[allow(dead_code)]
|
||||
pub fn contains_scheme(&self, scheme: &String) -> bool {
|
||||
match self {
|
||||
Self::One(protocol) => protocol.schemes.contains(scheme),
|
||||
Self::List(protocols) => protocols
|
||||
.iter()
|
||||
.any(|protocol| protocol.schemes.contains(scheme)),
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn schemes(&self) -> Vec<String> {
|
||||
match self {
|
||||
Self::One(protocol) => protocol.schemes.clone(),
|
||||
Self::List(protocols) => protocols
|
||||
.iter()
|
||||
.flat_map(|protocol| protocol.schemes.clone())
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user