parent
29091a387b
commit
ea6d7e86f1
@ -1,21 +1,30 @@ |
|||||||
<script lang="ts"> |
<script lang="ts"> |
||||||
import { invoke } from "@tauri-apps/api/tauri" |
|
||||||
|
|
||||||
let name = ""; |
let name = ""; |
||||||
let greetMsg = "" |
let greetMsg = ""; |
||||||
|
let ng; |
||||||
|
|
||||||
|
if (import.meta.env.NG_APP_WEB) { |
||||||
|
ng = { |
||||||
|
greet: async function (n) { |
||||||
|
return "greetings from web " + n; |
||||||
|
}, |
||||||
|
}; |
||||||
|
} else { |
||||||
|
import("@tauri-apps/api/tauri").then((tauri) => { |
||||||
|
ng = { greet: (n) => tauri.invoke("greet", { name: n }) }; |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
async function greet() { |
async function greet() { |
||||||
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command |
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command |
||||||
greetMsg = await invoke("greet", { name }) |
greetMsg = await ng.greet(name); |
||||||
} |
} |
||||||
</script> |
</script> |
||||||
|
|
||||||
<div> |
<div> |
||||||
<div class="row"> |
<div class="row"> |
||||||
<input id="greet-input" placeholder="Enter a name..." bind:value={name} /> |
<input id="greet-input" placeholder="Enter a name..." bind:value={name} /> |
||||||
<button on:click={greet}> |
<button on:click={greet}> Greet </button> |
||||||
Greet |
|
||||||
</button> |
|
||||||
</div> |
</div> |
||||||
<p>{greetMsg}</p> |
<p>{greetMsg}</p> |
||||||
</div> |
</div> |
Loading…
Reference in new issue