#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
-#[tauri::command]
+/*#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
+*/
+
+#[tauri::command]
+fn slice() {
+ println!("I was invoked from JS!");
+}
fn main() {
+ println!("launched");
tauri::Builder::default()
- .invoke_handler(tauri::generate_handler![greet])
+ //.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
<link rel="stylesheet" href="styles.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Rusty slicer</title>
- <script type="module" src="/main.js" defer></script>
+ <script src="main.js"></script>
</head>
<!-- Made by ayabusa (www.ayabusa.dev) with pain, because making html and css is awfully painfull :) -->
</select>
</div>
- <button class="slice-button" type="button"> Slice 🔪</button>
-
+ <button onclick="myFunction()" class="slice-button"> Slice 🔪</button>
+ <p id="demo">ddqdz</p>
+
<footer>
<br>
made by ayabusa ;D</footer>
const { invoke } = window.__TAURI__.tauri;
-let greetInputEl;
-let greetMsgEl;
-
-async function greet() {
- // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
- greetMsgEl.textContent = await invoke("greet", { name: greetInputEl.value });
+function myFunction() {
+ document.getElementById("demo").innerHTML = "Hello World";
+ invoke("slice")
}
-
-window.addEventListener("DOMContentLoaded", () => {
- greetInputEl = document.querySelector("#greet-input");
- greetMsgEl = document.querySelector("#greet-msg");
- document.querySelector("#greet-form").addEventListener("submit", (e) => {
- e.preventDefault();
- greet();
- });
-});