T-011: Login-Flow in der App (AudibleClient-Trait, Auth- Erkennung über ~/.audible, Terminal-Login, Minimale Bibliothek; spec-Abweichung: kein Kopieren nach ~/.config, app nutzt audible-cli-pfad)
This commit is contained in:
@ -1,14 +1,28 @@
|
||||
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
||||
mod audible;
|
||||
|
||||
use audible::{AudibleClient, AuthStatus, Book, CliAudibleClient};
|
||||
|
||||
#[tauri::command]
|
||||
fn greet(name: &str) -> String {
|
||||
format!("Hello, {}! You've been greeted from Rust!", name)
|
||||
fn auth_status(client: tauri::State<CliAudibleClient>) -> Result<AuthStatus, String> {
|
||||
client.auth_status()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn start_login(client: tauri::State<CliAudibleClient>) -> Result<bool, String> {
|
||||
client.start_login()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn get_library(client: tauri::State<CliAudibleClient>) -> Result<Vec<Book>, String> {
|
||||
client.library()
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.invoke_handler(tauri::generate_handler![greet])
|
||||
.manage(CliAudibleClient::new())
|
||||
.invoke_handler(tauri::generate_handler![auth_status, start_login, get_library])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user