feat: habilitar provisionamento desktop e rotas CORS

This commit is contained in:
Esdras Renan 2025-10-08 23:07:49 -03:00
parent 7569986ffc
commit 152550a9a0
19 changed files with 1806 additions and 211 deletions

View file

@ -1,14 +1,43 @@
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
mod agent;
use agent::{collect_profile, AgentRuntime, MachineProfile};
use tauri_plugin_store::Builder as StorePluginBuilder;
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
fn collect_machine_profile() -> Result<MachineProfile, String> {
collect_profile().map_err(|error| error.to_string())
}
#[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(())
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.manage(AgentRuntime::new())
.plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![greet])
.plugin(StorePluginBuilder::default().build())
.invoke_handler(tauri::generate_handler![
collect_machine_profile,
start_machine_agent,
stop_machine_agent
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}