我正在try 移除停靠图标,关闭窗口,并使用Tauri让应用程序在后台运行.
我可以关闭窗口,但我不知道如何在窗口关闭后删除应用程序图标.
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello ->, {}!", name)
}
fn main() {
tauri::Builder::default()
.setup(|app| {
// #[cfg(target_os = "macos")]
// app.set_activation_policy(tauri::ActivationPolicy::Accessory); // this removes the dock icon by default
Ok(())
})
.build(tauri::generate_context!())
.expect("error while building tauri application")
.run(|_app_handle, event| match event {
// dock icon should be removed here, but I don't know how, share the app state?
tauri::RunEvent::ExitRequested { api, .. } => {
api.prevent_exit();
}
_ => {}
})
}