From c878c96d7c54fc732fa5f0658932be5444d11e26 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Wed, 7 Aug 2024 19:36:47 -0700 Subject: [PATCH] Boiilerplate to auto-open devtools --- src-tauri/src/main.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index effc37c..f378719 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -1,6 +1,8 @@ // Prevents additional console window on Windows in release, DO NOT REMOVE!! #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] +use tauri::Manager; + // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command #[tauri::command] fn greet(name: &str) -> String { @@ -15,6 +17,15 @@ fn bash(name: &str) -> String { fn main() { tauri::Builder::default() .invoke_handler(tauri::generate_handler![greet, bash]) + .setup(|app| { + #[cfg(debug_assertions)] // only include this code on debug builds + { + let window = app.get_window("main").unwrap(); + window.open_devtools(); + window.close_devtools(); + } + Ok(()) + }) .run(tauri::generate_context!()) .expect("error while running tauri application"); }