diff options
| author | 2026-01-13 11:25:35 +0800 | |
|---|---|---|
| committer | 2026-01-13 11:25:35 +0800 | |
| commit | 68474e65c27323da62aad223cea7fb22356b0df6 (patch) | |
| tree | 3e6806cb3d1b0c2a0b6483fcd1768119620f9012 /src/main.rs | |
| parent | 431c117a55d06e45ef48305f67f71e6a2afb76fd (diff) | |
| download | DropOut-68474e65c27323da62aad223cea7fb22356b0df6.tar.gz DropOut-68474e65c27323da62aad223cea7fb22356b0df6.zip | |
feat: Added version control functionality and integrated Tokio and Reqwest to support asynchronous operations
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index 31e87da..9161263 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,39 @@ +mod core; mod launcher; mod ui; +use tokio::sync::mpsc; +use tokio::runtime::Runtime; +use std::thread; + fn main() { - // 初始化UI模块 - ui::init(); + // channel for UI -> Backend + let (tx, mut rx) = mpsc::channel(32); + + // Spawn Tokio runtime in a background thread + thread::spawn(move || { + let rt = Runtime::new().unwrap(); + rt.block_on(async move { + println!("Backend started"); + while let Some(msg) = rx.recv().await { + match msg { + ui::UiEvent::StartGame => { + println!("Backend received StartGame"); + match core::manifest::fetch_version_manifest().await { + Ok(manifest) => { + println!("Fetched manifest. Latest release: {}", manifest.latest.release); + println!("Latest snapshot: {}", manifest.latest.snapshot); + } + Err(e) => { + eprintln!("Error fetching manifest: {}", e); + } + } + } + } + } + }); + }); - // 启动器模块的逻辑 - launcher::start(); -}
\ No newline at end of file + // Run UI on main thread (must be main thread for GTK on some platforms) + ui::init(tx); +} |