native: open links in default webbrowser (#4623)
This commit is contained in:
1 parent
6cfe64209a
commit
ab19ad4624
6 files changed
+30
-2
No files matched your search
@@ -0,0 +1,18 @@
|
||||
use blitz_traits::{
|
||||
navigation::{NavigationOptions, NavigationProvider},
|
||||
net::Method,
|
||||
};
|
||||
|
||||
pub(crate) struct DioxusNativeNavigationProvider;
|
||||
|
||||
impl NavigationProvider for DioxusNativeNavigationProvider {
|
||||
fn navigate_to(&self, options: NavigationOptions) {
|
||||
if options.method == Method::GET
|
||||
&& matches!(options.url.scheme(), "http" | "https" | "mailto")
|
||||
{
|
||||
if let Err(err) = webbrowser::open(options.url.as_str()) {
|
||||
tracing::error!("Failed to open URL: {}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user