37 lines
725 B
Rust
37 lines
725 B
Rust
#![cfg_attr(
|
|
all(not(debug_assertions), target_os = "windows"),
|
|
windows_subsystem = "windows"
|
|
)]
|
|
|
|
mod models;
|
|
mod monitor;
|
|
mod cli;
|
|
|
|
use tauri::State;
|
|
use crate::monitor::Monitor;
|
|
use crate::models::GlobalStats;
|
|
|
|
struct AppState {
|
|
monitor: Monitor,
|
|
}
|
|
|
|
#[tauri::command]
|
|
fn get_latest_stats(state: State<AppState>) -> GlobalStats {
|
|
state.monitor.get_latest()
|
|
}
|
|
|
|
fn main() {
|
|
let monitor = Monitor::new();
|
|
monitor.start();
|
|
|
|
tauri::Builder::default()
|
|
.manage(AppState {
|
|
monitor
|
|
})
|
|
.invoke_handler(tauri::generate_handler![
|
|
get_latest_stats
|
|
])
|
|
.run(tauri::generate_context!())
|
|
.expect("error while running tauri application");
|
|
}
|