mirror of
https://github.com/LCE-Hub/LCE-Emerald-Launcher.git
synced 2026-08-20 04:27:29 +00:00
36 lines
1 KiB
Rust
36 lines
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())
|
|
}
|
|
}
|