fix: window zoom
This commit is contained in:
parent
6dfe84834d
commit
7f418bbfee
|
@ -4,9 +4,8 @@
|
|||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
dioxus_desktop::launch(app).await;
|
||||
fn main() {
|
||||
dioxus_desktop::launch(app);
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
|
|
|
@ -7,8 +7,8 @@ fn main() {
|
|||
|
||||
fn app(cx: Scope) -> Element {
|
||||
let window = use_window(cx);
|
||||
|
||||
let level = use_state(cx, || 1.0);
|
||||
|
||||
cx.render(rsx! {
|
||||
input {
|
||||
r#type: "number",
|
||||
|
@ -16,7 +16,7 @@ fn app(cx: Scope) -> Element {
|
|||
oninput: |e| {
|
||||
let num = e.value.parse::<f64>().unwrap_or(1.0);
|
||||
level.set(num);
|
||||
window.set_zoom_level(num);
|
||||
window.webview.zoom(num);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -118,6 +118,11 @@ impl DesktopContext {
|
|||
}
|
||||
}
|
||||
|
||||
/// Set the zoom level of the webview
|
||||
pub fn set_zoom_level(&self, level: f64) {
|
||||
self.webview.zoom(level);
|
||||
}
|
||||
|
||||
/// opens DevTool window
|
||||
pub fn devtool(&self) {
|
||||
#[cfg(debug_assertions)]
|
||||
|
|
Loading…
Reference in New Issue