diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 3806ee9..c9db333 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -15,18 +15,18 @@ fn greet(name: &str) -> String { } #[tauri::command] -async fn second_window(app: tauri::AppHandle, _window: tauri::Window) -> Result { +async fn login(app: tauri::AppHandle, _window: tauri::Window) -> Result { let result = Authentification::login(Prompt::SelectAccount, app).await; match result { Ok(val) => Ok(format!("Hello {}", val.1)), - Err(err) => Ok(err.to_string()) + Err(err) => Err(err.to_string()) } } #[tokio::main] async fn main() { tauri::Builder::default() - .invoke_handler(tauri::generate_handler![greet, second_window]) + .invoke_handler(tauri::generate_handler![greet, login]) .run(tauri::generate_context!()) .expect("error while running tauri application"); } diff --git a/src/index.html b/src/index.html index b2fc8e7..f276387 100644 --- a/src/index.html +++ b/src/index.html @@ -17,28 +17,10 @@

Welcome to Tauri!

- - -

Click on the Tauri logo to learn more about the framework

-
- - + +
diff --git a/src/main.js b/src/main.js index f109d08..78dc021 100644 --- a/src/main.js +++ b/src/main.js @@ -1,17 +1,20 @@ const { invoke } = window.__TAURI__.tauri; -let greetInputEl; let greetMsgEl; +let greetButton; async function greet() { // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command - greetMsgEl.textContent = await invoke("second_window", { name: greetInputEl.value }); + // greetMsgEl.textContent = await invoke("login", {}); + invoke("login", {}).then(value => { + greetMsgEl.textContent = value + }).catch(err => { + greetMsgEl.textContent = "Error: " + err + }) } window.addEventListener("DOMContentLoaded", () => { - greetInputEl = document.querySelector("#greet-input"); greetMsgEl = document.querySelector("#greet-msg"); - document - .querySelector("#greet-button") - .addEventListener("click", () => greet()); + greetButton = document.querySelector("#greet-button") + greetButton.addEventListener("click", () => greet()); });