mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2026-07-24 17:03:14 +10:00
migrate to nuxt and groundwork
This commit is contained in:
+31
-10
@@ -1,24 +1,45 @@
|
||||
mod auth;
|
||||
mod data;
|
||||
mod unpacker;
|
||||
|
||||
use data::DatabaseInterface;
|
||||
use serde::Serialize;
|
||||
use tauri::Runtime;
|
||||
use unpacker::unpack;
|
||||
|
||||
#[derive(Clone, Copy, Serialize)]
|
||||
pub enum AppAuthenticationStatus {
|
||||
SignedOut,
|
||||
SignedIn,
|
||||
SignedInNeedsReauth,
|
||||
}
|
||||
#[derive(Clone, Copy, Serialize)]
|
||||
pub struct User {}
|
||||
|
||||
#[derive(Clone, Copy, Serialize)]
|
||||
pub struct AppState {
|
||||
auth: AppAuthenticationStatus,
|
||||
user: Option<User>,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn unpack_debug<R: Runtime>(
|
||||
app: tauri::AppHandle<R>,
|
||||
window: tauri::Window<R>,
|
||||
) -> Result<String, String> {
|
||||
|
||||
unpack().unwrap();
|
||||
|
||||
return Ok("Successful".to_string());
|
||||
fn fetch_state(state: tauri::State<AppState>) -> Result<AppState, String> {
|
||||
Ok(*state.inner())
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
let db: DatabaseInterface = data::setup();
|
||||
let auth_result = auth::setup(db).unwrap();
|
||||
|
||||
let state = AppState {
|
||||
auth: auth_result.0,
|
||||
user: auth_result.1,
|
||||
};
|
||||
|
||||
tauri::Builder::default()
|
||||
.manage(state)
|
||||
.invoke_handler(tauri::generate_handler![fetch_state])
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.invoke_handler(tauri::generate_handler![unpack_debug])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user