mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-08-11 18:40:22 +02:00
feat(opener): Add requireLiteralLeadingDot config (#2762)
This commit is contained in:
@@ -14,6 +14,7 @@ const PLUGIN_IDENTIFIER: &str = "app.tauri.opener";
|
||||
tauri::ios_plugin_binding!(init_plugin_opener);
|
||||
|
||||
mod commands;
|
||||
mod config;
|
||||
mod error;
|
||||
mod open;
|
||||
mod reveal_item_in_dir;
|
||||
@@ -27,12 +28,13 @@ pub use open::{open_path, open_url};
|
||||
pub use reveal_item_in_dir::reveal_item_in_dir;
|
||||
|
||||
pub struct Opener<R: Runtime> {
|
||||
// we use `fn() -> R` to slicence the unused generic error
|
||||
// we use `fn() -> R` to silence the unused generic error
|
||||
// while keeping this struct `Send + Sync` without requiring `R` to be
|
||||
#[cfg(not(mobile))]
|
||||
_marker: std::marker::PhantomData<fn() -> R>,
|
||||
#[cfg(mobile)]
|
||||
mobile_plugin_handle: PluginHandle<R>,
|
||||
require_literal_leading_dot: Option<bool>,
|
||||
}
|
||||
|
||||
impl<R: Runtime> Opener<R> {
|
||||
@@ -185,19 +187,23 @@ impl Builder {
|
||||
}
|
||||
|
||||
/// Build and Initializes the plugin.
|
||||
pub fn build<R: Runtime>(self) -> TauriPlugin<R> {
|
||||
let mut builder = tauri::plugin::Builder::new("opener")
|
||||
.setup(|app, _api| {
|
||||
pub fn build<R: Runtime>(self) -> TauriPlugin<R, Option<config::Config>> {
|
||||
let mut builder = tauri::plugin::Builder::<R, Option<config::Config>>::new("opener")
|
||||
.setup(|app, api| {
|
||||
#[cfg(target_os = "android")]
|
||||
let handle = _api.register_android_plugin(PLUGIN_IDENTIFIER, "OpenerPlugin")?;
|
||||
let handle = api.register_android_plugin(PLUGIN_IDENTIFIER, "OpenerPlugin")?;
|
||||
#[cfg(target_os = "ios")]
|
||||
let handle = _api.register_ios_plugin(init_plugin_opener)?;
|
||||
let handle = api.register_ios_plugin(init_plugin_opener)?;
|
||||
|
||||
app.manage(Opener {
|
||||
#[cfg(not(mobile))]
|
||||
_marker: std::marker::PhantomData::<fn() -> R>,
|
||||
#[cfg(mobile)]
|
||||
mobile_plugin_handle: handle,
|
||||
require_literal_leading_dot: api
|
||||
.config()
|
||||
.as_ref()
|
||||
.and_then(|c| c.require_literal_leading_dot),
|
||||
});
|
||||
Ok(())
|
||||
})
|
||||
@@ -216,6 +222,6 @@ impl Builder {
|
||||
}
|
||||
|
||||
/// Initializes the plugin.
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R, Option<config::Config>> {
|
||||
Builder::default().build()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user