Unggahan awal
This commit is contained in:
1 parent
240227ce02
commit
9db8123021
43 files changed
+713
-2
No files matched your search
+48
@@ -0,0 +1,48 @@
|
||||
use tauri::{
|
||||
plugin::{Builder, TauriPlugin},
|
||||
Manager, Runtime,
|
||||
};
|
||||
|
||||
pub use models::*;
|
||||
|
||||
#[cfg(desktop)]
|
||||
mod desktop;
|
||||
#[cfg(mobile)]
|
||||
mod mobile;
|
||||
|
||||
mod commands;
|
||||
mod error;
|
||||
mod models;
|
||||
|
||||
pub use error::{Error, Result};
|
||||
|
||||
#[cfg(desktop)]
|
||||
use desktop::Bluclas;
|
||||
#[cfg(mobile)]
|
||||
use mobile::Bluclas;
|
||||
|
||||
/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the bluclas APIs.
|
||||
pub trait BluclasExt<R: Runtime> {
|
||||
fn bluclas(&self) -> &Bluclas<R>;
|
||||
}
|
||||
|
||||
impl<R: Runtime, T: Manager<R>> crate::BluclasExt<R> for T {
|
||||
fn bluclas(&self) -> &Bluclas<R> {
|
||||
self.state::<Bluclas<R>>().inner()
|
||||
}
|
||||
}
|
||||
|
||||
/// Initializes the plugin.
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::new("bluclas")
|
||||
.invoke_handler(tauri::generate_handler![commands::ping])
|
||||
.setup(|app, api| {
|
||||
#[cfg(mobile)]
|
||||
let bluclas = mobile::init(app, api)?;
|
||||
#[cfg(desktop)]
|
||||
let bluclas = desktop::init(app, api)?;
|
||||
app.manage(bluclas);
|
||||
Ok(())
|
||||
})
|
||||
.build()
|
||||
}
|
||||
Reference in new issue
Block a user