mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-07-10 16:27:05 +02:00
feat(app): add plugin (#345)
This commit is contained in:
committed by
GitHub
parent
02754f527c
commit
bcb42b7343
@@ -0,0 +1,33 @@
|
||||
use tauri::{AppHandle, Runtime};
|
||||
|
||||
#[tauri::command]
|
||||
pub fn version<R: Runtime>(app: AppHandle<R>) -> String {
|
||||
app.package_info().version.to_string()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn name<R: Runtime>(app: AppHandle<R>) -> String {
|
||||
app.package_info().name.clone()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn tauri_version() -> &'static str {
|
||||
// TODO: return actual tauri version with `tauri::VERSION`
|
||||
env!("CARGO_PKG_VERSION")
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[allow(unused_variables)]
|
||||
pub fn show<R: Runtime>(app: AppHandle<R>) -> tauri::Result<()> {
|
||||
#[cfg(target_os = "macos")]
|
||||
app.show()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[allow(unused_variables)]
|
||||
pub fn hide<R: Runtime>(app: AppHandle<R>) -> tauri::Result<()> {
|
||||
#[cfg(target_os = "macos")]
|
||||
app.hide()?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
use tauri::{
|
||||
plugin::{Builder, TauriPlugin},
|
||||
Runtime,
|
||||
};
|
||||
|
||||
mod commands;
|
||||
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::new("app")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
commands::version,
|
||||
commands::name,
|
||||
commands::tauri_version,
|
||||
commands::show,
|
||||
commands::hide
|
||||
])
|
||||
.build()
|
||||
}
|
||||
Reference in New Issue
Block a user