Menyelesaikan plugin, siap ucob
Penerbitan Plugin / persiapan (pull_request) Successful in 5s
Penerbitan Plugin / penerbitan (pull_request) Failing after 1m29s

This commit is contained in:
rizky_denianto committed 2026-09-02 23:13:23 +07:00
1 parent 6f5478e9ab
commit caf005b82d
14 files changed
+312 -15

No files matched your search

+8 -2
View File
@@ -2,8 +2,14 @@ use tauri::{AppHandle, Runtime, command};
use crate::AuthExt;
use crate::Result;
use crate::models::SAuthMuatanMasuk;
#[command]
pub(crate) async fn autentikasi<R: Runtime>(app: AppHandle<R>) -> Result<Vec<()>> {
return app.auth().autentikasi();
pub(crate) async fn masuk<R: Runtime>(app: AppHandle<R>, payload: SAuthMuatanMasuk) -> Result<()> {
return app.auth().masuk(payload);
}
#[command]
pub(crate) async fn keluar<R: Runtime>(app: AppHandle<R>) -> Result<()> {
return app.auth().keluar();
}
+8 -2
View File
@@ -1,6 +1,8 @@
use serde::de::DeserializeOwned;
use tauri::{AppHandle, Runtime, plugin::PluginApi};
use crate::models::SAuthMuatanMasuk;
pub fn init<R: Runtime, C: DeserializeOwned>(
app: &AppHandle<R>,
_api: PluginApi<R, C>,
@@ -12,7 +14,11 @@ pub fn init<R: Runtime, C: DeserializeOwned>(
pub struct Auth<R: Runtime>(AppHandle<R>);
impl<R: Runtime> Auth<R> {
pub fn autentikasi(&self) -> crate::Result<Vec<()>> {
return Ok(vec![]);
pub fn masuk(&self, muatan: SAuthMuatanMasuk) -> crate::Result<()> {
return Ok(());
}
pub fn keluar(&self) -> crate::Result<()> {
return Ok(());
}
}
+3 -1
View File
@@ -19,6 +19,8 @@ use desktop::Auth;
#[cfg(mobile)]
use mobile::Auth;
use crate::commands::{keluar, masuk};
/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the auth APIs.
pub trait AuthExt<R: Runtime> {
fn auth(&self) -> &Auth<R>;
@@ -33,7 +35,7 @@ impl<R: Runtime, T: Manager<R>> crate::AuthExt<R> for T {
/// Initializes the plugin.
pub fn init<R: Runtime>() -> TauriPlugin<R> {
Builder::new("auth")
.invoke_handler(tauri::generate_handler![commands::autentikasi])
.invoke_handler(tauri::generate_handler![masuk, keluar])
.setup(|app, api| {
#[cfg(mobile)]
let auth = mobile::init(app, api)?;
+10 -3
View File
@@ -15,7 +15,7 @@ pub fn init<R: Runtime, C: DeserializeOwned>(
api: PluginApi<R, C>,
) -> crate::Result<Auth<R>> {
#[cfg(target_os = "android")]
let handle = api.register_android_plugin("", "ExamplePlugin")?;
let handle = api.register_android_plugin("com.plugin.auth", "AuthPlugin")?;
#[cfg(target_os = "ios")]
let handle = api.register_ios_plugin(init_plugin_auth)?;
Ok(Auth(handle))
@@ -25,7 +25,14 @@ pub fn init<R: Runtime, C: DeserializeOwned>(
pub struct Auth<R: Runtime>(PluginHandle<R>);
impl<R: Runtime> Auth<R> {
pub fn autentikasi(&self) -> crate::Result<Vec<()>> {
return self.0.run_mobile_plugin("autentikasi").map_err(Into::into);
pub fn masuk(&self, payload: SAuthMuatanMasuk) -> crate::Result<()> {
return self
.0
.run_mobile_plugin("masuk", payload)
.map_err(Into::into);
}
pub fn keluar(&self) -> crate::Result<Vec<()>> {
return self.0.run_mobile_plugin("keluar", ()).map_err(Into::into);
}
}
+6
View File
@@ -1 +1,7 @@
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SAuthMuatanMasuk {
pub id_klien: String,
}