From 64fc10e147ce306432cb30366b55f9c6724a186d Mon Sep 17 00:00:00 2001 From: Jonas Kruckenberg Date: Fri, 6 Jan 2023 17:25:08 +0100 Subject: [PATCH] Update README.md --- plugins/single-instance/README.md | 38 +++++++++++++------------------ 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/plugins/single-instance/README.md b/plugins/single-instance/README.md index 5823ab98..36f855ad 100644 --- a/plugins/single-instance/README.md +++ b/plugins/single-instance/README.md @@ -1,6 +1,6 @@ -![{{plugin name}}](banner.jpg) +![tauri-plugin-single-instance](banner.jpg) - +Ensure a single instance of your tauri app is running. ## Install @@ -15,19 +15,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file: `src-tauri/Cargo.toml` ```toml [dependencies] - = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" } -``` - -You can install the JavaScript Guest bindings using your preferred JavaScript package manager: - -> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. - -```sh -pnpm add -# or -npm add -# or -yarn add +tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" } ``` ## Usage @@ -36,20 +24,26 @@ First you need to register the core plugin with Tauri: `src-tauri/src/main.rs` ```rust +use tauri::{Manager}; + +#[derive(Clone, serde::Serialize)] +struct Payload { + args: Vec, + cwd: String, +} + fn main() { tauri::Builder::default() - .plugin() + .plugin(auri_plugin_single_instance::init(|app, argv, cwd| { + println!("{}, {argv:?}, {cwd}", app.package_info().name); + + app.emit_all("single-instance", Payload { args: argv, cwd }).unwrap(); + })) .run(tauri::generate_context!()) .expect("error while running tauri application"); } ``` -Afterwards all the plugin's APIs are available through the JavaScript guest bindings: - -```javascript - -``` - ## Contributing PRs accepted. Please make sure to read the Contributing Guide before making a pull request.