From 035d72fd56ec8a03fc8e0c008cd6d3d3b17612fa Mon Sep 17 00:00:00 2001 From: ayabusa Date: Wed, 14 Feb 2024 18:02:42 +0100 Subject: [PATCH] broken code, does not suceed at calling rust code :( --- src-tauri/src/main.rs | 11 +++++++++-- src/index.html | 7 ++++--- src/main.js | 18 +++--------------- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 523550d..754b7da 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -2,14 +2,21 @@ #![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"); } diff --git a/src/index.html b/src/index.html index 708a08f..d2c823f 100644 --- a/src/index.html +++ b/src/index.html @@ -5,7 +5,7 @@ Rusty slicer - + @@ -37,8 +37,9 @@ - - + +

ddqdz

+ diff --git a/src/main.js b/src/main.js index 95a1702..af5aacf 100644 --- a/src/main.js +++ b/src/main.js @@ -1,18 +1,6 @@ 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(); - }); -});