36 lines
982 B
Rust
36 lines
982 B
Rust
pub mod apps;
|
|
|
|
use che_tauri::{ApiError, ApiRequest, AppState, TauriApi};
|
|
|
|
#[tauri::command]
|
|
fn greet(name: &str) -> String {
|
|
format!("Hello, {}! You've been greeted from Rust!", name)
|
|
}
|
|
|
|
#[tauri::command]
|
|
async fn che_api(
|
|
api: tauri::State<'_, TauriApi>,
|
|
request: ApiRequest,
|
|
) -> Result<serde_json::Value, ApiError> {
|
|
api.dispatch(request).await
|
|
}
|
|
|
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
|
pub fn run() {
|
|
let api = tauri::async_runtime::block_on(async {
|
|
let state = AppState::from_config_file("app.toml").await?;
|
|
TauriApi::new(state)
|
|
.install(apps::installed_apps())
|
|
.build()
|
|
.await
|
|
})
|
|
.expect("failed to initialize che-tauri");
|
|
|
|
tauri::Builder::default()
|
|
.manage(api)
|
|
.plugin(tauri_plugin_opener::init())
|
|
.invoke_handler(tauri::generate_handler![greet, che_api])
|
|
.run(tauri::generate_context!())
|
|
.expect("error while running tauri application");
|
|
}
|