From e1b56875edf039aab9f41868826bcd3a92097133 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Tue, 17 Sep 2024 01:52:19 +0200 Subject: [PATCH] egui: base web app on newer version of official eframe template --- index.html | 54 ++++++++++++++++++++++++++----------- src/bin/topola-egui/main.rs | 23 +++++++++++++--- 2 files changed, 59 insertions(+), 18 deletions(-) diff --git a/index.html b/index.html index 184e7a2..c9b35e3 100644 --- a/index.html +++ b/index.html @@ -3,19 +3,30 @@ - + - Topola + Topola PCB router + - - + - - + + + + + + + + + + + + + + + - - --> + + diff --git a/src/bin/topola-egui/main.rs b/src/bin/topola-egui/main.rs index b970501..446daf0 100644 --- a/src/bin/topola-egui/main.rs +++ b/src/bin/topola-egui/main.rs @@ -50,13 +50,30 @@ fn main() { let web_options = eframe::WebOptions::default(); wasm_bindgen_futures::spawn_local(async { - eframe::WebRunner::new() + let start_result = eframe::WebRunner::new() .start( "topola-egui", web_options, Box::new(|cc| Ok(Box::new(App::new(cc, langid!("en-US"))))), ) - .await - .expect("failed to start eframe"); + .await; + + // Remove the loading text and spinner: + let loading_text = eframe::web_sys::window() + .and_then(|w| w.document()) + .and_then(|d| d.get_element_by_id("loading_text")); + if let Some(loading_text) = loading_text { + match start_result { + Ok(_) => { + loading_text.remove(); + } + Err(e) => { + loading_text.set_inner_html( + "

The app has crashed. See the developer console for details.

", + ); + panic!("Failed to start eframe: {e:?}"); + } + } + } }); }