diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs index d938327..c20a616 100644 --- a/apps/desktop/src-tauri/src/lib.rs +++ b/apps/desktop/src-tauri/src/lib.rs @@ -32,6 +32,12 @@ fn stop_machine_agent(state: tauri::State) -> Result<(), String> { Ok(()) } +#[tauri::command] +fn open_devtools(window: tauri::WebviewWindow) -> Result<(), String> { + window.open_devtools(); + Ok(()) +} + #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { tauri::Builder::default() @@ -44,7 +50,8 @@ pub fn run() { collect_machine_profile, collect_machine_inventory, start_machine_agent, - stop_machine_agent + stop_machine_agent, + open_devtools ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); diff --git a/apps/desktop/src/main.tsx b/apps/desktop/src/main.tsx index 3b33e93..833d783 100644 --- a/apps/desktop/src/main.tsx +++ b/apps/desktop/src/main.tsx @@ -769,3 +769,26 @@ function StatusBadge({ status }: { status: string | null }) { const root = document.getElementById("root") || (() => { const el = document.createElement("div"); el.id = "root"; document.body.appendChild(el); return el })() createRoot(root).render() + // DevTools shortcut (F12 / Ctrl+Shift+I) and context menu with modifier + useEffect(() => { + function onKeyDown(e: KeyboardEvent) { + const key = (e.key || '').toLowerCase() + if (key === 'f12' || (e.ctrlKey && e.shiftKey && key === 'i')) { + invoke('open_devtools').catch(() => {}) + e.preventDefault() + } + } + function onContextMenu(e: MouseEvent) { + // Evita abrir sempre: use Ctrl ou Shift + botão direito para abrir DevTools + if (e.ctrlKey || e.shiftKey) { + invoke('open_devtools').catch(() => {}) + e.preventDefault() + } + } + window.addEventListener('keydown', onKeyDown) + window.addEventListener('contextmenu', onContextMenu) + return () => { + window.removeEventListener('keydown', onKeyDown) + window.removeEventListener('contextmenu', onContextMenu) + } + }, [])