瀏覽代碼

Allows desktop apps to open mailto links (#4282)

* Allows desktop apps to open mailto links

* Drop webbrowser, use `open` only

* switch to that_detached

* use workspace `open`

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
Juan Vásquez 1 周之前
父節點
當前提交
1d3168dc4a
共有 6 個文件被更改,包括 9 次插入24 次删除
  1. 1 18
      Cargo.lock
  2. 0 1
      Cargo.toml
  3. 1 1
      packages/cli/src/build/request.rs
  4. 1 1
      packages/desktop/Cargo.toml
  5. 1 1
      packages/desktop/src/app.rs
  6. 5 2
      packages/desktop/src/webview.rs

+ 1 - 18
Cargo.lock

@@ -3951,6 +3951,7 @@ dependencies = [
  "ndk-sys 0.6.0+11769913",
  "objc",
  "objc_id",
+ "open",
  "percent-encoding",
  "rand 0.8.5",
  "reqwest 0.12.15",
@@ -3967,7 +3968,6 @@ dependencies = [
  "tokio-tungstenite",
  "tracing",
  "tray-icon",
- "webbrowser",
  "wry",
 ]
 
@@ -16194,23 +16194,6 @@ dependencies = [
  "string_cache_codegen",
 ]
 
-[[package]]
-name = "webbrowser"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d5df295f8451142f1856b1bd86a606dfe9587d439bc036e319c827700dbd555e"
-dependencies = [
- "core-foundation 0.10.0",
- "home",
- "jni",
- "log",
- "ndk-context",
- "objc2 0.6.1",
- "objc2-foundation 0.3.1",
- "url",
- "web-sys",
-]
-
 [[package]]
 name = "webkit2gtk"
 version = "2.0.1"

+ 0 - 1
Cargo.toml

@@ -314,7 +314,6 @@ memfd = "0.6.4"
 # desktop
 wry = { version = "0.45.0", default-features = false }
 tao = { version = "0.33.0", features = ["rwh_05"] }
-webbrowser = "1.0.3"
 infer = "0.19.0"
 dunce = "1.0.5"
 percent-encoding = "2.3.1"

+ 1 - 1
packages/cli/src/build/request.rs

@@ -4148,7 +4148,7 @@ r#" <script>
                     .trim()
                     .into();
                 let path_to_sim = path_to_xcode.join("Applications").join("Simulator.app");
-                open::that(path_to_sim)?;
+                open::that_detached(path_to_sim)?;
             }
 
             Platform::Android => {

+ 1 - 1
packages/desktop/Cargo.toml

@@ -37,7 +37,6 @@ tokio = { workspace = true, features = [
   "fs",
   "io-util",
 ], optional = true }
-webbrowser = { workspace = true }
 infer = { workspace = true }
 dunce = { workspace = true }
 slab = { workspace = true }
@@ -49,6 +48,7 @@ async-trait = { workspace = true }
 tao = { workspace = true, features = ["rwh_05"] }
 dioxus-history = { workspace = true }
 base64 = { workspace = true }
+open = { workspace = true }
 libc = "0.2.170"
 
 [target.'cfg(unix)'.dependencies]

+ 1 - 1
packages/desktop/src/app.rs

@@ -271,7 +271,7 @@ impl App {
         if let Some(temp) = msg.params().as_object() {
             if temp.contains_key("href") {
                 if let Some(href) = temp.get("href").and_then(|v| v.as_str()) {
-                    if let Err(e) = webbrowser::open(href) {
+                    if let Err(e) = open::that_detached(href) {
                         tracing::error!("Open Browser error: {:?}", e);
                     }
                 }

+ 5 - 2
packages/desktop/src/webview.rs

@@ -346,8 +346,11 @@ impl WebviewInstance {
                 if var.starts_with("dioxus://") || var.starts_with("http://dioxus.") {
                     true
                 } else {
-                    if var.starts_with("http://") || var.starts_with("https://") {
-                        _ = webbrowser::open(&var);
+                    if var.starts_with("http://")
+                        || var.starts_with("https://")
+                        || var.starts_with("mailto:")
+                    {
+                        _ = open::that_detached(&var);
                     }
                     false
                 }