feat: update to tauri beta, add permissions (#862)

Co-authored-by: Lucas Nogueira <lucas@tauri.app>
Co-authored-by: Lucas Nogueira <lucas@crabnebula.dev>
This commit is contained in:
Tillmann
2024-02-04 03:14:41 +09:00
committed by GitHub
parent 506ce4835b
commit d198c01486
387 changed files with 21883 additions and 943 deletions
+4 -16
View File
@@ -12,18 +12,15 @@ use tauri::{
AppHandle, Manager, Runtime,
};
use crate::config::{Config, HttpAllowlistScope};
pub use error::{Error, Result};
mod commands;
mod config;
mod error;
mod scope;
struct Http<R: Runtime> {
#[allow(dead_code)]
app: AppHandle<R>,
scope: scope::Scope,
}
trait HttpExt<R: Runtime> {
@@ -36,8 +33,8 @@ impl<R: Runtime, T: Manager<R>> HttpExt<R> for T {
}
}
pub fn init<R: Runtime>() -> TauriPlugin<R, Option<Config>> {
Builder::<R, Option<Config>>::new("http")
pub fn init<R: Runtime>() -> TauriPlugin<R> {
Builder::<R>::new("http")
.js_init_script(include_str!("api-iife.js").to_string())
.invoke_handler(tauri::generate_handler![
commands::fetch,
@@ -45,17 +42,8 @@ pub fn init<R: Runtime>() -> TauriPlugin<R, Option<Config>> {
commands::fetch_send,
commands::fetch_read_body,
])
.setup(|app, api| {
let default_scope = HttpAllowlistScope::default();
app.manage(Http {
app: app.clone(),
scope: scope::Scope::new(
api.config()
.as_ref()
.map(|c| &c.scope)
.unwrap_or(&default_scope),
),
});
.setup(|app, _api| {
app.manage(Http { app: app.clone() });
Ok(())
})
.build()