App.svelte 650 B

123456789101112131415161718192021222324252627282930313233
  1. <script>
  2. import { show, hide } from '@tauri-apps/api/app'
  3. export let onMessage
  4. function showApp() {
  5. hideApp()
  6. .then(() => {
  7. setTimeout(() => {
  8. show()
  9. .then(() => onMessage('Shown app'))
  10. .catch(onMessage)
  11. }, 2000)
  12. })
  13. .catch(onMessage)
  14. }
  15. function hideApp() {
  16. return hide()
  17. .then(() => onMessage('Hide app'))
  18. .catch(onMessage)
  19. }
  20. </script>
  21. <div>
  22. <button
  23. class="btn"
  24. id="show"
  25. title="Hides and shows the app after 2 seconds"
  26. on:click={showApp}>Show</button
  27. >
  28. <button class="btn" id="hide" on:click={hideApp}>Hide</button>
  29. </div>