mirror of
https://github.com/ayabusa/Rusty-slicer.git
synced 2024-11-21 18:53:25 +00:00
broken code, does not suceed at calling rust code :(
This commit is contained in:
parent
e3505f2d34
commit
035d72fd56
@ -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");
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<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 :) -->
|
||||
@ -37,8 +37,9 @@
|
||||
</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>
|
||||
|
18
src/main.js
18
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();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user