mirror of
https://github.com/readest/readest.git
synced 2026-04-29 12:00:49 +00:00
refactor: rename plugin safari-auth to native-bridge (#749)
* fix: layout tweaks for mobile * refactor: rename plugin safari-auth to native-bridge
This commit is contained in:
parent
f90177713a
commit
a72c8f2391
46 changed files with 145 additions and 144 deletions
|
|
@ -1,48 +0,0 @@
|
|||
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::SafariAuth;
|
||||
#[cfg(mobile)]
|
||||
use mobile::SafariAuth;
|
||||
|
||||
/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the safari-auth APIs.
|
||||
pub trait SafariAuthExt<R: Runtime> {
|
||||
fn safari_auth(&self) -> &SafariAuth<R>;
|
||||
}
|
||||
|
||||
impl<R: Runtime, T: Manager<R>> crate::SafariAuthExt<R> for T {
|
||||
fn safari_auth(&self) -> &SafariAuth<R> {
|
||||
self.state::<SafariAuth<R>>().inner()
|
||||
}
|
||||
}
|
||||
|
||||
/// Initializes the plugin.
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::new("safari-auth")
|
||||
.invoke_handler(tauri::generate_handler![commands::auth_with_safari])
|
||||
.setup(|app, api| {
|
||||
#[cfg(mobile)]
|
||||
let safari_auth = mobile::init(app, api)?;
|
||||
#[cfg(desktop)]
|
||||
let safari_auth = desktop::init(app, api)?;
|
||||
app.manage(safari_auth);
|
||||
Ok(())
|
||||
})
|
||||
.build()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue