summaryrefslogtreecommitdiff
path: root/src-tauri/src
diff options
context:
space:
mode:
Diffstat (limited to 'src-tauri/src')
-rw-r--r--src-tauri/src/build.rs16
-rw-r--r--src-tauri/src/cmd.rs10
-rw-r--r--src-tauri/src/main.rs30
3 files changed, 56 insertions, 0 deletions
diff --git a/src-tauri/src/build.rs b/src-tauri/src/build.rs
new file mode 100644
index 0000000..75f4465
--- /dev/null
+++ b/src-tauri/src/build.rs
@@ -0,0 +1,16 @@
+#[cfg(windows)]
+extern crate winres;
+
+#[cfg(windows)]
+fn main() {
+ if std::path::Path::new("icons/icon.ico").exists() {
+ let mut res = winres::WindowsResource::new();
+ res.set_icon_with_id("icons/icon.ico", "32512");
+ res.compile().expect("Unable to find visual studio tools.");
+ } else {
+ panic!("No icon.ico found. Please add one or check the path.");
+ }
+}
+
+#[cfg(not(windows))]
+fn main() {}
diff --git a/src-tauri/src/cmd.rs b/src-tauri/src/cmd.rs
new file mode 100644
index 0000000..3c95a35
--- /dev/null
+++ b/src-tauri/src/cmd.rs
@@ -0,0 +1,10 @@
+use serde::Deserialize;
+
+#[derive(Deserialize)]
+#[serde(tag = "cmd", rename_all = "camelCase")]
+pub enum Cmd {
+ // your custom commands
+ // multiple arguments are allowed
+ // note that rename_all = "camelCase": you need to use "myCustomCommand" on JS
+ MyCustomCommand { argument: String },
+}
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
new file mode 100644
index 0000000..e937ebc
--- /dev/null
+++ b/src-tauri/src/main.rs
@@ -0,0 +1,30 @@
+#![cfg_attr(
+ all(not(debug_assertions), target_os = "windows"),
+ windows_subsystem = "windows"
+)]
+
+mod cmd;
+
+fn main() {
+ tauri::AppBuilder::new()
+ .invoke_handler(|_webview, arg| {
+ use cmd::Cmd::*;
+ match serde_json::from_str(arg) {
+ Err(e) => {
+ Err(e.to_string())
+ }
+ Ok(command) => {
+ match command {
+ // definitions for your custom commands from Cmd here
+ MyCustomCommand { argument } => {
+ // your command code
+ println!("{}", argument);
+ }
+ }
+ Ok(())
+ }
+ }
+ })
+ .build()
+ .run();
+}