31 lines
921 B
Rust
31 lines
921 B
Rust
|
use tauri::Manager;
|
||
|
|
||
|
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
|
||
|
#[tauri::command]
|
||
|
fn greet(name: &str) -> String {
|
||
|
format!("Hello, {}! You've been greeted from Rust!", name)
|
||
|
}
|
||
|
|
||
|
#[derive(Clone, serde::Serialize)]
|
||
|
struct Payload {
|
||
|
args: Vec<String>,
|
||
|
cwd: String,
|
||
|
}
|
||
|
|
||
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||
|
pub fn run() {
|
||
|
tauri::Builder::default()
|
||
|
.plugin(tauri_plugin_http::init())
|
||
|
.plugin(tauri_plugin_shell::init())
|
||
|
.plugin(tauri_plugin_single_instance::init(|app, argv, cwd| {
|
||
|
println!("{}, {argv:?}, {cwd}", app.package_info().name);
|
||
|
app
|
||
|
.emit("single-instance", Payload { args: argv, cwd })
|
||
|
.unwrap();
|
||
|
}))
|
||
|
.plugin(tauri_plugin_window_state::Builder::default().build())
|
||
|
.invoke_handler(tauri::generate_handler![greet])
|
||
|
.run(tauri::generate_context!())
|
||
|
.expect("error while running tauri application");
|
||
|
}
|