feat: add open_external_url command to open URLs in the default browser
All checks were successful
All checks were successful
This commit is contained in:
2
cinny
2
cinny
Submodule cinny updated: 546135988e...47b24d26ff
1
src-tauri/Cargo.lock
generated
1
src-tauri/Cargo.lock
generated
@@ -2681,6 +2681,7 @@ version = "4.10.2"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"arboard",
|
"arboard",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
|
"open",
|
||||||
"png 0.17.16",
|
"png 0.17.16",
|
||||||
"ppv-lite86",
|
"ppv-lite86",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ tauri-plugin-window-state = "2"
|
|||||||
tauri-plugin-single-instance = "2"
|
tauri-plugin-single-instance = "2"
|
||||||
tauri-plugin-updater = "2"
|
tauri-plugin-updater = "2"
|
||||||
tauri-plugin-autostart = "2"
|
tauri-plugin-autostart = "2"
|
||||||
|
open = "5"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["custom-protocol"]
|
default = ["custom-protocol"]
|
||||||
|
|||||||
@@ -51,6 +51,13 @@ fn read_clipboard_image() -> Result<Option<String>, String> {
|
|||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Open a URL in the default browser (bypasses ACL issues with localhost plugin)
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
#[tauri::command]
|
||||||
|
fn open_external_url(url: String) -> Result<(), String> {
|
||||||
|
open::that(&url).map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
/// Runs the Tauri application
|
/// Runs the Tauri application
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
@@ -157,7 +164,7 @@ pub fn run() {
|
|||||||
api.prevent_close();
|
api.prevent_close();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.invoke_handler(tauri::generate_handler![read_clipboard_image])
|
.invoke_handler(tauri::generate_handler![read_clipboard_image, open_external_url])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while building tauri application");
|
.expect("error while building tauri application");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user