Menambah izin per perintah atau per fungsi
This commit is contained in:
1 parent
b7ceeccb52
commit
c72c86c984
14 files changed
+234
-35
No files matched your search
@@ -4,6 +4,16 @@ use crate::BluclasExt;
|
||||
use crate::Result;
|
||||
use crate::models::*;
|
||||
|
||||
#[command]
|
||||
pub(crate) async fn cek_izin<R: Runtime>(app: AppHandle<R>) -> Result<bool> {
|
||||
return app.bluclas().cek_izin();
|
||||
}
|
||||
|
||||
#[command]
|
||||
pub(crate) async fn minta_izin<R: Runtime>(app: AppHandle<R>) -> Result<()> {
|
||||
return app.bluclas().minta_izin();
|
||||
}
|
||||
|
||||
#[command]
|
||||
pub(crate) async fn daftar_perangkat<R: Runtime>(
|
||||
app: AppHandle<R>,
|
||||
|
||||
@@ -14,6 +14,14 @@ pub fn init<R: Runtime, C: DeserializeOwned>(
|
||||
pub struct Bluclas<R: Runtime>(AppHandle<R>);
|
||||
|
||||
impl<R: Runtime> Bluclas<R> {
|
||||
pub fn cek_izin(&self) -> crate::Result<bool> {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
pub fn minta_izin(&self) -> crate::Result<()> {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
pub fn daftar_perangkat(&self) -> crate::Result<SBlueclasResponDaftarPerangkat> {
|
||||
return Ok(SBlueclasResponDaftarPerangkat { data: vec![] });
|
||||
}
|
||||
|
||||
+6
-3
@@ -1,6 +1,7 @@
|
||||
use crate::commands::{cek_izin, daftar_perangkat, kirim, minta_izin};
|
||||
use tauri::{
|
||||
plugin::{Builder, TauriPlugin},
|
||||
Manager, Runtime,
|
||||
plugin::{Builder, TauriPlugin},
|
||||
};
|
||||
|
||||
pub use models::*;
|
||||
@@ -36,8 +37,10 @@ impl<R: Runtime, T: Manager<R>> crate::BluclasExt<R> for T {
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::new("bluclas")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
commands::daftar_perangkat,
|
||||
commands::kirim
|
||||
cek_izin,
|
||||
minta_izin,
|
||||
daftar_perangkat,
|
||||
kirim
|
||||
])
|
||||
.setup(|app, api| {
|
||||
#[cfg(mobile)]
|
||||
|
||||
@@ -25,6 +25,20 @@ pub fn init<R: Runtime, C: DeserializeOwned>(
|
||||
pub struct Bluclas<R: Runtime>(PluginHandle<R>);
|
||||
|
||||
impl<R: Runtime> Bluclas<R> {
|
||||
pub fn cek_izin(&self) -> crate::Result<bool> {
|
||||
return self
|
||||
.0
|
||||
.run_mobile_plugin("checkPermissions", ())
|
||||
.map_err(Into::into);
|
||||
}
|
||||
|
||||
pub fn minta_izin(&self) -> crate::Result<()> {
|
||||
return self
|
||||
.0
|
||||
.run_mobile_plugin("requestPermissions", ())
|
||||
.map_err(Into::into);
|
||||
}
|
||||
|
||||
pub fn daftar_perangkat(&self) -> crate::Result<SBlueclasResponDaftarPerangkat> {
|
||||
return self
|
||||
.0
|
||||
|
||||
Reference in new issue
Block a user