mirror of
https://github.com/patarapolw/cjdic2.git
synced 2026-11-09 17:39:35 +00:00
consume core in Tauri
This commit is contained in:
1 parent
876b879a65
commit
59968e0d6c
14 files changed
+157
-75
No files matched your search
+15
-5
@@ -1,15 +1,24 @@
|
||||
import { useState } from "react";
|
||||
import reactLogo from "./assets/react.svg";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import "./App.css";
|
||||
import './App.css';
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
|
||||
import reactLogo from './assets/react.svg';
|
||||
|
||||
function App() {
|
||||
const [greetMsg, setGreetMsg] = useState("");
|
||||
const [name, setName] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
invoke("list_entries").then((r) => {
|
||||
setGreetMsg(JSON.stringify(r));
|
||||
});
|
||||
}, [name]);
|
||||
|
||||
async function greet() {
|
||||
invoke("add_entry", { name });
|
||||
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
||||
setGreetMsg(await invoke("greet", { name }));
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -39,6 +48,7 @@ function App() {
|
||||
<input
|
||||
id="greet-input"
|
||||
onChange={(e) => setName(e.currentTarget.value)}
|
||||
autoComplete="off"
|
||||
placeholder="Enter a name..."
|
||||
/>
|
||||
<button type="submit">Greet</button>
|
||||
|
||||
Reference in new issue
Block a user