aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src-tauri/src/main.rs
diff options
context:
space:
mode:
authorHsiangNianian <i@jyunko.cn>2026-01-13 15:37:55 +0800
committerHsiangNianian <i@jyunko.cn>2026-01-13 15:37:55 +0800
commit6fbb5f19cab02f3a0f18cdeda3da02e717b69cd6 (patch)
treebb84869afeb316e2510018e2ba33c651488f3e71 /src-tauri/src/main.rs
parentb7e7f8de3d2200ef34510cda3601a50f62af798d (diff)
downloadDropOut-6fbb5f19cab02f3a0f18cdeda3da02e717b69cd6.tar.gz
DropOut-6fbb5f19cab02f3a0f18cdeda3da02e717b69cd6.zip
feat: add offline account management and version fetching functionality
Diffstat (limited to 'src-tauri/src/main.rs')
-rw-r--r--src-tauri/src/main.rs35
1 files changed, 34 insertions, 1 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index fdd0794..402f58f 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -1,6 +1,8 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
+use tauri::State;
+
mod core;
mod launcher;
@@ -23,10 +25,41 @@ async fn start_game() -> Result<String, String> {
}
}
+#[tauri::command]
+async fn get_versions() -> Result<Vec<core::manifest::Version>, String> {
+ match core::manifest::fetch_version_manifest().await {
+ Ok(manifest) => Ok(manifest.versions),
+ Err(e) => Err(e.to_string()),
+ }
+}
+
+#[tauri::command]
+async fn login_offline(
+ state: State<'_, core::auth::AccountState>,
+ username: String,
+) -> Result<core::auth::OfflineAccount, String> {
+ let uuid = core::auth::generate_offline_uuid(&username);
+ let account = core::auth::OfflineAccount {
+ username,
+ uuid,
+ };
+
+ *state.active_account.lock().unwrap() = Some(account.clone());
+ Ok(account)
+}
+
+#[tauri::command]
+async fn get_active_account(
+ state: State<'_, core::auth::AccountState>,
+) -> Result<Option<core::auth::OfflineAccount>, String> {
+ Ok(state.active_account.lock().unwrap().clone())
+}
+
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
- .invoke_handler(tauri::generate_handler![start_game])
+ .manage(core::auth::AccountState::new())
+ .invoke_handler(tauri::generate_handler![start_game, get_versions, login_offline, get_active_account])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}