index.html 667 B

12345678910111213141516171819202122232425262728293031323334
  1. <!DOCTYPE html>
  2. <html lang="en-US">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Hello Tauri!</title>
  6. </head>
  7. <body>
  8. <div>
  9. <h1>Hello, Tauri!</h1>
  10. <div>
  11. <button id="ping">ping</button>
  12. <span id="pong"></span>
  13. </div>
  14. </div>
  15. <script>
  16. const { invoke } = window.__TAURI__.core
  17. const ping = document.querySelector("#ping")
  18. const pong = document.querySelector('#pong')
  19. ping.addEventListener("click", () => {
  20. invoke("ping")
  21. .then(() => {
  22. pong.innerText = `ok: ${Date.now()}`
  23. })
  24. .catch(() => {
  25. pong.innerText = `error: ${Date.now()}`
  26. })
  27. })
  28. </script>
  29. </body>
  30. </html>