sistema-de-chamados/apps/desktop/src-tauri/src/lib.rs
Esdras Renan 0b39bcb56c desktop/devtools: habilitar F12/Ctrl+Shift+I e menu de contexto para abrir DevTools
- src-tauri: adiciona comando open_devtools que chama window.open_devtools()
- frontend: listeners para F12/Ctrl+Shift+I e botão direito com Ctrl/Shift

Facilita depuração de UI no executável Tauri.
2025-10-14 15:26:59 -03:00

58 lines
1.6 KiB
Rust

mod agent;
use agent::{collect_inventory_plain, collect_profile, AgentRuntime, MachineProfile};
use tauri_plugin_store::Builder as StorePluginBuilder;
#[tauri::command]
fn collect_machine_profile() -> Result<MachineProfile, String> {
collect_profile().map_err(|error| error.to_string())
}
#[tauri::command]
fn collect_machine_inventory() -> Result<serde_json::Value, String> {
Ok(collect_inventory_plain())
}
#[tauri::command]
fn start_machine_agent(
state: tauri::State<AgentRuntime>,
base_url: String,
token: String,
status: Option<String>,
interval_seconds: Option<u64>,
) -> Result<(), String> {
state
.start_heartbeat(base_url, token, status, interval_seconds)
.map_err(|error| error.to_string())
}
#[tauri::command]
fn stop_machine_agent(state: tauri::State<AgentRuntime>) -> Result<(), String> {
state.stop();
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()
.manage(AgentRuntime::new())
.plugin(tauri_plugin_opener::init())
.plugin(StorePluginBuilder::default().build())
.plugin(tauri_plugin_updater::Builder::new().build())
.plugin(tauri_plugin_process::init())
.invoke_handler(tauri::generate_handler![
collect_machine_profile,
collect_machine_inventory,
start_machine_agent,
stop_machine_agent,
open_devtools
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}