first
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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");
|
||||
}
|
||||
Reference in New Issue
Block a user