mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-26 21:41:48 +02:00
chore: edition 2024
This commit is contained in:
@@ -5,7 +5,7 @@ description = "A Tauri App"
|
||||
authors = ["you"]
|
||||
license = ""
|
||||
repository = ""
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
rust-version = "1.90"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use tauri::{command, AppHandle, Runtime, State, Window};
|
||||
use tauri::{AppHandle, Runtime, State, Window, command};
|
||||
|
||||
use crate::{DeepLink, Result};
|
||||
|
||||
|
||||
@@ -50,7 +50,9 @@ impl AssociatedDomain {
|
||||
}
|
||||
if self.scheme.iter().any(|s| s == "http") && !self.scheme.iter().any(|s| s == "https")
|
||||
{
|
||||
eprintln!("Warning: AppLink uses only 'http' — allowed on Android but not secure for production.");
|
||||
eprintln!(
|
||||
"Warning: AppLink uses only 'http' — allowed on Android but not secure for production."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,13 +70,12 @@ where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let opt = Option::<String>::deserialize(deserializer)?;
|
||||
if let Some(ref host) = opt {
|
||||
if let Some((scheme, _)) = host.split_once("://") {
|
||||
if let Some(ref host) = opt
|
||||
&& let Some((scheme, _)) = host.split_once("://") {
|
||||
return Err(serde::de::Error::custom(format!(
|
||||
"host `{host}` cannot start with a scheme, please remove the `{scheme}://` prefix"
|
||||
)));
|
||||
}
|
||||
}
|
||||
Ok(opt)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use serde::{ser::Serializer, Serialize};
|
||||
use serde::{Serialize, ser::Serializer};
|
||||
|
||||
/// Alias for a [`Result`](std::result::Result) with the error type [`Error`].
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
//! calling those methods returns [`Error::UnsupportedPlatform`].
|
||||
|
||||
use tauri::{
|
||||
plugin::{Builder, PluginApi, TauriPlugin},
|
||||
AppHandle, EventId, Listener, Manager, Runtime,
|
||||
plugin::{Builder, PluginApi, TauriPlugin},
|
||||
};
|
||||
|
||||
mod commands;
|
||||
@@ -33,8 +33,8 @@ fn init_deep_link<R: Runtime>(
|
||||
let _api = api;
|
||||
|
||||
use tauri::{
|
||||
ipc::{Channel, InvokeResponseBody},
|
||||
Emitter,
|
||||
ipc::{Channel, InvokeResponseBody},
|
||||
};
|
||||
|
||||
let handle = _api.register_android_plugin(PLUGIN_IDENTIFIER, "DeepLinkPlugin")?;
|
||||
@@ -94,7 +94,7 @@ fn init_deep_link<R: Runtime>(
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
mod imp {
|
||||
use tauri::{ipc::Channel, plugin::PluginHandle, AppHandle, Runtime};
|
||||
use tauri::{AppHandle, Runtime, ipc::Channel, plugin::PluginHandle};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -172,7 +172,7 @@ mod imp {
|
||||
use std::sync::Mutex;
|
||||
#[cfg(target_os = "linux")]
|
||||
use std::{
|
||||
fs::{create_dir_all, File},
|
||||
fs::{File, create_dir_all},
|
||||
io::Write,
|
||||
process::Command,
|
||||
};
|
||||
@@ -223,7 +223,9 @@ mod imp {
|
||||
current.replace(vec![url.clone()]);
|
||||
let _ = self.app.emit("deep-link://new-url", vec![url]);
|
||||
} else if cfg!(debug_assertions) {
|
||||
tracing::warn!("argument {url} does not match any configured deep link scheme; skipping it");
|
||||
tracing::warn!(
|
||||
"argument {url} does not match any configured deep link scheme; skipping it"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -414,11 +416,10 @@ mod imp {
|
||||
let mimeapps_path = self.app.path().config_dir()?.join("mimeapps.list");
|
||||
if mimeapps_path.exists() {
|
||||
let mut mimeapps = ini::Ini::load_from_file(&mimeapps_path)?;
|
||||
if let Some(section) = mimeapps.section_mut(Some("Default Applications")) {
|
||||
if section.get(&mime_type).unwrap_or_default() == file_name {
|
||||
if let Some(section) = mimeapps.section_mut(Some("Default Applications"))
|
||||
&& section.get(&mime_type).unwrap_or_default() == file_name {
|
||||
section.remove(&mime_type);
|
||||
}
|
||||
}
|
||||
mimeapps.write_to_file(&mimeapps_path)?;
|
||||
}
|
||||
|
||||
@@ -558,16 +559,16 @@ impl<R: Runtime> DeepLink<R> {
|
||||
///
|
||||
/// Use `get_current` on app load to check whether your app was started via a deep link.
|
||||
pub fn on_open_url<F: Fn(OpenUrlEvent) + Send + Sync + 'static>(&self, f: F) -> EventId {
|
||||
let event_id = self.app.listen("deep-link://new-url", move |event| {
|
||||
|
||||
|
||||
self.app.listen("deep-link://new-url", move |event| {
|
||||
if let Ok(urls) = serde_json::from_str(event.payload()) {
|
||||
f(OpenUrlEvent {
|
||||
id: event.id(),
|
||||
urls,
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
event_id
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user