Added a webview managed by the application

This commit is contained in:
Manuel Forcén Muñoz 2024-05-22 19:11:25 +02:00
parent c9e621571c
commit b4044de503
3 changed files with 295 additions and 6 deletions

View file

@ -16,3 +16,4 @@ serde_json = "1"
accounters = { path = ".." }
tera = "1.19.1"
rand = "0.8"
web-view="0.7"

View file

@ -105,10 +105,26 @@ async fn main() {
.with_state(state);
let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
let server = axum::Server::bind(&addr).serve(app.into_make_service());
let wv_task = tokio::task::spawn_blocking(|| {
web_view::builder()
.title("Test")
.content(web_view::Content::Url("http://localhost:3000"))
.user_data(())
.invoke_handler(|_wv, _arg| Ok(()))
.run()
.unwrap();
});
tokio::select! {
_ = wv_task => {
println!("WebView finished");
}
e = server => {
println!("Axum finished with result {e:?}");
}
}
}
#[derive(Clone)]