feat: link open in browser

This commit is contained in:
YuKun Liu committed 2022-01-18 09:19:12 +08:00
1 parent e84126ad16
commit a0f60152bc
4 files changed
+73 -1

No files matched your search

+21
View File
@@ -187,6 +187,27 @@ pub fn launch_with_props<P: 'static + Send>(
is_ready.store(true, std::sync::atomic::Ordering::Relaxed);
let _ = proxy.send_event(UserWindowEvent::Update);
}
"browser_open" => {
let data = req.params.unwrap();
log::trace!("Open browser: {:?}", data);
if data.is_array() {
let arr = data.as_array().unwrap();
if arr[0].is_object() {
let temp = arr[0]
.as_object()
.unwrap();
if temp.contains_key("href") {
let url = temp
.get("href").unwrap()
.as_str().unwrap();
match webbrowser::open(url) {
Ok(_) => {},
Err(e) => log::trace!("Open browser error: {:?}", e),
}
}
}
}
}
_ => {}
}
None