Move wasm main to wasm.rs

This commit is contained in:
2026-01-03 20:56:41 +01:00
parent 314a3b455c
commit 894f5c5e20
3 changed files with 15 additions and 12 deletions
+7 -10
View File
@@ -1,7 +1,12 @@
// Prevent console window in addition to Slint window in Windows release builds when, e.g., starting the app via file manager. Ignored on other platforms.
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
mod config;
mod runtime;
#[cfg(target_arch = "wasm32")]
mod wasm;
use std::{
rc::Rc,
sync::{Arc, Mutex},
@@ -76,21 +81,13 @@ fn refresh_list(conf: &Arc<Mutex<Config>>, app_weak: &slint::Weak<App>) {
});
}
#[cfg(target_arch = "wasm32")]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen::prelude::wasm_bindgen(start))]
pub fn main() {
if let Err(e) = run() {
eprintln!("{e:?}");
}
}
pub fn run() -> Result<(), anyhow::Error> {
let app = App::new()?;
let state = app.global::<State>();
let list_shared = Rc::new(VecModel::default());
state.set_list(ModelRc::new(list_shared.clone()));
#[cfg(not(target_arch = "wasm32"))]
#[cfg(target_os = "linux")]
let conf = runtime::RT
.block_on(config::get_config())
.inspect_err(|err| eprintln!("{err:?}"))
@@ -197,7 +194,7 @@ pub fn run() -> Result<(), anyhow::Error> {
state.on_set_server_address(move |address| {
conf_shared.lock().unwrap().address = address.to_string();
#[cfg(not(target_arch = "wasm32"))]
#[cfg(target_os = "linux")]
let _ = config::save_config(address.to_string());
});