LCE-Emerald-Launcher/src-tauri/src/lce_auth.rs
/home/neo d6f622c913
Merge diamond into main (#175)
Co-authored-by: str1k3r <115313679+S1l3ntStr1ke87@users.noreply.github.com>
2026-08-17 21:42:38 +03:00

36 lines
1.1 KiB
Rust

use tauri::plugin::{Builder, PluginHandle, TauriPlugin};
use tauri::Wry;
pub struct LceAuthState(pub PluginHandle<Wry>);
pub fn init() -> TauriPlugin<Wry> {
Builder::new("emerald-lce-auth")
.setup(|app, api| {
#[cfg(target_os = "android")]
{
use tauri::Manager;
let handle = api.register_android_plugin("com.emerald.legacy", "LceAuthPlugin")?;
app.manage(LceAuthState(handle));
}
Ok(())
})
.build()
}
#[tauri::command]
pub async fn start_lce_auth(app: tauri::AppHandle) -> Result<String, String> {
#[cfg(target_os = "android")]
{
use tauri::Manager;
let state = app.state::<LceAuthState>();
state
.0
.run_mobile_plugin_async("startAuth", ())
.await
.map_err(|e| e.to_string())
}
#[cfg(not(target_os = "android"))]
{
let _ = app;
Err("LCE Online auth is only supported on Android".into()) //neo: erm, rust-side only. its supported on desktop on the typescript side.
}
}